mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
Linker: add support for symbols with local binding
This commits add support for relocating symbols with local binding and of functional type (STB_LOCAL, STT_FUNC). Related-To: NEO-7299 Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
824c781ab5
commit
710c8cf5ef
@ -100,7 +100,8 @@ cl_int Program::linkBinary(Device *pDevice, const void *constantsInitData, const
|
||||
auto &kernHeapInfo = kernelInfo->heapInfo;
|
||||
const char *originalIsa = reinterpret_cast<const char *>(kernHeapInfo.pKernelHeap);
|
||||
patchedIsaTempStorage.push_back(std::vector<char>(originalIsa, originalIsa + kernHeapInfo.KernelHeapSize));
|
||||
isaSegmentsForPatching.push_back(Linker::PatchableSegment{patchedIsaTempStorage.rbegin()->data(), kernHeapInfo.KernelHeapSize});
|
||||
DEBUG_BREAK_IF(nullptr == kernelInfo->getGraphicsAllocation());
|
||||
isaSegmentsForPatching.push_back(Linker::PatchableSegment{patchedIsaTempStorage.rbegin()->data(), static_cast<uintptr_t>(kernelInfo->getGraphicsAllocation()->getGpuAddressToPatch()), kernHeapInfo.KernelHeapSize, kernelInfo->kernelDescriptor.kernelMetadata.kernelName});
|
||||
kernelDescriptors.push_back(&kernelInfo->kernelDescriptor);
|
||||
}
|
||||
}
|
||||
@ -123,9 +124,6 @@ cl_int Program::linkBinary(Device *pDevice, const void *constantsInitData, const
|
||||
} else if (linkerInput->getTraits().requiresPatchingOfInstructionSegments) {
|
||||
for (auto kernelId = 0u; kernelId < kernelInfoArray.size(); kernelId++) {
|
||||
const auto &kernelInfo = kernelInfoArray[kernelId];
|
||||
if (nullptr == kernelInfo->getGraphicsAllocation()) {
|
||||
continue;
|
||||
}
|
||||
auto &kernHeapInfo = kernelInfo->heapInfo;
|
||||
auto segmentId = &kernelInfo - &kernelInfoArray[0];
|
||||
auto &hwInfo = pDevice->getHardwareInfo();
|
||||
|
@ -1319,6 +1319,9 @@ TEST_F(KernelDataTest, givenRelocationTablePatchTokenThenLinkerInputIsCreated) {
|
||||
token.Token = PATCH_TOKEN_PROGRAM_RELOCATION_TABLE;
|
||||
token.Size = static_cast<uint32_t>(sizeof(SPatchFunctionTableInfo));
|
||||
token.NumEntries = 0;
|
||||
kernelHeapSize = 0x100; //force creating kernel allocation for ISA
|
||||
auto kernelHeapData = std::make_unique<char[]>(kernelHeapSize);
|
||||
pKernelHeap = kernelHeapData.get();
|
||||
|
||||
pPatchList = &token;
|
||||
patchListSize = token.Size;
|
||||
|
@ -586,6 +586,7 @@ TEST(ProgramLinkBinaryTest, whenLinkerUnresolvedExternalThenLinkFailedAndBuildLo
|
||||
kernelHeap.resize(32, 7);
|
||||
kernelInfo.heapInfo.pKernelHeap = kernelHeap.data();
|
||||
kernelInfo.heapInfo.KernelHeapSize = static_cast<uint32_t>(kernelHeap.size());
|
||||
kernelInfo.createKernelAllocation(device->getDevice(), false);
|
||||
program.getKernelInfoArray(rootDeviceIndex).push_back(&kernelInfo);
|
||||
program.setLinkerInput(rootDeviceIndex, std::move(linkerInput));
|
||||
|
||||
@ -600,6 +601,7 @@ TEST(ProgramLinkBinaryTest, whenLinkerUnresolvedExternalThenLinkFailedAndBuildLo
|
||||
expectedUnresolvedExternals.push_back(Linker::UnresolvedExternal{relocation, 0, false});
|
||||
auto expectedError = constructLinkerErrorMessage(expectedUnresolvedExternals, std::vector<std::string>{"kernel : " + kernelInfo.kernelDescriptor.kernelMetadata.kernelName});
|
||||
EXPECT_TRUE(hasSubstr(buildLog, expectedError));
|
||||
device->getMemoryManager()->freeGraphicsMemory(kernelInfo.getGraphicsAllocation());
|
||||
}
|
||||
|
||||
TEST_F(ProgramDataTest, whenLinkerInputValidThenIsaIsProperlyPatched) {
|
||||
|
Reference in New Issue
Block a user