[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

llvm-svn: 360439
This commit is contained in:
Fangrui Song 2019-05-10 16:24:57 +00:00
parent 61c0daa007
commit 6150407951
5 changed files with 66 additions and 12 deletions

View File

@ -11,7 +11,7 @@
# CHECK-NOT: yy
# CHECK: SYMBOL TABLE:
# CHECK: xx 00000000 __start_xx
# CHECK: xx 00000000 .protected __start_xx
# CHECK: w *UND* 00000000 __start_yy
.weak __start_xx

View File

@ -53,9 +53,9 @@
# EL: Contents of section .debug_info
# EL-NEXT: 0000 11000200
# SYM: 00038000 .got 00000000 .hidden _gp
# SYM: 00020000 g F .text 00000000 foo
# SYM: 00020010 .text 00000000 __start
# SYM: 00038000 .got 00000000 .hidden _gp
# SYM: 00020000 g F .text 00000000 0x80 foo
# SYM: 00020010 .text 00000000 0x80 __start
# ELF: ElfHeader {
# ELF: Entry: 0x20011

View File

@ -26,8 +26,8 @@
# EL-NEXT: 20014: 7f 80 f6 ff beqzc $3, -36
# EL-NEXT: 20018: ff b7 f4 ff balc -24 <foo>
# SYM: 00020000 g F .text 00000000 foo
# SYM: 00020010 .text 00000000 __start
# SYM: 00020000 g F .text 00000000 0x80 foo
# SYM: 00020010 .text 00000000 0x80 __start
.text
.set micromips

View File

@ -0,0 +1,36 @@
# 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:
- 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

View File

@ -1686,20 +1686,38 @@ void printSymbolTable(const ObjectFile *O, StringRef ArchiveName,
outs() << SectionName;
}
outs() << '\t';
if (Common || isa<ELFObjectFileBase>(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<ELFObjectFileBase>(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';
}
}