resolve relocs and imports of all modules. Or resolve exports
| 1680 | |
| 1681 | // resolve relocs and imports of all modules. Or resolve exports |
| 1682 | void RPLLoader_LinkSingleModule(RPLModule* rplLoaderContext, bool resolveOnlyExports) |
| 1683 | { |
| 1684 | // setup shared import tracking |
| 1685 | std::vector<RPLSharedImportTracking> sharedImportTracking; |
| 1686 | |
| 1687 | sharedImportTracking.resize(rplLoaderContext->rplHeader.sectionTableEntryCount - 2); |
| 1688 | |
| 1689 | memset(sharedImportTracking.data(), 0, sizeof(RPLSharedImportTracking) * sharedImportTracking.size()); |
| 1690 | |
| 1691 | for (uint32 i = 0; i < (uint32)rplLoaderContext->rplHeader.sectionTableEntryCount; i++) |
| 1692 | { |
| 1693 | if( rplLoaderContext->sectionTablePtr[i].type != (uint32be)SHT_RPL_IMPORTS ) |
| 1694 | continue; |
| 1695 | char* libName = (char*)((uint8*)rplLoaderContext->sectionAddressTable2[i].ptr + 8); |
| 1696 | // make module name |
| 1697 | char _importModuleName[RPL_MODULE_NAME_LENGTH]; |
| 1698 | _RPLLoader_ExtractModuleNameFromPath(_importModuleName, libName); |
| 1699 | // find in loaded module list |
| 1700 | std::string importModuleName{_importModuleName}; |
| 1701 | bool foundModule = false; |
| 1702 | for (sint32 f = 0; f < rplModuleCount; f++) |
| 1703 | { |
| 1704 | if (boost::iequals(rplModuleList[f]->moduleName2, importModuleName)) |
| 1705 | { |
| 1706 | sharedImportTracking[i].rplLoaderContext = rplModuleList[f]; |
| 1707 | memset(sharedImportTracking[i].modulename, 0, sizeof(sharedImportTracking[i].modulename)); |
| 1708 | strcpy_s(sharedImportTracking[i].modulename, importModuleName.c_str()); |
| 1709 | foundModule = true; |
| 1710 | break; |
| 1711 | } |
| 1712 | } |
| 1713 | if( foundModule ) |
| 1714 | continue; |
| 1715 | // if not found, we assume it's a HLE lib |
| 1716 | sharedImportTracking[i].rplLoaderContext = HLE_MODULE_PTR; |
| 1717 | sharedImportTracking[i].exportSection = nullptr; |
| 1718 | strcpy_s(sharedImportTracking[i].modulename, libName); |
| 1719 | } |
| 1720 | |
| 1721 | if (resolveOnlyExports) |
| 1722 | RPLLoader_HandleRelocs(rplLoaderContext, sharedImportTracking, 2); |
| 1723 | else |
| 1724 | RPLLoader_HandleRelocs(rplLoaderContext, sharedImportTracking, 0); |
| 1725 | |
| 1726 | RPLLoader_FlushMemory(rplLoaderContext); |
| 1727 | } |
| 1728 | |
| 1729 | void RPLLoader_LoadSectionDebugSymbols(RPLModule* rplLoaderContext, rplSectionEntryNew_t* section, int symtabSectionIndex) |
| 1730 | { |
no test coverage detected