Changeset 99551 in vbox for trunk/src/bldprogs
- Timestamp:
- Apr 27, 2023 6:12:59 PM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/VBoxDef2LazyLoad.cpp
r99540 r99551 51 51 char const *pszExportedNm; 52 52 unsigned uOrdinal; 53 /** NONAME. */ 53 54 bool fNoName; 55 /** DATA symbol if true, otherwise function. */ 56 bool fData; 54 57 char szName[1]; 55 58 } MYEXPORT; … … 227 230 } 228 231 232 bool fData = false; 229 233 while (*psz) 230 234 { … … 232 236 if (WORD_CMP(psz, cch, "DATA")) 233 237 { 238 fData = true; 234 239 if (!g_fIgnoreData) 235 240 { … … 239 244 } 240 245 } 241 else if ( !WORD_CMP(psz, cch, "PRIVATE"))246 else if (WORD_CMP(psz, cch, "PRIVATE")) 242 247 { 243 fprintf(stderr, "%s:%u: error: Cannot process DATAexport '%.*s'.\n",248 fprintf(stderr, "%s:%u: error: Cannot process PRIVATE export '%.*s'.\n", 244 249 pszInput, iLine, cchName, pchName); 245 250 return RTEXITCODE_SUCCESS; 251 } 252 else 253 { 254 fprintf(stderr, "%s:%u: error: Unknown keyword: %.*s.\n", pszInput, iLine, cch, psz); 255 return RTEXITCODE_FAILURE; 246 256 } 247 257 psz = leftStrip(psz + cch); … … 266 276 * Add the export. 267 277 */ 268 269 278 PMYEXPORT pExp = (PMYEXPORT)malloc(cbExp); 270 279 if (!pExp) 271 280 { 272 281 fprintf(stderr, "%s:%u: error: Out of memory.\n", pszInput, iLine); 273 return RTEXITCODE_ SUCCESS;282 return RTEXITCODE_FAILURE; 274 283 } 275 284 memcpy(pExp->szName, pchName, cchName); … … 289 298 pExp->uOrdinal = uOrdinal; 290 299 pExp->fNoName = fNoName; 300 pExp->fData = fData; 291 301 pExp->pNext = NULL; 292 302 *g_ppExpNext = pExp; … … 372 382 "BEGINCODE\n"); 373 383 for (PMYEXPORT pExp = g_pExpHead; pExp; pExp = pExp->pNext) 374 if (!pExp->pszUnstdcallName) 384 if (pExp->fData) 385 fprintf(pOutput, 386 "BEGINPROC LazyGetPtr_%s\n" 387 " mov xAX, [NAME(g_p%s) xWrtRIP]\n" 388 " test xAX, xAX\n" 389 " jz ___LazyLoad___%s\n" 390 " ret\n" 391 "ENDPROC LazyGetPtr_%s\n", 392 pExp->szName, pExp->szName, pExp->szName, pExp->szName); 393 else if (!pExp->pszUnstdcallName) 375 394 fprintf(pOutput, 376 395 "BEGINPROC %s\n" 377 " jmp RTCCPTR_PRE [ g_pfn%sxWrtRIP]\n"396 " jmp RTCCPTR_PRE [NAME(g_pfn%s) xWrtRIP]\n" 378 397 "ENDPROC %s\n", 379 398 pExp->szName, pExp->szName, pExp->szName); … … 383 402 "global %s\n" 384 403 "%s:\n" 385 " jmp RTCCPTR_PRE [ g_pfn%sxWrtRIP]\n"404 " jmp RTCCPTR_PRE [NAME(g_pfn%s) xWrtRIP]\n" 386 405 "%%else\n" 387 406 "BEGINPROC %s\n" 388 " jmp RTCCPTR_PRE [ g_pfn%sxWrtRIP]\n"407 " jmp RTCCPTR_PRE [NAME(g_pfn%s) xWrtRIP]\n" 389 408 "ENDPROC %s\n" 390 409 "%%endif\n", … … 406 425 "g_apfnImports:\n"); 407 426 for (PMYEXPORT pExp = g_pExpHead; pExp; pExp = pExp->pNext) 408 if (pExp->pszUnstdcallName) 427 if (pExp->fData) 428 fprintf(pOutput, 429 "%%ifdef ASM_FORMAT_PE\n" 430 ";@todo\n" 431 "%%endif\n" 432 "global NAME(g_p%s)\n" 433 "NAME(g_p%s): RTCCPTR_DEF 0\n", 434 pExp->pszExportedNm, pExp->pszExportedNm); 435 else if (pExp->pszUnstdcallName) 409 436 fprintf(pOutput, 410 437 "%%ifdef ASM_FORMAT_PE\n" … … 417 444 " %%endif\n" 418 445 "%%endif\n" 419 " g_pfn%sRTCCPTR_DEF ___LazyLoad___%s\n"446 "NAME(g_pfn%s) RTCCPTR_DEF ___LazyLoad___%s\n" 420 447 "\n", 421 448 pExp->szName, … … 431 458 "__imp_%s:\n" 432 459 "%%endif\n" 433 " g_pfn%sRTCCPTR_DEF ___LazyLoad___%s\n"460 "NAME(g_pfn%s) RTCCPTR_DEF ___LazyLoad___%s\n" 434 461 "\n", 435 462 pExp->szName, … … 486 513 "%%ifdef RT_ARCH_AMD64\n" 487 514 " lea rax, [g_sz%s wrt rip]\n" 488 " lea r10, [ g_pfn%swrt rip]\n"515 " lea r10, [NAME(g_p%s%s) wrt rip]\n" 489 516 " call LazyLoadResolver\n" 490 517 "%%elifdef RT_ARCH_X86\n" 491 518 " push g_sz%s\n" 492 " push g_pfn%s\n"519 " push NAME(g_p%s%s)\n" 493 520 " call LazyLoadResolver\n" 494 521 " add esp, 8h\n" … … 499 526 pExp->pszExportedNm, 500 527 pExp->pszExportedNm, 528 !pExp->fData ? "fn" : "", pExp->pszExportedNm, 501 529 pExp->pszExportedNm, 502 pExp->pszExportedNm, 503 pExp->pszExportedNm); 530 !pExp->fData ? "fn" : "", pExp->pszExportedNm); 504 531 else 505 532 fprintf(pOutput, … … 508 535 "%%ifdef RT_ARCH_AMD64\n" 509 536 " mov eax, %u\n" 510 " lea r10, [ g_pfn%swrt rip]\n"537 " lea r10, [NAME(g_p%s%s) wrt rip]\n" 511 538 " call LazyLoadResolver\n" 512 539 "%%elifdef RT_ARCH_X86\n" 513 540 " push %u\n" 514 " push g_pfn%s\n"541 " push NAME(g_p%s%s)\n" 515 542 " call LazyLoadResolver\n" 516 543 " add esp, 8h\n" … … 521 548 pExp->pszExportedNm, 522 549 pExp->uOrdinal, 523 pExp->pszExportedNm,550 !pExp->fData ? "fn" : "", pExp->pszExportedNm, 524 551 pExp->uOrdinal, 525 pExp->pszExportedNm); 526 if (!pExp->pszUnstdcallName) 552 !pExp->fData ? "fn" : "", pExp->pszExportedNm); 553 if (pExp->fData) 554 fprintf(pOutput, " jmp NAME(LazyGetPtr_%s)\n", pExp->szName); 555 else if (!pExp->pszUnstdcallName) 527 556 fprintf(pOutput, " jmp NAME(%s)\n", pExp->szName); 528 557 else … … 1099 1128 ".section __TEXT,__text,regular,pure_instructions\n"); 1100 1129 for (PMYEXPORT pExp = g_pExpHead; pExp; pExp = pExp->pNext) 1101 fprintf(pOutput, 1102 ".p2align 3\n" 1103 ".globl %s%s\n" 1104 "%s%s:\n" 1105 " adrp x9, %sg_pfn%s@PAGE\n" 1106 " ldr x9, [x9, %sg_pfn%s@PAGEOFF]\n" 1107 " br x9\n", 1108 pszNmPfx, pExp->szName, pszNmPfx, pExp->szName, pszNmPfx, pExp->szName, pszNmPfx, pExp->szName); 1130 if (!pExp->fData) 1131 fprintf(pOutput, 1132 ".p2align 3\n" 1133 ".globl %s%s\n" 1134 "%s%s:\n" 1135 " adrp x9, %sg_pfn%s@PAGE\n" 1136 " ldr x9, [x9, %sg_pfn%s@PAGEOFF]\n" 1137 " br x9\n", 1138 pszNmPfx, pExp->szName, pszNmPfx, pExp->szName, pszNmPfx, pExp->szName, pszNmPfx, pExp->szName); 1139 else 1140 fprintf(pOutput, 1141 ".p2align 3\n" 1142 ".globl %sLazyGetPtr_%s\n" 1143 "%sLazyGetPtr_%s:\n" 1144 " adrp x9, %sg_p%s@PAGE\n" 1145 " ldr x9, [x9, %sg_p%s@PAGEOFF]\n" 1146 " cmp x9, #0\n" 1147 " b.ne ___LazyLoad___%s\n" 1148 " mov x0, x9\n" 1149 " ret\n", 1150 pszNmPfx, pExp->szName, pszNmPfx, pExp->szName, pszNmPfx, pExp->szName, pszNmPfx, pExp->szName, pExp->pszExportedNm); 1109 1151 fprintf(pOutput, 1110 1152 "\n" … … 1122 1164 "g_apfnImports:\n"); 1123 1165 for (PMYEXPORT pExp = g_pExpHead; pExp; pExp = pExp->pNext) 1124 fprintf(pOutput, 1125 ".globl __imp_%s\n" 1126 "__imp_%s:\n" 1127 ".globl %sg_pfn%s\n" 1128 "%sg_pfn%s:\n" 1129 " .quad ___LazyLoad___%s\n" 1130 "\n", 1131 pExp->szName, pExp->szName, 1132 pszNmPfx, pExp->szName, pszNmPfx, pExp->szName, 1133 pExp->pszExportedNm); 1166 if (!pExp->fData) 1167 fprintf(pOutput, 1168 ".globl __imp_%s\n" 1169 "__imp_%s:\n" 1170 ".globl %sg_pfn%s\n" 1171 "%sg_pfn%s:\n" 1172 " .quad ___LazyLoad___%s\n" 1173 "\n", 1174 pExp->szName, pExp->szName, 1175 pszNmPfx, pExp->szName, pszNmPfx, pExp->szName, 1176 pExp->pszExportedNm); 1177 else 1178 fprintf(pOutput, 1179 ".globl %sg_p%s\n" 1180 "%sg_p%s:\n" 1181 " .quad 0\n" 1182 "\n", 1183 pszNmPfx, pExp->szName, pszNmPfx, pExp->szName); 1134 1184 fprintf(pOutput, 1135 1185 " .quad 0 ; Terminator entry for traversal.\n" … … 1182 1232 " adrp x9, g_sz%s@PAGE\n" 1183 1233 " add x9, x9, g_sz%s@PAGEOFF\n" 1184 " adrp x10, %sg_p fn%s@PAGE\n"1185 " add x10, x10, %sg_p fn%s@PAGEOFF\n"1234 " adrp x10, %sg_p%s%s@PAGE\n" 1235 " add x10, x10, %sg_p%s%s@PAGEOFF\n" 1186 1236 " bl LazyLoadResolver\n" 1187 1237 , pExp->pszExportedNm, 1188 1238 pExp->pszExportedNm, pExp->pszExportedNm, 1189 pszNmPfx, pExp->pszExportedNm, pszNmPfx, pExp->pszExportedNm); 1239 pszNmPfx, !pExp->fData ? "fn" : "", pExp->pszExportedNm, 1240 pszNmPfx, !pExp->fData ? "fn" : "", pExp->pszExportedNm); 1190 1241 else 1191 1242 fprintf(pOutput, … … 1197 1248 pExp->uOrdinal, 1198 1249 pszNmPfx, pExp->pszExportedNm, pszNmPfx, pExp->pszExportedNm); 1199 fprintf(pOutput, " b %s%s\n", pszNmPfx, pExp->szName); 1250 if (!pExp->fData) 1251 fprintf(pOutput, " b %s%s\n", pszNmPfx, pExp->szName); 1252 else 1253 fprintf(pOutput, " b %sLazyGetPtr_%s\n", pszNmPfx, pExp->szName); 1200 1254 fprintf(pOutput, "\n"); 1201 1255 }
Note:
See TracChangeset
for help on using the changeset viewer.