diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-03-29 16:48:19 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-03-29 16:48:19 +0000 |
commit | 871baa2551649b806c98b06c3aa3503360495ce3 (patch) | |
tree | 8c3c8661af3d08ed6061e80921046553cef8481f /llvm/tools/llvm-readobj | |
parent | 342aaa14b1048c2e8e622ca1c148fa493959f7c1 (diff) | |
download | bcm5719-llvm-871baa2551649b806c98b06c3aa3503360495ce3.tar.gz bcm5719-llvm-871baa2551649b806c98b06c3aa3503360495ce3.zip |
[llvm-readobj] Add some generic notes (e.g. NT_VERSION)
Summary: Support reading notes that don't have a standard note name.
Reviewers: MaskRay
Reviewed By: MaskRay
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59969
llvm-svn: 357271
Diffstat (limited to 'llvm/tools/llvm-readobj')
-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)) + ")"); } }; |