@@ -20,7 +20,7 @@ TEST(DebugZebinTest, givenValidZebinThenDebugZebinIsGenerated) {
20
20
uint8_t kernelISA[8 ] = {0x3 };
21
21
uint8_t stringData[8 ] = {0x4 };
22
22
23
- uint8_t debugInfo[0x28 ] = {0x0 };
23
+ uint8_t debugInfo[0x30 ] = {0x22 };
24
24
uint8_t debugAbbrev[8 ] = {0x0 };
25
25
26
26
using Segment = NEO::Debug::Segments::Segment;
@@ -43,7 +43,7 @@ TEST(DebugZebinTest, givenValidZebinThenDebugZebinIsGenerated) {
43
43
typedef NEO::Elf::ElfSymbolEntry<NEO::Elf::ELF_IDENTIFIER_CLASS::EI_CLASS_64> SymbolEntry;
44
44
typedef NEO::Elf::ElfRela<NEO::Elf::ELF_IDENTIFIER_CLASS::EI_CLASS_64> Relocation;
45
45
46
- SymbolEntry symbols[6 ]{};
46
+ SymbolEntry symbols[7 ]{};
47
47
symbols[0 ].name = elfEncoder.appendSectionName (" kernel" );
48
48
symbols[0 ].info = NEO::Elf::SYMBOL_TABLE_TYPE::STT_SECTION | NEO::Elf::SYMBOL_TABLE_BIND::STB_LOCAL << 4 ;
49
49
symbols[0 ].shndx = static_cast <decltype (SymbolEntry::shndx)>(kernelSectionIndex);
@@ -74,7 +74,12 @@ TEST(DebugZebinTest, givenValidZebinThenDebugZebinIsGenerated) {
74
74
symbols[5 ].shndx = static_cast <decltype (SymbolEntry::shndx)>(debugInfoSectionIndex);
75
75
symbols[5 ].value = 0U ;
76
76
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 ]{};
78
83
debugRelocations[0 ].addend = 0xabc ;
79
84
debugRelocations[0 ].offset = 0x0 ;
80
85
debugRelocations[0 ].info = (uint64_t (0 ) << 32 ) | NEO::Elf::RELOC_TYPE_ZEBIN::R_ZE_SYM_ADDR;
@@ -100,6 +105,11 @@ TEST(DebugZebinTest, givenValidZebinThenDebugZebinIsGenerated) {
100
105
debugRelocations[5 ].offset = 0x20U ;
101
106
debugRelocations[5 ].info = (uint64_t (5 ) << 32 ) | NEO::Elf::RELOC_TYPE_ZEBIN::R_ZE_SYM_ADDR;
102
107
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
+
103
113
elfEncoder.appendSection (NEO::Elf::SHT_SYMTAB, NEO::Elf::SectionsNamesZebin::symtab, ArrayRef<const uint8_t >(reinterpret_cast <uint8_t *>(symbols), sizeof (symbols)));
104
114
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)));
105
115
relaHeader.info = debugInfoSectionIndex;
@@ -177,11 +187,15 @@ TEST(DebugZebinTest, givenValidZebinThenDebugZebinIsGenerated) {
177
187
*reinterpret_cast <const uint64_t *>(ptrDebugInfo + debugRelocations[3 ].offset ));
178
188
179
189
// 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 ));
181
192
182
193
// debug symbols with text segment name are offseted by corresponding segment's address
183
194
EXPECT_EQ (segments.nameToSegMap [" kernel" ].address ,
184
195
*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 ));
185
199
} else {
186
200
EXPECT_EQ (zebin.sectionHeaders [i].header ->size , sectionHeader->size );
187
201
if (sectionHeader->size > 0U ) {
0 commit comments