diff --git a/level_zero/core/source/module/module_imp.cpp b/level_zero/core/source/module/module_imp.cpp index d3899fc1ad..f7f854e8b4 100644 --- a/level_zero/core/source/module/module_imp.cpp +++ b/level_zero/core/source/module/module_imp.cpp @@ -314,6 +314,7 @@ bool ModuleTranslationUnit::processUnpackedBinary() { id++; } programInfo.prepareLinkerInputStorage(); + programInfo.linkerInput->undefinedSymbolsAllowed = programInfo.levelZeroDynamicLinkProgram; programInfo.linkerInput->decodeElfSymbolTableAndRelocations(programInfo.decodedElf, nameToKernelId); } diff --git a/shared/source/compiler_interface/linker.cpp b/shared/source/compiler_interface/linker.cpp index 99259e9a36..236bfafa5b 100644 --- a/shared/source/compiler_interface/linker.cpp +++ b/shared/source/compiler_interface/linker.cpp @@ -214,7 +214,7 @@ void LinkerInput::decodeElfSymbolTableAndRelocations(Elf::Elf auto bind = elf.extractSymbolBind(symbol); if (bind == Elf::SYMBOL_TABLE_BIND::STB_GLOBAL) { - SymbolInfo &symbolInfo = symbols[elf.getSymbolName(symbol.name)]; + SymbolInfo symbolInfo; symbolInfo.offset = static_cast(symbol.value); symbolInfo.size = static_cast(symbol.size); auto type = elf.extractSymbolType(symbol); @@ -224,8 +224,9 @@ void LinkerInput::decodeElfSymbolTableAndRelocations(Elf::Elf switch (type) { default: - DEBUG_BREAK_IF(true); - break; + this->valid &= this->undefinedSymbolsAllowed; + DEBUG_BREAK_IF(false == this->undefinedSymbolsAllowed); + continue; case Elf::SYMBOL_TABLE_TYPE::STT_OBJECT: symbolInfo.segment = symbolSegment; traits.exportsGlobalVariables |= symbolSegment == SegmentType::GlobalVariables; @@ -243,6 +244,7 @@ void LinkerInput::decodeElfSymbolTableAndRelocations(Elf::Elf } } break; } + symbols.insert({elf.getSymbolName(symbol.name), symbolInfo}); } } } diff --git a/shared/test/unit_test/compiler_interface/linker_tests.cpp b/shared/test/unit_test/compiler_interface/linker_tests.cpp index 7f134770ab..cec4d4976d 100644 --- a/shared/test/unit_test/compiler_interface/linker_tests.cpp +++ b/shared/test/unit_test/compiler_interface/linker_tests.cpp @@ -892,7 +892,7 @@ TEST(LinkerInputTests, GivenGlobalFunctionsInTwoSegementsWhenDecodingThenUnrecov EXPECT_THROW(linkerInput.decodeElfSymbolTableAndRelocations(elf64, nameToKernelId), std::exception); auto symbols = linkerInput.getSymbols(); - ASSERT_EQ(2u, symbols.size()); + ASSERT_EQ(1u, symbols.size()); EXPECT_EQ(0, linkerInput.getExportedFunctionsSegmentId()); } @@ -928,7 +928,7 @@ TEST(LinkerInputTests, GivenNoKernelNameToIdWhenDecodingGlobalFunctionThenExport EXPECT_EQ(-1, linkerInput.getExportedFunctionsSegmentId()); } -TEST(LinkerInputTests, GivenGlobalElfSymbolOfNoTypeWhenDecodingThenSymbolWithUnknownSegmentIsAddedAndDebugBreakCalled) { +TEST(LinkerInputTests, GivenGlobalElfSymbolOfNoTypeWhenDecodingThenDebugBreakCalled) { NEO::LinkerInput linkerInput = {}; NEO::Elf::ElfFileHeader header; MockElf elf64; @@ -960,8 +960,7 @@ TEST(LinkerInputTests, GivenGlobalElfSymbolOfNoTypeWhenDecodingThenSymbolWithUnk linkerInput.decodeElfSymbolTableAndRelocations(elf64, nameToKernelId); auto symbols = linkerInput.getSymbols(); - ASSERT_EQ(1u, symbols.size()); - EXPECT_EQ(SegmentType::Unknown, symbols.begin()->second.segment); + ASSERT_EQ(0u, symbols.size()); EXPECT_FALSE(linkerInput.getTraits().exportsGlobalVariables); EXPECT_FALSE(linkerInput.getTraits().exportsGlobalConstants);