summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <tstellar@redhat.com>2019-06-06 02:22:34 +0000
committerTom Stellard <tstellar@redhat.com>2019-06-06 02:22:34 +0000
commitc493057bdeede0e41902a2e8de6b5c8541a4237b (patch)
tree2151d029437ddd884cfb02080c401bf30f4b6293
parentMerging r360293: (diff)
downloadllvm-project-c493057bdeede0e41902a2e8de6b5c8541a4237b.tar.gz
llvm-project-c493057bdeede0e41902a2e8de6b5c8541a4237b.tar.bz2
llvm-project-c493057bdeede0e41902a2e8de6b5c8541a4237b.zip
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 ------------------------------------------------------------------------ llvm-svn: 362668
-rw-r--r--lld/test/ELF/gc-sections-metadata-startstop.s2
-rw-r--r--lld/test/ELF/mips-micro-relocs.s6
-rw-r--r--lld/test/ELF/mips-micror6-relocs.s4
-rw-r--r--llvm/test/tools/llvm-objdump/elf-symbol-visibility.test37
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp30
5 files changed, 67 insertions, 12 deletions
diff --git a/lld/test/ELF/gc-sections-metadata-startstop.s b/lld/test/ELF/gc-sections-metadata-startstop.s
index ede1899698c4..0a1efb7e6075 100644
--- a/lld/test/ELF/gc-sections-metadata-startstop.s
+++ b/lld/test/ELF/gc-sections-metadata-startstop.s
@@ -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
diff --git a/lld/test/ELF/mips-micro-relocs.s b/lld/test/ELF/mips-micro-relocs.s
index b539aa946763..566f6810f6e9 100644
--- a/lld/test/ELF/mips-micro-relocs.s
+++ b/lld/test/ELF/mips-micro-relocs.s
@@ -39,9 +39,9 @@
# EL-NEXT: 20028: 00 00 00 00 nop
# EL-NEXT: 2002c: 00 94 e8 ff b -44
-# SYM: 00037ff0 .got 00000000 .hidden _gp
-# SYM: 00020000 g F .text 00000000 foo
-# SYM: 00020010 .text 00000000 __start
+# SYM: 00037ff0 .got 00000000 .hidden _gp
+# SYM: 00020000 g F .text 00000000 0x80 foo
+# SYM: 00020010 .text 00000000 0x80 __start
.text
.set micromips
diff --git a/lld/test/ELF/mips-micror6-relocs.s b/lld/test/ELF/mips-micror6-relocs.s
index ca2c1c064f56..fb450ba5cf3c 100644
--- a/lld/test/ELF/mips-micror6-relocs.s
+++ b/lld/test/ELF/mips-micror6-relocs.s
@@ -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
diff --git a/llvm/test/tools/llvm-objdump/elf-symbol-visibility.test b/llvm/test/tools/llvm-objdump/elf-symbol-visibility.test
new file mode 100644
index 000000000000..da7f6d285166
--- /dev/null
+++ b/llvm/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/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index ba8d3c5b8d5c..9bd4528ef7f7 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/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<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';
}
}