Index: test/MC/Mips/elf_st_other.s =================================================================== --- test/MC/Mips/elf_st_other.s +++ test/MC/Mips/elf_st_other.s @@ -21,6 +21,6 @@ // CHECK-LABEL: Name: d1 // CHECK: Other: 0 // CHECK-LABEL: Name: f1 -// CHECK: Other: 128 +// CHECK: Other [ (0x80) // CHECK-LABEL: Name: f2 // CHECK: Other: 0 Index: test/MC/Mips/insn-directive.s =================================================================== --- test/MC/Mips/insn-directive.s +++ test/MC/Mips/insn-directive.s @@ -73,10 +73,10 @@ # 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 @@ # 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 Index: test/MC/Mips/micromips-alias.s =================================================================== --- test/MC/Mips/micromips-alias.s +++ test/MC/Mips/micromips-alias.s @@ -3,7 +3,7 @@ # Symbol bar must be marked as micromips. # CHECK: Name: bar -# CHECK: Other: 128 +# CHECK: Other [ (0x80) .align 2 .type f,@function .set nomips16 @@ -16,7 +16,7 @@ bar = f # CHECK: Name: foo -# CHECK: Other: 128 +# CHECK: Other [ (0x80) .type o,@object .set micromips o: Index: test/MC/Mips/micromips-label-test-sections.s =================================================================== --- test/MC/Mips/micromips-label-test-sections.s +++ test/MC/Mips/micromips-label-test-sections.s @@ -14,7 +14,9 @@ # 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 @@ # 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: ] Index: test/MC/Mips/micromips-label-test.s =================================================================== --- test/MC/Mips/micromips-label-test.s +++ test/MC/Mips/micromips-label-test.s @@ -26,7 +26,9 @@ # 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 @@ # 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 { Index: test/MC/PowerPC/ppc64-localentry.s =================================================================== --- test/MC/PowerPC/ppc64-localentry.s +++ test/MC/PowerPC/ppc64-localentry.s @@ -61,7 +61,8 @@ # 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 @@ # 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: Index: test/MC/PowerPC/st-other-crash.s =================================================================== --- test/MC/PowerPC/st-other-crash.s +++ test/MC/PowerPC/st-other-crash.s @@ -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: } Index: test/Object/yaml2obj-elf-symbol-visibility.yaml =================================================================== --- test/Object/yaml2obj-elf-symbol-visibility.yaml +++ test/Object/yaml2obj-elf-symbol-visibility.yaml @@ -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: } Index: test/tools/llvm-readobj/mips-st-other.test =================================================================== --- /dev/null +++ test/tools/llvm-readobj/mips-st-other.test @@ -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: ] Index: tools/llvm-readobj/ELFDumper.cpp =================================================================== --- tools/llvm-readobj/ELFDumper.cpp +++ tools/llvm-readobj/ELFDumper.cpp @@ -1128,6 +1128,25 @@ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_64R6) }; +static const EnumEntry 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 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 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 ELFDumper::ELFDumper(const ELFFile *Obj, StreamWriter &Writer) : ObjDumper(Writer), Obj(Obj) { @@ -2883,7 +2902,28 @@ 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> 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); }