diff options
author | George Rimar <grimar@accesssoftek.com> | 2019-08-23 09:31:07 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2019-08-23 09:31:07 +0000 |
commit | 668b11b2c85cd47e9afed51e9bef31321507db6e (patch) | |
tree | 5b4c037a29cfc49e1eff2bebe2ef87e8033610b1 /llvm/test | |
parent | bc01f48da37ee6f8996c5206785433d4928d3346 (diff) | |
download | bcm5719-llvm-668b11b2c85cd47e9afed51e9bef31321507db6e.tar.gz bcm5719-llvm-668b11b2c85cd47e9afed51e9bef31321507db6e.zip |
[yaml2obj] - Allow setting the symbol st_other field to any integer.
st_other field of a symbol usually contains its visibility.
Other bits are usually 0, though some targets, like
MIPS can set them using the named bit field values.
Problem is that there is no way to set an arbitrary value now,
though that might be useful for our test cases.
In this patch I introduced a way to set st_other to any numeric
value using the new StOther field.
I added a test and simplified the existent one to show the effect/benefit
Differential revision: https://reviews.llvm.org/D66583
llvm-svn: 369742
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/tools/llvm-readobj/elf-symbol-visibility.test | 23 | ||||
-rw-r--r-- | llvm/test/tools/yaml2obj/elf-symbol-stother.yaml | 79 |
2 files changed, 85 insertions, 17 deletions
diff --git a/llvm/test/tools/llvm-readobj/elf-symbol-visibility.test b/llvm/test/tools/llvm-readobj/elf-symbol-visibility.test index f2e402004dc..58354ce291d 100644 --- a/llvm/test/tools/llvm-readobj/elf-symbol-visibility.test +++ b/llvm/test/tools/llvm-readobj/elf-symbol-visibility.test @@ -1,11 +1,9 @@ # Show that llvm-readobj prints the symbol visibility where recognised, or # something sensible when not, for both GNU and LLVM output. -# Use --dyn-symbols because it is only possible to hand-craft symbols with -# non-standard st_other values for .dynsym. # RUN: yaml2obj %s > %t -# RUN: llvm-readobj --symbols --dyn-symbols %t | FileCheck %s --check-prefix=LLVM -# RUN: llvm-readelf --symbols --dyn-symbols %t | FileCheck %s --check-prefix=GNU +# RUN: llvm-readobj --symbols %t | FileCheck %s --check-prefix=LLVM +# RUN: llvm-readelf --symbols %t | FileCheck %s --check-prefix=GNU # LLVM: Name: default # LLVM: Other: 0 @@ -27,11 +25,11 @@ # FIXME - the "other" symbol should print something indicating its non-zero st_other value. # See https://bugs.llvm.org/show_bug.cgi?id=40785. -# GNU: DEFAULT {{.*}} other # GNU: DEFAULT {{.*}} default # GNU-NEXT: INTERNAL {{.*}} internal # GNU-NEXT: HIDDEN {{.*}} hidden # GNU-NEXT: PROTECTED {{.*}} protected +# GNU-NEXT: DEFAULT {{.*}} other !ELF FileHeader: @@ -39,18 +37,6 @@ FileHeader: Data: ELFDATA2LSB Type: ET_REL Machine: EM_386 -Sections: - - Name: .dynstr - Type: SHT_STRTAB - #\0other\0 - Content: "006f7468657200" - - Name: .dynsym - Type: SHT_DYNSYM - Link: .dynstr - EntSize: 16 - # Null symbol - # Symbol with st_name = 1, st_other = 0x4 - Content: "0000000000000000000000000000000001000000000000000000000000040000" Symbols: - Name: default Visibility: STV_DEFAULT @@ -64,3 +50,6 @@ Symbols: - Name: protected Visibility: STV_PROTECTED Binding: STB_GLOBAL + - Name: other + Binding: STB_GLOBAL + StOther: 4 diff --git a/llvm/test/tools/yaml2obj/elf-symbol-stother.yaml b/llvm/test/tools/yaml2obj/elf-symbol-stother.yaml new file mode 100644 index 00000000000..c867b9ec898 --- /dev/null +++ b/llvm/test/tools/yaml2obj/elf-symbol-stother.yaml @@ -0,0 +1,79 @@ +## Test how yaml2obj sets the value of a symbol's st_other fields. + +## Show that yaml2obj reports an error when using an STO_* flag that belongs +## to a different machine type to what is specified by the YAML. + +# RUN: not yaml2obj --docnum=1 2>&1 %s | FileCheck %s --check-prefix=ERR +# ERR: error: unknown bit value +# ERR-NEXT: Other: [ STO_MIPS_OPTIONAL ] + +--- !ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_386 +Symbols: + - Name: foo + Other: [ STO_MIPS_OPTIONAL ] + +## Test that STO_* can be used with their correct machine type. +## We use the same YAML as above, but with a change of machine type. + +# RUN: yaml2obj --docnum=2 %s > %t2 +# RUN: llvm-readobj --symbols %t2 | FileCheck %s --check-prefix=USE-OTHER + +# USE-OTHER: Name: foo +# USE-OTHER: Other [ (0x4) +# USE-OTHER-NEXT: STO_MIPS_OPTIONAL (0x4) +# USE-OTHER-NEXT: ] + +--- !ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_MIPS +Symbols: + - Name: foo + Other: [ STO_MIPS_OPTIONAL ] + +## Test that instead of using the "Other" field we can use the "StOther" field +## to set st_other to any arbitrary value. + +# RUN: yaml2obj --docnum=3 %s > %t3 +# RUN: llvm-readobj --symbols %t3 | FileCheck %s --check-prefix=USE-STOTHER +# RUN: yaml2obj --docnum=4 %s > %t4 +# RUN: llvm-readobj --symbols %t4 | FileCheck %s --check-prefix=USE-STOTHER + +# USE-STOTHER: Name: foo +# USE-STOTHER: Other [ +# USE-STOTHER-SAME: (0x4) + +# USE-STOTHER: Name: bar +# USE-STOTHER: Other [ +# USE-STOTHER-SAME: (0xFF) + +--- !ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_MIPS +Symbols: + - Name: foo + StOther: 4 + - Name: bar + StOther: 0xff + +--- !ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_386 +Symbols: + - Name: foo + StOther: 4 + - Name: bar + StOther: 0xff |