diff options
Diffstat (limited to 'llvm/tools/llvm-readobj/ELFDumper.cpp')
-rw-r--r-- | llvm/tools/llvm-readobj/ELFDumper.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index dbeb03df9f4..a200c10296b 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -129,6 +129,8 @@ public: void printMipsReginfo() override; void printMipsOptions() override; + void printAMDGPURuntimeMD() override; + void printStackMap() const override; void printHashHistogram() override; @@ -2339,6 +2341,36 @@ template <class ELFT> void ELFDumper<ELFT>::printMipsOptions() { } } +template <class ELFT> void ELFDumper<ELFT>::printAMDGPURuntimeMD() { + const Elf_Shdr *Shdr = findSectionByName(*Obj, ".note"); + if (!Shdr) { + W.startLine() << "There is no .note section in the file.\n"; + return; + } + ArrayRef<uint8_t> Sec = unwrapOrError(Obj->getSectionContents(Shdr)); + + const uint32_t RuntimeMDNoteType = 7; + for (auto I = reinterpret_cast<const uint32_t *>(&Sec[0]), + E = I + Sec.size()/4; I != E;) { + uint32_t NameSZ = I[0]; + uint32_t DescSZ = I[1]; + uint32_t Type = I[2]; + I += 3; + + StringRef Name; + if (NameSZ) { + Name = StringRef(reinterpret_cast<const char *>(I), NameSZ - 1); + I += alignTo<4>(NameSZ)/4; + } + + if (Name == "AMD" && Type == RuntimeMDNoteType) { + StringRef Desc(reinterpret_cast<const char *>(I), DescSZ); + W.printString(Desc); + } + I += alignTo<4>(DescSZ)/4; + } +} + template <class ELFT> void ELFDumper<ELFT>::printStackMap() const { const Elf_Shdr *StackMapSection = nullptr; for (const auto &Sec : unwrapOrError(Obj->sections())) { |