[llvm] r264300 - [llvm-readobj] Decode st_other symbol's flags
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 24 09:10:38 PDT 2016
Author: atanasyan
Date: Thu Mar 24 11:10:37 2016
New Revision: 264300
URL: http://llvm.org/viewvc/llvm-project?rev=264300&view=rev
Log:
[llvm-readobj] Decode st_other symbol's flags
The patch supports common STV_xxx visibility flags and MIPS specific
STO_MIPS_xxx flags.
Differential Revision: http://reviews.llvm.org/D18447
Added:
llvm/trunk/test/tools/llvm-readobj/Inputs/st-other.obj.elf-mips
llvm/trunk/test/tools/llvm-readobj/Inputs/st-other.obj.elf-mips16
llvm/trunk/test/tools/llvm-readobj/mips-st-other.test
Modified:
llvm/trunk/test/MC/Mips/elf_st_other.s
llvm/trunk/test/MC/Mips/insn-directive.s
llvm/trunk/test/MC/Mips/micromips-alias.s
llvm/trunk/test/MC/Mips/micromips-label-test-sections.s
llvm/trunk/test/MC/Mips/micromips-label-test.s
llvm/trunk/test/MC/PowerPC/ppc64-localentry.s
llvm/trunk/test/MC/PowerPC/st-other-crash.s
llvm/trunk/test/Object/yaml2obj-elf-symbol-visibility.yaml
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
Modified: llvm/trunk/test/MC/Mips/elf_st_other.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/elf_st_other.s?rev=264300&r1=264299&r2=264300&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/elf_st_other.s (original)
+++ llvm/trunk/test/MC/Mips/elf_st_other.s Thu Mar 24 11:10:37 2016
@@ -21,6 +21,6 @@ f2:
// CHECK-LABEL: Name: d1
// CHECK: Other: 0
// CHECK-LABEL: Name: f1
-// CHECK: Other: 128
+// CHECK: Other [ (0x80)
// CHECK-LABEL: Name: f2
// CHECK: Other: 0
Modified: llvm/trunk/test/MC/Mips/insn-directive.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/insn-directive.s?rev=264300&r1=264299&r2=264300&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/insn-directive.s (original)
+++ llvm/trunk/test/MC/Mips/insn-directive.s Thu Mar 24 11:10:37 2016
@@ -73,10 +73,10 @@ bar:
# OBJ: Other: 0
# OBJ: Name: f_mm_insn_data
-# OBJ: Other: 128
+# OBJ: Other [ (0x80)
# OBJ: Name: f_mm_insn_instr
-# OBJ: Other: 128
+# OBJ: Other [ (0x80)
# OBJ: Name: f_normal_insn_data
# OBJ: Other: 0
@@ -85,10 +85,10 @@ bar:
# OBJ: Other: 0
# OBJ: Name: o_mm_insn_data
-# OBJ: Other: 128
+# OBJ: Other [ (0x80)
# OBJ: Name: o_mm_insn_instr
-# OBJ: Other: 128
+# OBJ: Other [ (0x80)
# OBJ: Name: o_normal_insn_data
# OBJ: Other: 0
Modified: llvm/trunk/test/MC/Mips/micromips-alias.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/micromips-alias.s?rev=264300&r1=264299&r2=264300&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/micromips-alias.s (original)
+++ llvm/trunk/test/MC/Mips/micromips-alias.s Thu Mar 24 11:10:37 2016
@@ -3,7 +3,7 @@
# Symbol bar must be marked as micromips.
# CHECK: Name: bar
-# CHECK: Other: 128
+# CHECK: Other [ (0x80)
.align 2
.type f, at function
.set nomips16
@@ -16,7 +16,7 @@ f:
bar = f
# CHECK: Name: foo
-# CHECK: Other: 128
+# CHECK: Other [ (0x80)
.type o, at object
.set micromips
o:
Modified: llvm/trunk/test/MC/Mips/micromips-label-test-sections.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/micromips-label-test-sections.s?rev=264300&r1=264299&r2=264300&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/micromips-label-test-sections.s (original)
+++ llvm/trunk/test/MC/Mips/micromips-label-test-sections.s Thu Mar 24 11:10:37 2016
@@ -14,7 +14,9 @@ h:
# CHECK: Name: f
# CHECK: Binding: Local
# CHECK: Type: None
-# CHECK: Other: 128
+# CHECK: Other [ (0x80)
+# CHECK: STO_MIPS_MICROMIPS
+# CHECK: ]
# CHECK: Section: .text
# CHECK: }
# CHECK: Symbol {
@@ -28,7 +30,9 @@ h:
# CHECK: Name: h
# CHECK: Binding: Local
# CHECK: Type: None
-# CHECK: Other: 128
+# CHECK: Other [ (0x80)
+# CHECK: STO_MIPS_MICROMIPS
+# CHECK: ]
# CHECK: Section: .text
# CHECK: }
# CHECK: ]
Modified: llvm/trunk/test/MC/Mips/micromips-label-test.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/micromips-label-test.s?rev=264300&r1=264299&r2=264300&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/micromips-label-test.s (original)
+++ llvm/trunk/test/MC/Mips/micromips-label-test.s Thu Mar 24 11:10:37 2016
@@ -26,7 +26,9 @@ j:
# CHECK: Name: g
# CHECK: Binding: Local
# CHECK: Type: None
-# CHECK: Other: 128
+# CHECK: Other [ (0x80)
+# CHECK: STO_MIPS_MICROMIPS
+# CHECK: ]
# CHECK: Section: .text
# CHECK: }
# CHECK: Symbol {
@@ -40,7 +42,9 @@ j:
# CHECK: Name: i
# CHECK: Binding: Local
# CHECK: Type: None
-# CHECK: Other: 128
+# CHECK: Other [ (0x80)
+# CHECK: STO_MIPS_MICROMIPS
+# CHECK: ]
# CHECK: Section: .text
# CHECK: }
# CHECK: Symbol {
Modified: llvm/trunk/test/MC/PowerPC/ppc64-localentry.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/PowerPC/ppc64-localentry.s?rev=264300&r1=264299&r2=264300&view=diff
==============================================================================
--- llvm/trunk/test/MC/PowerPC/ppc64-localentry.s (original)
+++ llvm/trunk/test/MC/PowerPC/ppc64-localentry.s Thu Mar 24 11:10:37 2016
@@ -61,7 +61,8 @@ copy2 = callee2
# CHECK-NEXT: Size: 16
# CHECK-NEXT: Binding: Local
# CHECK-NEXT: Type: Function
-# CHECK-NEXT: Other: 96
+# CHECK-NEXT: Other [ (0x60)
+# CHECK-NEXT: ]
# CHECK-NEXT: Section: .text
# CHECK: Name: callee2
# CHECK-NEXT: Value:
@@ -77,7 +78,8 @@ copy2 = callee2
# CHECK-NEXT: Size: 16
# CHECK-NEXT: Binding: Local
# CHECK-NEXT: Type: Function
-# CHECK-NEXT: Other: 96
+# CHECK-NEXT: Other [ (0x60)
+# CHECK-NEXT: ]
# CHECK-NEXT: Section: .text
# CHECK: Name: copy2
# CHECK-NEXT: Value:
Modified: llvm/trunk/test/MC/PowerPC/st-other-crash.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/PowerPC/st-other-crash.s?rev=264300&r1=264299&r2=264300&view=diff
==============================================================================
--- llvm/trunk/test/MC/PowerPC/st-other-crash.s (original)
+++ llvm/trunk/test/MC/PowerPC/st-other-crash.s Thu Mar 24 11:10:37 2016
@@ -9,7 +9,8 @@
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local (0x0)
// CHECK-NEXT: Type: None (0x0)
-// CHECK-NEXT: Other: 64
+// CHECK-NEXT: Other [ (0x40)
+// CHECK-NEXT: ]
// CHECK-NEXT: Section: .group
// CHECK-NEXT: }
Modified: llvm/trunk/test/Object/yaml2obj-elf-symbol-visibility.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/yaml2obj-elf-symbol-visibility.yaml?rev=264300&r1=264299&r2=264300&view=diff
==============================================================================
--- llvm/trunk/test/Object/yaml2obj-elf-symbol-visibility.yaml (original)
+++ llvm/trunk/test/Object/yaml2obj-elf-symbol-visibility.yaml Thu Mar 24 11:10:37 2016
@@ -26,7 +26,9 @@
# OBJ-NEXT: Size: 4
# OBJ-NEXT: Binding: Global (0x1)
# OBJ-NEXT: Type: Object (0x1)
-# OBJ-NEXT: Other: 1
+# OBJ-NEXT: Other [ (0x1)
+# OBJ-NEXT: STV_INTERNAL
+# OBJ-NEXT: ]
# OBJ-NEXT: Section: .data (0x1)
# OBJ-NEXT: }
# OBJ-NEXT: Symbol {
@@ -35,7 +37,9 @@
# OBJ-NEXT: Size: 4
# OBJ-NEXT: Binding: Global (0x1)
# OBJ-NEXT: Type: Object (0x1)
-# OBJ-NEXT: Other: 2
+# OBJ-NEXT: Other [ (0x2)
+# OBJ-NEXT: STV_HIDDEN
+# OBJ-NEXT: ]
# OBJ-NEXT: Section: .data (0x1)
# OBJ-NEXT: }
# OBJ-NEXT: Symbol {
@@ -44,7 +48,11 @@
# OBJ-NEXT: Size: 4
# OBJ-NEXT: Binding: Global (0x1)
# OBJ-NEXT: Type: Object (0x1)
-# OBJ-NEXT: Other: 163
+# OBJ-NEXT: Other [ (0xA3)
+# OBJ-NEXT: STO_MIPS_MICROMIPS
+# OBJ-NEXT: STO_MIPS_PIC
+# OBJ-NEXT: STV_PROTECTED
+# OBJ-NEXT: ]
# OBJ-NEXT: Section: .data (0x1)
# OBJ-NEXT: }
Added: llvm/trunk/test/tools/llvm-readobj/Inputs/st-other.obj.elf-mips
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/Inputs/st-other.obj.elf-mips?rev=264300&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/llvm-readobj/Inputs/st-other.obj.elf-mips (added) and llvm/trunk/test/tools/llvm-readobj/Inputs/st-other.obj.elf-mips Thu Mar 24 11:10:37 2016 differ
Added: llvm/trunk/test/tools/llvm-readobj/Inputs/st-other.obj.elf-mips16
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/Inputs/st-other.obj.elf-mips16?rev=264300&view=auto
==============================================================================
Binary files llvm/trunk/test/tools/llvm-readobj/Inputs/st-other.obj.elf-mips16 (added) and llvm/trunk/test/tools/llvm-readobj/Inputs/st-other.obj.elf-mips16 Thu Mar 24 11:10:37 2016 differ
Added: llvm/trunk/test/tools/llvm-readobj/mips-st-other.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/mips-st-other.test?rev=264300&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/mips-st-other.test (added)
+++ llvm/trunk/test/tools/llvm-readobj/mips-st-other.test Thu Mar 24 11:10:37 2016
@@ -0,0 +1,25 @@
+RUN: llvm-readobj -symbols %p/Inputs/st-other.obj.elf-mips \
+RUN: | FileCheck -check-prefix=MREG %s
+RUN: llvm-readobj -symbols %p/Inputs/st-other.obj.elf-mips16 \
+RUN: | FileCheck -check-prefix=M16 %s
+
+MREG: Name: foo
+MREG-NEXT: Value: 0x0
+MREG-NEXT: Size: 0
+MREG-NEXT: Binding: Global
+MREG-NEXT: Type: None
+MREG-NEXT: Other [ (0x29)
+MREG-NEXT: STO_MIPS_PIC (0x20)
+MREG-NEXT: STO_MIPS_PLT (0x8)
+MREG-NEXT: STV_INTERNAL (0x1)
+MREG-NEXT: ]
+
+M16: Name: foo
+M16-NEXT: Value: 0x0
+M16-NEXT: Size: 0
+M16-NEXT: Binding: Global
+M16-NEXT: Type: None
+M16-NEXT: Other [ (0xF1)
+M16-NEXT: STO_MIPS_MIPS16 (0xF0)
+M16-NEXT: STV_INTERNAL (0x1)
+M16-NEXT: ]
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=264300&r1=264299&r2=264300&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Thu Mar 24 11:10:37 2016
@@ -1128,6 +1128,25 @@ static const EnumEntry<unsigned> ElfHead
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_64R6)
};
+static const EnumEntry<unsigned> ElfSymOtherFlags[] = {
+ LLVM_READOBJ_ENUM_ENT(ELF, STV_INTERNAL),
+ LLVM_READOBJ_ENUM_ENT(ELF, STV_HIDDEN),
+ LLVM_READOBJ_ENUM_ENT(ELF, STV_PROTECTED)
+};
+
+static const EnumEntry<unsigned> ElfMipsSymOtherFlags[] = {
+ LLVM_READOBJ_ENUM_ENT(ELF, STO_MIPS_OPTIONAL),
+ LLVM_READOBJ_ENUM_ENT(ELF, STO_MIPS_PLT),
+ LLVM_READOBJ_ENUM_ENT(ELF, STO_MIPS_PIC),
+ LLVM_READOBJ_ENUM_ENT(ELF, STO_MIPS_MICROMIPS)
+};
+
+static const EnumEntry<unsigned> ElfMips16SymOtherFlags[] = {
+ LLVM_READOBJ_ENUM_ENT(ELF, STO_MIPS_OPTIONAL),
+ LLVM_READOBJ_ENUM_ENT(ELF, STO_MIPS_PLT),
+ LLVM_READOBJ_ENUM_ENT(ELF, STO_MIPS_MIPS16)
+};
+
template <typename ELFT>
ELFDumper<ELFT>::ELFDumper(const ELFFile<ELFT> *Obj, StreamWriter &Writer)
: ObjDumper(Writer), Obj(Obj) {
@@ -2883,7 +2902,28 @@ void LLVMStyle<ELFT>::printSymbol(const
W.printEnum("Type", SymbolType, makeArrayRef(AMDGPUSymbolTypes));
else
W.printEnum("Type", SymbolType, makeArrayRef(ElfSymbolTypes));
- W.printNumber("Other", Symbol->st_other);
+ if (Symbol->st_other == 0)
+ // Usually st_other flag is zero. Do not pollute the output
+ // by flags enumeration in that case.
+ W.printNumber("Other", 0);
+ else {
+ std::vector<EnumEntry<unsigned>> SymOtherFlags(std::begin(ElfSymOtherFlags),
+ std::end(ElfSymOtherFlags));
+ if (Obj->getHeader()->e_machine == EM_MIPS) {
+ // Someones in their infinite wisdom decided to make STO_MIPS_MIPS16
+ // flag overlapped with other ST_MIPS_xxx flags. So consider both
+ // cases separately.
+ if ((Symbol->st_other & STO_MIPS_MIPS16) == STO_MIPS_MIPS16)
+ SymOtherFlags.insert(SymOtherFlags.end(),
+ std::begin(ElfMips16SymOtherFlags),
+ std::end(ElfMips16SymOtherFlags));
+ else
+ SymOtherFlags.insert(SymOtherFlags.end(),
+ std::begin(ElfMipsSymOtherFlags),
+ std::end(ElfMipsSymOtherFlags));
+ }
+ W.printFlags("Other", Symbol->st_other, makeArrayRef(SymOtherFlags), 0x3u);
+ }
W.printHex("Section", SectionName, SectionIndex);
}
More information about the llvm-commits
mailing list