feat(linker): allow use of local symbols

This commit adds support for handling local symbols.
* Added 2 fields to SymbolInfo - binding, and associated
instructions segment id.
* Simplified code for decoding elf symbols and relocations.
* Simplified code for patching instruction segments.
* Changed logic of decodeElfSymbolTableAndRelocations:
* Add every global symbol to symbol map.
* Add any local symbol used by relocation to symbol map.
* Changed logic of link:
* After performing relocations remove local symbols from map.
* Replaced UNRECOVERABLE_IF with returning error.
* Removed LocalSymbolInfo structure used before for local kernel jumps.
* Removed old tests.

Signed-off-by: Krystian Chmielewski <krystian.chmielewski@intel.com>
This commit is contained in:
Krystian Chmielewski
2023-02-20 10:04:40 +00:00
committed by Compute-Runtime-Automation
parent c8b90613a8
commit 5caf7f7290
10 changed files with 560 additions and 989 deletions

View File

@@ -595,9 +595,9 @@ TEST(ProgramLinkBinaryTest, whenLinkerUnresolvedExternalThenLinkFailedAndBuildLo
TEST_F(ProgramDataTest, whenLinkerInputValidThenIsaIsProperlyPatched) {
auto linkerInput = std::make_unique<WhiteBox<LinkerInput>>();
linkerInput->symbols["A"] = NEO::SymbolInfo{4U, 4U, NEO::SegmentType::GlobalVariables};
linkerInput->symbols["B"] = NEO::SymbolInfo{8U, 4U, NEO::SegmentType::GlobalConstants};
linkerInput->symbols["C"] = NEO::SymbolInfo{16U, 4U, NEO::SegmentType::Instructions};
linkerInput->symbols["A"] = NEO::SymbolInfo{4U, 4U, NEO::SegmentType::GlobalVariables, std::numeric_limits<uint32_t>::max(), true};
linkerInput->symbols["B"] = NEO::SymbolInfo{8U, 4U, NEO::SegmentType::GlobalConstants, std::numeric_limits<uint32_t>::max(), true};
linkerInput->symbols["C"] = NEO::SymbolInfo{16U, 4U, NEO::SegmentType::Instructions, std::numeric_limits<uint32_t>::max(), true};
auto relocationType = NEO::LinkerInput::RelocationInfo::Type::Address;
linkerInput->textRelocations.push_back({NEO::LinkerInput::RelocationInfo{"A", 8U, relocationType},