diff options
Diffstat (limited to 'llvm/tools/llvm-readobj/ELFDumper.cpp')
-rw-r--r-- | llvm/tools/llvm-readobj/ELFDumper.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index 1bd7737bc31..5a4699c3683 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -3489,6 +3489,24 @@ void GNUStyle<ELFT>::printAddrsig(const ELFFile<ELFT> *Obj) { OS << "GNUStyle::printAddrsig not implemented\n"; } +static StringRef getGenericNoteTypeName(const uint32_t NT) { + static const struct { + uint32_t ID; + const char *Name; + } Notes[] = { + {ELF::NT_VERSION, "NT_VERSION (version)"}, + {ELF::NT_ARCH, "NT_ARCH (architecture)"}, + {ELF::NT_GNU_BUILD_ATTRIBUTE_OPEN, "OPEN"}, + {ELF::NT_GNU_BUILD_ATTRIBUTE_FUNC, "func"}, + }; + + for (const auto &Note : Notes) + if (Note.ID == NT) + return Note.Name; + + return ""; +} + static std::string getGNUNoteTypeName(const uint32_t NT) { static const struct { uint32_t ID; @@ -3877,7 +3895,11 @@ void GNUStyle<ELFT>::printNotes(const ELFFile<ELFT> *Obj) { if (!N.Type.empty()) OS << " " << N.Type << ":\n " << N.Value << '\n'; } else { - OS << "Unknown note type: (" << format_hex(Type, 10) << ')'; + StringRef NoteType = getGenericNoteTypeName(Type); + if (!NoteType.empty()) + OS << NoteType; + else + OS << "Unknown note type: (" << format_hex(Type, 10) << ')'; } OS << '\n'; }; @@ -4682,8 +4704,12 @@ void LLVMStyle<ELFT>::printNotes(const ELFFile<ELFT> *Obj) { if (!N.Type.empty()) W.printString(N.Type, N.Value); } else { - W.printString("Type", - "Unknown (" + to_string(format_hex(Type, 10)) + ")"); + StringRef NoteType = getGenericNoteTypeName(Type); + if (!NoteType.empty()) + W.printString("Type", NoteType); + else + W.printString("Type", + "Unknown (" + to_string(format_hex(Type, 10)) + ")"); } }; |