From 9fab0fa99800f6efa170d2ac4307120bdcc4f646 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 6 Jun 2019 02:22:34 +0000 Subject: [PATCH] Merging r360439: ------------------------------------------------------------------------ r360439 | maskray | 2019-05-10 09:24:57 -0700 (Fri, 10 May 2019) | 8 lines [llvm-objdump] Print st_other Add support for ".hidden" ".internal" ".protected" and " 0x%02x" for other st_other bits used by some architectures. Reviewed By: sfertile Differential Revision: https://reviews.llvm.org/D61718 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_80@362668 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../llvm-objdump/elf-symbol-visibility.test | 37 +++++++++++++++++++ tools/llvm-objdump/llvm-objdump.cpp | 30 ++++++++++++--- 2 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 test/tools/llvm-objdump/elf-symbol-visibility.test diff --git a/test/tools/llvm-objdump/elf-symbol-visibility.test b/test/tools/llvm-objdump/elf-symbol-visibility.test new file mode 100644 index 00000000000..da7f6d28516 --- /dev/null +++ b/test/tools/llvm-objdump/elf-symbol-visibility.test @@ -0,0 +1,37 @@ +# RUN: yaml2obj %s -o %t +# RUN: llvm-objdump --syms %t | FileCheck %s + +# CHECK: SYMBOL TABLE: +# CHECK-NEXT: .text 00000000 default +# CHECK-NEXT: .text 00000000 .internal internal +# CHECK-NEXT: .text 00000000 .hidden hidden +# CHECK-NEXT: .text 00000000 .protected protected +# CHECK-NEXT: .text 00000000 0x20 mips_pic + +!ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_MIPS + Flags: [ EF_MIPS_ABI_O32, EF_MIPS_ARCH_32 ] +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] +Symbols: + Local: + - Name: default + Section: .text + - Name: internal + Visibility: STV_INTERNAL + Section: .text + - Name: hidden + Visibility: STV_HIDDEN + Section: .text + - Name: protected + Visibility: STV_PROTECTED + Section: .text + - Name: mips_pic + Other: [ STO_MIPS_PIC ] + Section: .text diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp index ba8d3c5b8d5..9bd4528ef7f 100644 --- a/tools/llvm-objdump/llvm-objdump.cpp +++ b/tools/llvm-objdump/llvm-objdump.cpp @@ -2087,20 +2087,38 @@ void llvm::printSymbolTable(const ObjectFile *O, StringRef ArchiveName, outs() << SectionName; } - outs() << '\t'; if (Common || isa(O)) { uint64_t Val = Common ? Symbol.getAlignment() : ELFSymbolRef(Symbol).getSize(); - outs() << format("\t %08" PRIx64 " ", Val); + outs() << format("\t%08" PRIx64, Val); } - if (Hidden) - outs() << ".hidden "; + if (isa(O)) { + uint8_t Other = ELFSymbolRef(Symbol).getOther(); + switch (Other) { + case ELF::STV_DEFAULT: + break; + case ELF::STV_INTERNAL: + outs() << " .internal"; + break; + case ELF::STV_HIDDEN: + outs() << " .hidden"; + break; + case ELF::STV_PROTECTED: + outs() << " .protected"; + break; + default: + outs() << format(" 0x%02x", Other); + break; + } + } else if (Hidden) { + outs() << " .hidden"; + } if (Demangle) - outs() << demangle(Name) << '\n'; + outs() << ' ' << demangle(Name) << '\n'; else - outs() << Name << '\n'; + outs() << ' ' << Name << '\n'; } } -- 2.40.0