Changeset 3665 in CLRX for CLRadeonExtender/trunk/amdbin/ROCmBinaries.cpp
- Timestamp:
- Jan 26, 2018, 11:09:35 PM (23 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CLRadeonExtender/trunk/amdbin/ROCmBinaries.cpp
r3662 r3665 36 36 ROCmBinary::ROCmBinary(size_t binaryCodeSize, cxbyte* binaryCode, Flags creationFlags) 37 37 : ElfBinary64(binaryCodeSize, binaryCode, creationFlags), 38 regionsNum(0), codeSize(0), code(nullptr) 38 regionsNum(0), codeSize(0), code(nullptr), metadataSize(0), metadata(nullptr) 39 39 { 40 40 cxuint textIndex = SHN_UNDEF; … … 122 122 } 123 123 124 // get metadata 125 const size_t notesSize = getNotesSize(); 126 const cxbyte* noteContent = (const cxbyte*)getNotes(); 127 128 for (size_t offset = 0; offset < notesSize; ) 129 { 130 const Elf64_Nhdr* nhdr = (const Elf64_Nhdr*)(noteContent + offset); 131 size_t namesz = ULEV(nhdr->n_namesz); 132 size_t descsz = ULEV(nhdr->n_descsz); 133 if (usumGt(offset, namesz+descsz, notesSize)) 134 throw BinException("Note offset+size out of range"); 135 136 if (namesz==4 && 137 ::strcmp((const char*)noteContent+offset+ sizeof(Elf64_Nhdr), "AMD")==0) 138 { 139 const uint32_t noteType = ULEV(nhdr->n_type); 140 if (noteType == 0xa) 141 { 142 metadata = (char*)(noteContent+offset+sizeof(Elf64_Nhdr) + 4); 143 metadataSize = descsz; 144 } 145 else if (noteType == 0xb) 146 target.assign((char*)(noteContent+offset+sizeof(Elf64_Nhdr) + 4), descsz); 147 } 148 size_t align = (((namesz+descsz)&3)!=0) ? 4-((namesz+descsz)&3) : 0; 149 offset += sizeof(Elf64_Nhdr) + namesz + descsz + align; 150 } 151 124 152 if (hasRegionMap()) 125 153 { … … 217 245 const std::vector<ROCmSymbolInput>& symbols) 218 246 { 219 input = new ROCmInput{ deviceType, archMinor, archStepping, symbols, codeSize, code }; 247 input = new ROCmInput{ deviceType, archMinor, archStepping, 0, false, 248 symbols, codeSize, code }; 220 249 } 221 250 … … 224 253 std::vector<ROCmSymbolInput>&& symbols) 225 254 { 226 input = new ROCmInput{ deviceType, archMinor, archStepping, std::move(symbols),227 255 input = new ROCmInput{ deviceType, archMinor, archStepping, 0, false, 256 std::move(symbols), codeSize, code }; 228 257 } 229 258 … … 351 380 SULEV(*(uint32_t*)(noteBuf.get()+12), amdGpuArchValues.stepping); 352 381 elfBinGen64.addNote({"AMD", 0x1b, noteBuf.get(), 3U}); 382 if (!input->target.empty()) 383 elfBinGen64.addNote({"AMD", input->target.size(), 384 (const cxbyte*)input->target.c_str(), 0xbU}); 385 if (input->metadataSize != 0) 386 elfBinGen64.addNote({"AMD", input->metadataSize, 387 (const cxbyte*)input->metadata, 0xaU}); 353 388 354 389 /// region and sections
Note: See TracChangeset
for help on using the changeset viewer.