Changeset 99552 in vbox
- Timestamp:
- Apr 27, 2023 8:16:20 PM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/VBoxDef2LazyLoad.cpp
r99551 r99552 385 385 fprintf(pOutput, 386 386 "BEGINPROC LazyGetPtr_%s\n" 387 " mov xAX, [NAME(g_ p%s) xWrtRIP]\n"387 " mov xAX, [NAME(g_LazyPtr_%s) xWrtRIP]\n" 388 388 " test xAX, xAX\n" 389 389 " jz ___LazyLoad___%s\n" … … 430 430 ";@todo\n" 431 431 "%%endif\n" 432 "global NAME(g_ p%s)\n"433 "NAME(g_ p%s): RTCCPTR_DEF 0\n",432 "global NAME(g_LazyPtr_%s)\n" 433 "NAME(g_LazyPtr_%s): RTCCPTR_DEF 0\n", 434 434 pExp->pszExportedNm, pExp->pszExportedNm); 435 435 else if (pExp->pszUnstdcallName) … … 513 513 "%%ifdef RT_ARCH_AMD64\n" 514 514 " lea rax, [g_sz%s wrt rip]\n" 515 " lea r10, [NAME( g_p%s%s) wrt rip]\n"515 " lea r10, [NAME(%s%s) wrt rip]\n" 516 516 " call LazyLoadResolver\n" 517 517 "%%elifdef RT_ARCH_X86\n" 518 518 " push g_sz%s\n" 519 " push NAME( g_p%s%s)\n"519 " push NAME(%s%s)\n" 520 520 " call LazyLoadResolver\n" 521 521 " add esp, 8h\n" … … 526 526 pExp->pszExportedNm, 527 527 pExp->pszExportedNm, 528 !pExp->fData ? " fn" : "", pExp->pszExportedNm,528 !pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm, 529 529 pExp->pszExportedNm, 530 !pExp->fData ? " fn" : "", pExp->pszExportedNm);530 !pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm); 531 531 else 532 532 fprintf(pOutput, … … 535 535 "%%ifdef RT_ARCH_AMD64\n" 536 536 " mov eax, %u\n" 537 " lea r10, [NAME( g_p%s%s) wrt rip]\n"537 " lea r10, [NAME(%s%s) wrt rip]\n" 538 538 " call LazyLoadResolver\n" 539 539 "%%elifdef RT_ARCH_X86\n" 540 540 " push %u\n" 541 " push NAME( g_p%s%s)\n"541 " push NAME(%s%s)\n" 542 542 " call LazyLoadResolver\n" 543 543 " add esp, 8h\n" … … 548 548 pExp->pszExportedNm, 549 549 pExp->uOrdinal, 550 !pExp->fData ? " fn" : "", pExp->pszExportedNm,550 !pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm, 551 551 pExp->uOrdinal, 552 !pExp->fData ? " fn" : "", pExp->pszExportedNm);552 !pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm); 553 553 if (pExp->fData) 554 554 fprintf(pOutput, " jmp NAME(LazyGetPtr_%s)\n", pExp->szName); … … 1142 1142 ".globl %sLazyGetPtr_%s\n" 1143 1143 "%sLazyGetPtr_%s:\n" 1144 " adrp x9, %sg_ p%s@PAGE\n"1145 " ldr x9, [x9, %sg_ p%s@PAGEOFF]\n"1144 " adrp x9, %sg_LazyPtr_%s@PAGE\n" 1145 " ldr x9, [x9, %sg_LazyPtr_%s@PAGEOFF]\n" 1146 1146 " cmp x9, #0\n" 1147 1147 " b.ne ___LazyLoad___%s\n" … … 1177 1177 else 1178 1178 fprintf(pOutput, 1179 ".globl %sg_ p%s\n"1180 "%sg_ p%s:\n"1179 ".globl %sg_LazyPtr_%s\n" 1180 "%sg_LazyPtr_%s:\n" 1181 1181 " .quad 0\n" 1182 1182 "\n", … … 1232 1232 " adrp x9, g_sz%s@PAGE\n" 1233 1233 " add x9, x9, g_sz%s@PAGEOFF\n" 1234 " adrp x10, %s g_p%s%s@PAGE\n"1235 " add x10, x10, %s g_p%s%s@PAGEOFF\n"1234 " adrp x10, %s%s%s@PAGE\n" 1235 " add x10, x10, %s%s%s@PAGEOFF\n" 1236 1236 " bl LazyLoadResolver\n" 1237 1237 , pExp->pszExportedNm, 1238 1238 pExp->pszExportedNm, pExp->pszExportedNm, 1239 pszNmPfx, !pExp->fData ? " fn" : "", pExp->pszExportedNm,1240 pszNmPfx, !pExp->fData ? " fn" : "", pExp->pszExportedNm);1239 pszNmPfx, !pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm, 1240 pszNmPfx, !pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm); 1241 1241 else 1242 1242 fprintf(pOutput, 1243 1243 "___LazyLoad___%s:\n" 1244 1244 " movk w9, #%u\n" 1245 " adrp x10, %s g_pfn%s@PAGE\n"1246 " add x10, x10, %s g_pfn%s@PAGEOFF\n"1245 " adrp x10, %s%s%s@PAGE\n" 1246 " add x10, x10, %s%s%s@PAGEOFF\n" 1247 1247 , pExp->pszExportedNm, 1248 1248 pExp->uOrdinal, 1249 pszNmPfx, pExp->pszExportedNm, pszNmPfx, pExp->pszExportedNm); 1249 pszNmPfx, !pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm, 1250 pszNmPfx, !pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm); 1250 1251 if (!pExp->fData) 1251 1252 fprintf(pOutput, " b %s%s\n", pszNmPfx, pExp->szName); … … 1643 1644 static int usage(const char *pszArgv0) 1644 1645 { 1645 printf("usage: %s [options] --libary <loadname> --output <lazyload.asm> <input.def>\n" 1646 const char *pszTmp = strrchr(pszArgv0, '/'); 1647 if (pszTmp) 1648 pszArgv0 = pszTmp + 1; 1649 pszTmp = strrchr(pszArgv0, '\\'); 1650 if (pszTmp) 1651 pszArgv0 = pszTmp + 1; 1652 1653 /* 0 1 2 3 4 5 6 7 8 1654 012345678901234567890123456789012345678901234567890123456789012345678901234567890 */ 1655 printf("VBoxDef2LazyLoad - Lazy DLL/SO/DYLIB loader code generator.\n" 1656 "Copyright (C) 2013-2016 Oracle Corporation\n" 1657 "\n" 1658 "Description:\n" 1659 "------------\n" 1660 "\n" 1661 "Takes a Microsoft-style linker definition file for a library (DLL/SO/DYLIB) and\n" 1662 "generates assembly code which defines stub functions that lazily loads and\n" 1663 "resolves the real symbols before calling them. This is entirely transparent when\n" 1664 "used with functions.\n" 1665 "\n" 1666 "With data symbols it's more messy since the compiler will not invoke code when\n" 1667 "using them, but access them directly (ELF executables) or indirectly (ELF SOs,\n" 1668 "PE, ++). For data symbols use the DATA keyword after the symbol name in the\n" 1669 "def-file and modify the header definition from 'extern type symbol;' to:\n" 1670 "\n" 1671 " DECLASM(type *) LazyGetPtr_<symbol>(void);\n" 1672 " #define <symbol> (*LazyGetPtr_<symbol>())\n" 1673 "\n" 1674 "or, if using --explict-load-function this will work as well:\n" 1675 "\n" 1676 " extern type *g_LazyPtr_<symbol>;\n" 1677 " #define <symbol> (*g_LazyPtr_)\n" 1678 "\n" 1679 "Usage:\n" 1680 "------\n" 1681 "%s [options] --libary <loadname> --output <lazyload.asm> <input.def>\n" 1646 1682 "\n" 1647 1683 "Options:\n" 1684 "--------\n" 1685 " --library <loadname>, -l <loadname>\n" 1686 " The name of the library. This is what will be passed to RTLdrLoadSystem\n" 1687 " or SUPR3HardenedLdrLoadAppPriv.\n" 1688 " --output <filename>, -o <filename>\n" 1689 " The assembly output file.\n" 1648 1690 " --explicit-load-function, --no-explicit-load-function\n" 1649 " Whether to include the explicit load function, default is not to.\n" 1691 " Whether to include the explicit load function:\n" 1692 " DECLASM(int) ExplicitlyLoad<basename>(bool fResolveAllImports, pErrInfo);\n" 1693 " The default is not to include it.\n" 1694 " --system\n" 1695 " The library is a system DLL to be loaded using RTLdrLoadSystem.\n" 1696 " The default is to use SUPR3HardenedLdrLoadAppPriv to load it.\n" 1650 1697 "\n" 1651 "Copyright (C) 2013-2016 Oracle Corporation\n"1652 1698 , pszArgv0); 1653 1699
Note:
See TracChangeset
for help on using the changeset viewer.