diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index 264d5730525..7893eea5d22 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -3370,7 +3370,8 @@ static std::string getFreeBSDNoteTypeName(const uint32_t NT) { template static void printGNUNote(raw_ostream &OS, uint32_t NoteType, - ArrayRef::Elf_Word> Words) { + ArrayRef::Elf_Word> Words, + size_t Size) { switch (NoteType) { default: return; @@ -3393,16 +3394,14 @@ static void printGNUNote(raw_ostream &OS, uint32_t NoteType, } case ELF::NT_GNU_BUILD_ID: { OS << " Build ID: "; - ArrayRef ID(reinterpret_cast(Words.data()), - Words.size() * 4); + ArrayRef ID(reinterpret_cast(Words.data()), Size); for (const auto &B : ID) OS << format_hex_no_prefix(B, 2); break; } case ELF::NT_GNU_GOLD_VERSION: OS << " Version: " - << StringRef(reinterpret_cast(Words.data()), - Words.size() * 4); + << StringRef(reinterpret_cast(Words.data()), Size); break; } @@ -3446,7 +3445,7 @@ void GNUStyle::printNotes(const ELFFile *Obj) { if (Name == "GNU") { OS << getGNUNoteTypeName(Type) << '\n'; - printGNUNote(OS, Type, Descriptor); + printGNUNote(OS, Type, Descriptor, DescriptorSize); } else if (Name == "FreeBSD") { OS << getFreeBSDNoteTypeName(Type) << '\n'; } else {