Changeset 100275 in vbox for trunk/src/bldprogs/VBoxDef2LazyLoad.cpp
- Timestamp:
- Jun 23, 2023 10:54:34 PM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bldprogs/VBoxDef2LazyLoad.cpp
r100273 r100275 78 78 #elif defined(RT_ARCH_ARM64) 79 79 static RTLDRARCH g_enmTarget = RTLDRARCH_ARM64; 80 #else81 # error "Port me!"82 #endif83 #if defined(RT_OS_DARWIN)84 static RTLDRFMT g_enmLdrFmt = RTLDRFMT_MACHO;85 #elif defined(RT_OS_WINDOWS)86 static RTLDRFMT g_enmLdrFmt = RTLDRFMT_PE;87 #elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_SOLARIS) \88 || defined(RT_OS_NETBSD) || defined(RT_OS_OPENBSD)89 static RTLDRFMT g_enmLdrFmt = RTLDRFMT_ELF;90 #elif defined(RT_OS_OS2)91 static RTLDRFMT g_enmLdrFmt = RTLDRFMT_LX;92 80 #else 93 81 # error "Port me!" … … 1114 1102 static RTEXITCODE generateOutputInnerArm64(FILE *pOutput) 1115 1103 { 1116 const char *pszNmPfx = g_enmLdrFmt == RTLDRFMT_ELF ? "" : "_";1117 1118 1104 fprintf(pOutput, "/*\n"); 1119 1105 for (unsigned i = 0; i < g_cInputs; i++) … … 1141 1127 fprintf(pOutput, 1142 1128 ".p2align 3\n" 1143 ".globl %s%s\n"1144 " %s%s:\n"1145 " adrp x9, PAGE( %sg_pfn%s)\n"1146 " ldr x9, [x9, PAGEOFF( %sg_pfn%s)]\n"1129 ".globl NAME(%s)\n" 1130 "NAME(%s):\n" 1131 " adrp x9, PAGE(NAME(g_pfn%s))\n" 1132 " ldr x9, [x9, PAGEOFF(NAME(g_pfn%s))]\n" 1147 1133 " br x9\n", 1148 p szNmPfx, pExp->szName, pszNmPfx, pExp->szName, pszNmPfx, pExp->szName, pszNmPfx, pExp->szName);1134 pExp->szName, pExp->szName, pExp->szName, pExp->szName); 1149 1135 else 1150 1136 fprintf(pOutput, 1151 1137 ".p2align 3\n" 1152 ".globl %sLazyGetPtr_%s\n"1153 " %sLazyGetPtr_%s:\n"1154 " adrp x9, PAGE( %sg_LazyPtr_%s)\n"1155 " ldr x9, [x9, PAGEOFF( %sg_LazyPtr_%s)]\n"1138 ".globl NAME(LazyGetPtr_%s)\n" 1139 "NAME(LazyGetPtr_%s):\n" 1140 " adrp x9, PAGE(NAME(g_LazyPtr_%s))\n" 1141 " ldr x9, [x9, PAGEOFF(NAME(g_LazyPtr_%s))]\n" 1156 1142 " cmp x9, #0\n" 1157 1143 " b.eq ___LazyLoad___%s\n" 1158 1144 " mov x0, x9\n" 1159 1145 " ret\n", 1160 p szNmPfx, pExp->szName, pszNmPfx, pExp->szName, pszNmPfx, pExp->szName, pszNmPfx, pExp->szName, pExp->pszExportedNm);1146 pExp->szName, pExp->szName, pExp->szName, pExp->szName, pExp->pszExportedNm); 1161 1147 fprintf(pOutput, 1162 1148 "ENDCODE\n" … … 1179 1165 ".globl __imp_%s\n" 1180 1166 "__imp_%s:\n" 1181 ".globl %sg_pfn%s\n"1182 " %sg_pfn%s:\n"1167 ".globl NAME(g_pfn%s)\n" 1168 "NAME(g_pfn%s):\n" 1183 1169 " .quad ___LazyLoad___%s\n" 1184 1170 "\n", 1185 1171 pExp->szName, pExp->szName, 1186 p szNmPfx, pExp->szName, pszNmPfx, pExp->szName,1172 pExp->szName, pExp->szName, 1187 1173 pExp->pszExportedNm); 1188 1174 else 1189 1175 fprintf(pOutput, 1190 ".globl %sg_LazyPtr_%s\n"1191 " %sg_LazyPtr_%s:\n"1176 ".globl NAME(g_LazyPtr_%s)\n" 1177 "NAME(g_LazyPtr_%s):\n" 1192 1178 " .quad 0\n" 1193 1179 "\n", 1194 p szNmPfx, pExp->szName, pszNmPfx, pExp->szName);1180 pExp->szName, pExp->szName); 1195 1181 fprintf(pOutput, 1196 1182 " .quad 0 /* Terminator entry for traversal. */\n" … … 1245 1231 " adrp x9, PAGE(g_sz%s)\n" 1246 1232 " add x9, x9, PAGEOFF(g_sz%s)\n" 1247 " adrp x10, PAGE( %s%s%s)\n"1248 " add x10, x10, PAGEOFF( %s%s%s)\n"1233 " adrp x10, PAGE(NAME(%s%s))\n" 1234 " add x10, x10, PAGEOFF(NAME(%s%s))\n" 1249 1235 " mov x16, x30\n" 1250 1236 " bl LazyLoadResolver\n" … … 1252 1238 , pExp->pszExportedNm, 1253 1239 pExp->pszExportedNm, pExp->pszExportedNm, 1254 pszNmPfx,!pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm,1255 pszNmPfx,!pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm);1240 !pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm, 1241 !pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm); 1256 1242 else 1257 1243 fprintf(pOutput, 1258 1244 "___LazyLoad___%s:\n" 1259 1245 " movk w9, #%u\n" 1260 " adrp x10, PAGE( %s%s%s)\n"1261 " add x10, x10, PAGEOFF( %s%s%s)\n"1246 " adrp x10, PAGE(NAME(%s%s))\n" 1247 " add x10, x10, PAGEOFF(NAME(%s%s))\n" 1262 1248 , pExp->pszExportedNm, 1263 1249 pExp->uOrdinal, 1264 pszNmPfx,!pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm,1265 pszNmPfx,!pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm);1250 !pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm, 1251 !pExp->fData ? "g_pfn" : "g_LazyPtr_", pExp->pszExportedNm); 1266 1252 if (!pExp->fData) 1267 fprintf(pOutput, " b %s%s\n", pszNmPfx, pExp->szName);1253 fprintf(pOutput, " b NAME(%s)\n", pExp->szName); 1268 1254 else 1269 fprintf(pOutput, " b %sLazyGetPtr_%s\n", pszNmPfx, pExp->szName);1255 fprintf(pOutput, " b NAME(LazyGetPtr_%s)\n", pExp->szName); 1270 1256 fprintf(pOutput, "\n"); 1271 1257 } … … 1350 1336 " mov x1, x19\n" 1351 1337 " mov x2, x20\n" 1352 " bl %sRTLdrGetSymbol\n"1338 " bl NAME(RTLdrGetSymbol)\n" 1353 1339 "\n" 1354 1340 " cmp w0, #0\n" … … 1364 1350 " stp x1, x2, [sp]\n" 1365 1351 " str x3, [sp, #16]\n" 1366 " bl %sRTAssertMsg2Weak\n"1352 " bl NAME(RTAssertMsg2Weak)\n" 1367 1353 "Lbadsymloop:\n" 1368 1354 " brk #0x1\n" … … 1405 1391 " .cfi_endproc\n" 1406 1392 "\n" 1407 "\n" 1408 , pszNmPfx, pszNmPfx); 1393 "\n"); 1409 1394 1410 1395 fprintf(pOutput, … … 1433 1418 " adrp x0, PAGE(g_szLibrary)\n" 1434 1419 " add x0, x0, PAGEOFF(g_szLibrary)\n" 1435 " bl %sSUPR3HardenedLdrLoadAppPriv\n" 1436 , pszNmPfx); 1420 " bl NAME(SUPR3HardenedLdrLoadAppPriv)\n"); 1437 1421 else 1438 1422 fprintf(pOutput, … … 1443 1427 " adrp x0, PAGE(g_szLibrary)\n" 1444 1428 " add x0, x0, PAGEOFF(g_szLibrary)\n" 1445 " bl %sRTLdrLoadSystem\n" 1446 , pszNmPfx); 1429 " bl NAME(RTLdrLoadSystem)\n"); 1447 1430 1448 1431 fprintf(pOutput, … … 1457 1440 " add x0, x0, PAGEOFF(g_szFailResolveFmt)\n" 1458 1441 " stp x1, x2, [sp]\n" 1459 " bl %sRTAssertMsg2Weak\n"1442 " bl NAME(RTAssertMsg2Weak)\n" 1460 1443 "Lbadloadloop:\n" 1461 1444 " brk #0x1\n" … … 1472 1455 "ENDCODE\n" 1473 1456 "\n" 1474 "\n" 1475 , pszNmPfx); 1457 "\n"); 1476 1458 1477 1459 /* … … 1488 1470 "BEGINCODE\n" 1489 1471 ".p2align 3\n" 1490 ".globl %sExplicitlyLoad%.*s\n"1491 " %sExplicitlyLoad%.*s:\n"1472 ".globl NAME(ExplicitlyLoad%.*s)\n" 1473 "NAME(ExplicitlyLoad%.*s):\n" 1492 1474 " .cfi_startproc\n" 1493 1475 " /* Create frame. */\n" … … 1520 1502 , 1521 1503 cchLibBaseName, g_pszLibrary, 1522 pszNmPfx,cchLibBaseName, g_pszLibrary,1523 pszNmPfx,cchLibBaseName, g_pszLibrary);1504 cchLibBaseName, g_pszLibrary, 1505 cchLibBaseName, g_pszLibrary); 1524 1506 fprintf(pOutput, 1525 1507 "Lexplicit_load_module:\n"); … … 1533 1515 " adrp x0, PAGE(g_szLibrary)\n" 1534 1516 " add x0, x0, PAGEOFF(g_szLibrary)\n" 1535 " bl %sSUPR3HardenedLdrLoadAppPriv\n" 1536 , pszNmPfx); 1517 " bl NAME(SUPR3HardenedLdrLoadAppPriv)\n"); 1537 1518 else 1538 1519 fprintf(pOutput, … … 1543 1524 " adrp x0, PAGE(g_szLibrary)\n" 1544 1525 " add x0, x0, PAGEOFF(g_szLibrary)\n" 1545 " bl %sRTLdrLoadSystem\n" 1546 , pszNmPfx); 1526 " bl NAME(RTLdrLoadSystem)\n"); 1547 1527 fprintf(pOutput, 1548 1528 " cmp x0, #0\n" … … 1572 1552 " mov x1, x22\n" 1573 1553 " mov x2, x23\n" 1574 " bl %sRTLdrGetSymbol\n"1554 " bl NAME(RTLdrGetSymbol)\n" 1575 1555 " cmp x0, #0\n" 1576 1556 " b.ne Lexplicit_load_symbol_error\n" … … 1592 1572 " mov x1, x0\n" 1593 1573 " mov x0, x21\n" 1594 " bl %sRTErrInfoSet\n"1574 " bl NAME(RTErrInfoSet)\n" 1595 1575 " b Lexplicit_load_return" 1596 1576 " " … … 1612 1592 "ENDCODE\n" 1613 1593 "\n" 1614 "\n" 1615 , pszNmPfx, pszNmPfx); 1594 "\n"); 1616 1595 } 1617 1596
Note:
See TracChangeset
for help on using the changeset viewer.