mirror of
https://github.com/intel/compute-runtime.git
synced 2025-11-15 10:14:56 +08:00
Linker: do not process relocations for symbols with unknown segment type
In decodeElfSymbolTableAndRelocations, when symbol's section is of unknown type, then do not add it to linker's symbol table. Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
17c5374d42
commit
c046824c18
@@ -177,7 +177,9 @@ void LinkerInput::decodeElfSymbolTableAndRelocations(Elf::Elf<Elf::EI_CLASS_64>
|
||||
|
||||
auto symbolSectionName = elf.getSectionName(symbol.shndx);
|
||||
auto symbolSegment = getSegmentForSection(symbolSectionName);
|
||||
|
||||
if (NEO::SegmentType::Unknown == symbolSegment) {
|
||||
continue;
|
||||
}
|
||||
switch (type) {
|
||||
default:
|
||||
DEBUG_BREAK_IF(type != Elf::SYMBOL_TABLE_TYPE::STT_NOTYPE);
|
||||
|
||||
@@ -514,6 +514,34 @@ TEST(LinkerInputTests, GivenInvalidTextSectionNameWhenDecodingElfTextRelocations
|
||||
ASSERT_EQ(0u, relocations.size());
|
||||
}
|
||||
|
||||
TEST(LinkerInputTests, whenSymbolHasShndxReferringToSectionOfUnknownTypehenDoNotAddItToLinkerInput) {
|
||||
NEO::LinkerInput linkerInput = {};
|
||||
NEO::Elf::ElfFileHeader<NEO::Elf::EI_CLASS_64> header;
|
||||
MockElf<NEO::Elf::EI_CLASS_64> elf64;
|
||||
elf64.elfFileHeader = &header;
|
||||
|
||||
std::unordered_map<uint32_t, std::string> sectionNames;
|
||||
sectionNames[0] = ".invalid.aaa";
|
||||
elf64.setupSecionNames(std::move(sectionNames));
|
||||
elf64.overrideSymbolName = true;
|
||||
|
||||
NEO::Elf::ElfSymbolEntry<NEO::Elf::EI_CLASS_64> symbol;
|
||||
symbol.info = NEO::Elf::SYMBOL_TABLE_TYPE::STT_OBJECT | NEO::Elf::SYMBOL_TABLE_BIND::STB_GLOBAL << 4;
|
||||
symbol.name = 0x20;
|
||||
symbol.other = 0;
|
||||
symbol.shndx = 0;
|
||||
symbol.size = 0x8;
|
||||
symbol.value = 0x4000;
|
||||
|
||||
elf64.symbolTable.emplace_back(symbol);
|
||||
|
||||
NEO::LinkerInput::SectionNameToSegmentIdMap nameToKernelId;
|
||||
linkerInput.decodeElfSymbolTableAndRelocations(elf64, nameToKernelId);
|
||||
|
||||
auto symbols = linkerInput.getSymbols();
|
||||
ASSERT_EQ(0u, symbols.size());
|
||||
}
|
||||
|
||||
TEST(LinkerInputTests, GivenValidZebinRelocationTypesWhenDecodingElfTextRelocationsThenCorrectTypeIsSet) {
|
||||
NEO::LinkerInput linkerInput = {};
|
||||
NEO::Elf::ElfFileHeader<NEO::Elf::EI_CLASS_64> header;
|
||||
|
||||
Reference in New Issue
Block a user