@@ -20,7 +20,7 @@ TEST(DebugZebinTest, givenValidZebinThenDebugZebinIsGenerated) {
2020 uint8_t kernelISA[8 ] = {0x3 };
2121 uint8_t stringData[8 ] = {0x4 };
2222
23- uint8_t debugInfo[0x28 ] = {0x0 };
23+ uint8_t debugInfo[0x30 ] = {0x22 };
2424 uint8_t debugAbbrev[8 ] = {0x0 };
2525
2626 using Segment = NEO::Debug::Segments::Segment;
@@ -43,7 +43,7 @@ TEST(DebugZebinTest, givenValidZebinThenDebugZebinIsGenerated) {
4343 typedef NEO::Elf::ElfSymbolEntry<NEO::Elf::ELF_IDENTIFIER_CLASS::EI_CLASS_64> SymbolEntry;
4444 typedef NEO::Elf::ElfRela<NEO::Elf::ELF_IDENTIFIER_CLASS::EI_CLASS_64> Relocation;
4545
46- SymbolEntry symbols[6 ]{};
46+ SymbolEntry symbols[7 ]{};
4747 symbols[0 ].name = elfEncoder.appendSectionName (" kernel" );
4848 symbols[0 ].info = NEO::Elf::SYMBOL_TABLE_TYPE::STT_SECTION | NEO::Elf::SYMBOL_TABLE_BIND::STB_LOCAL << 4 ;
4949 symbols[0 ].shndx = static_cast <decltype (SymbolEntry::shndx)>(kernelSectionIndex);
@@ -74,7 +74,12 @@ TEST(DebugZebinTest, givenValidZebinThenDebugZebinIsGenerated) {
7474 symbols[5 ].shndx = static_cast <decltype (SymbolEntry::shndx)>(debugInfoSectionIndex);
7575 symbols[5 ].value = 0U ;
7676
77- Relocation debugRelocations[6 ]{};
77+ symbols[6 ].name = elfEncoder.appendSectionName (" kernel_payload_offset" );
78+ symbols[6 ].info = NEO::Elf::SYMBOL_TABLE_TYPE::STT_SECTION | NEO::Elf::SYMBOL_TABLE_BIND::STB_LOCAL << 4 ;
79+ symbols[6 ].shndx = static_cast <decltype (SymbolEntry::shndx)>(kernelSectionIndex);
80+ symbols[6 ].value = 0x10U ;
81+
82+ Relocation debugRelocations[7 ]{};
7883 debugRelocations[0 ].addend = 0xabc ;
7984 debugRelocations[0 ].offset = 0x0 ;
8085 debugRelocations[0 ].info = (uint64_t (0 ) << 32 ) | NEO::Elf::RELOC_TYPE_ZEBIN::R_ZE_SYM_ADDR;
@@ -100,6 +105,11 @@ TEST(DebugZebinTest, givenValidZebinThenDebugZebinIsGenerated) {
100105 debugRelocations[5 ].offset = 0x20U ;
101106 debugRelocations[5 ].info = (uint64_t (5 ) << 32 ) | NEO::Elf::RELOC_TYPE_ZEBIN::R_ZE_SYM_ADDR;
102107
108+ // Will be ignored due to reloc type
109+ debugRelocations[6 ].addend = 0x0 ;
110+ debugRelocations[6 ].offset = 0x28 ;
111+ debugRelocations[6 ].info = (uint64_t (6 ) << 32 ) | NEO::Elf::RELOC_TYPE_ZEBIN::R_PER_THREAD_PAYLOAD_OFFSET;
112+
103113 elfEncoder.appendSection (NEO::Elf::SHT_SYMTAB, NEO::Elf::SectionsNamesZebin::symtab, ArrayRef<const uint8_t >(reinterpret_cast <uint8_t *>(symbols), sizeof (symbols)));
104114 auto &relaHeader = elfEncoder.appendSection (NEO::Elf::SHT_RELA, NEO::Elf::SpecialSectionNames::relaPrefix.str () + NEO::Elf::SectionsNamesZebin::debugInfo.str (), ArrayRef<const uint8_t >(reinterpret_cast <uint8_t *>(debugRelocations), sizeof (debugRelocations)));
105115 relaHeader.info = debugInfoSectionIndex;
@@ -177,11 +187,15 @@ TEST(DebugZebinTest, givenValidZebinThenDebugZebinIsGenerated) {
177187 *reinterpret_cast <const uint64_t *>(ptrDebugInfo + debugRelocations[3 ].offset ));
178188
179189 // if symbols points to other sections relocation is skipped - not text, data, debug
180- EXPECT_EQ (0U , *reinterpret_cast <const uint64_t *>(ptrDebugInfo + debugRelocations[4 ].offset ));
190+ EXPECT_EQ (*reinterpret_cast <uint64_t *>(debugInfo + debugRelocations[4 ].offset ),
191+ *reinterpret_cast <const uint64_t *>(ptrDebugInfo + debugRelocations[4 ].offset ));
181192
182193 // debug symbols with text segment name are offseted by corresponding segment's address
183194 EXPECT_EQ (segments.nameToSegMap [" kernel" ].address ,
184195 *reinterpret_cast <const uint64_t *>(ptrDebugInfo + debugRelocations[5 ].offset ));
196+
197+ EXPECT_EQ (*reinterpret_cast <uint64_t *>(debugInfo + debugRelocations[6 ].offset ),
198+ *reinterpret_cast <const uint64_t *>(ptrDebugInfo + debugRelocations[6 ].offset ));
185199 } else {
186200 EXPECT_EQ (zebin.sectionHeaders [i].header ->size , sectionHeader->size );
187201 if (sectionHeader->size > 0U ) {
0 commit comments