diff options
author | George Rimar <grimar@accesssoftek.com> | 2019-04-03 14:53:42 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2019-04-03 14:53:42 +0000 |
commit | 6da44ad75d25d5d7089c66d7cd3f4f90cd70146c (patch) | |
tree | 4a0c32a0e9d75bb8005b9b7b3809b96dd63be7b6 /llvm/test/tools/yaml2obj | |
parent | f5b181e16db70bb78fb7ac33f811ff23e2a80191 (diff) | |
download | bcm5719-llvm-6da44ad75d25d5d7089c66d7cd3f4f90cd70146c.tar.gz bcm5719-llvm-6da44ad75d25d5d7089c66d7cd3f4f90cd70146c.zip |
[yaml2obj][obj2yaml] - Change how symbol's binding is descibed when parsing/dumping.
Currently, YAML has the following syntax for describing the symbols:
Symbols:
Local:
LocalSymbol1:
...
LocalSymbol2:
...
...
Global:
GlobalSymbol1:
...
Weak:
...
GNUUnique:
I.e. symbols are grouped by their bindings. That is not very convenient,
because:
It does not allow to set a custom binding, what can be useful for producing
broken/special outputs for test cases. Adding a new binding would require to
change a syntax (what we observed when added GNUUnique recently).
It does not allow to change the order of the symbols in .symtab/.dynsym,
i.e. currently all Local symbols are placed first, then Global, Weak and GNUUnique
are following, but we are not able to change the order.
It is not consistent. Binding is just one of the properties of the symbol,
we do not group them by other properties.
It makes the code more complex that it can be. This patch shows it can be simplified
with the change performed.
The patch changes the syntax to just:
Symbols:
Symbol1:
...
Symbol2:
...
...
With that, we are able to work with the binding field just like with any other symbol property.
Differential revision: https://reviews.llvm.org/D60122
llvm-svn: 357595
Diffstat (limited to 'llvm/test/tools/yaml2obj')
-rw-r--r-- | llvm/test/tools/yaml2obj/dynamic-symbols.yaml | 24 | ||||
-rw-r--r-- | llvm/test/tools/yaml2obj/dynsym-dynstr-addr.yaml | 4 | ||||
-rw-r--r-- | llvm/test/tools/yaml2obj/elf-comdat-broken.yaml | 4 | ||||
-rw-r--r-- | llvm/test/tools/yaml2obj/elf-gnu-unique-symbols.yaml | 6 | ||||
-rw-r--r-- | llvm/test/tools/yaml2obj/elf-symbols-binding-order.yaml | 18 | ||||
-rw-r--r-- | llvm/test/tools/yaml2obj/elf-symtab-shinfo.yaml | 8 | ||||
-rw-r--r-- | llvm/test/tools/yaml2obj/elf-symtab-shtype.yaml | 4 | ||||
-rw-r--r-- | llvm/test/tools/yaml2obj/relocation-explicit-symbol-index.yaml | 4 | ||||
-rw-r--r-- | llvm/test/tools/yaml2obj/symbol-index.yaml | 45 | ||||
-rw-r--r-- | llvm/test/tools/yaml2obj/symbol-type.yaml | 36 | ||||
-rw-r--r-- | llvm/test/tools/yaml2obj/verdef-section.yaml | 4 | ||||
-rw-r--r-- | llvm/test/tools/yaml2obj/verneed-section.yaml | 4 | ||||
-rw-r--r-- | llvm/test/tools/yaml2obj/versym-section.yaml | 7 |
13 files changed, 100 insertions, 68 deletions
diff --git a/llvm/test/tools/yaml2obj/dynamic-symbols.yaml b/llvm/test/tools/yaml2obj/dynamic-symbols.yaml index c77f743e369..718b06d55c4 100644 --- a/llvm/test/tools/yaml2obj/dynamic-symbols.yaml +++ b/llvm/test/tools/yaml2obj/dynamic-symbols.yaml @@ -14,18 +14,18 @@ Sections: Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_WRITE ] DynamicSymbols: - Global: - - Name: dynglobal - Type: STT_OBJECT - Section: .data - Weak: - - Name: dynweak - Type: STT_OBJECT - Section: .data - Local: - - Name: dynlocal - Type: STT_OBJECT - Section: .data + - Name: dynglobal + Type: STT_OBJECT + Section: .data + Binding: STB_GLOBAL + - Name: dynweak + Type: STT_OBJECT + Section: .data + Binding: STB_WEAK + - Name: dynlocal + Type: STT_OBJECT + Section: .data + Binding: STB_LOCAL # SECTION: Name: .dynsym # SECTION-NEXT: Type: SHT_DYNSYM diff --git a/llvm/test/tools/yaml2obj/dynsym-dynstr-addr.yaml b/llvm/test/tools/yaml2obj/dynsym-dynstr-addr.yaml index c54787cf30e..e256fdc00e0 100644 --- a/llvm/test/tools/yaml2obj/dynsym-dynstr-addr.yaml +++ b/llvm/test/tools/yaml2obj/dynsym-dynstr-addr.yaml @@ -36,5 +36,5 @@ Sections: Address: 0x2000 EntSize: 0x18 DynamicSymbols: - Global: - - Name: foo + - Name: foo + Binding: STB_GLOBAL diff --git a/llvm/test/tools/yaml2obj/elf-comdat-broken.yaml b/llvm/test/tools/yaml2obj/elf-comdat-broken.yaml index 14b4d53eeeb..5ed7a56c9a6 100644 --- a/llvm/test/tools/yaml2obj/elf-comdat-broken.yaml +++ b/llvm/test/tools/yaml2obj/elf-comdat-broken.yaml @@ -16,8 +16,8 @@ Sections: - SectionOrType: 0xFF - SectionOrType: 3 Symbols: - Global: - - Name: foo + - Name: foo + - Binding: STB_GLOBAL ## Check we are able to produce SHT_GROUP section with a custom Type (0xFF). # CHECK: Groups { diff --git a/llvm/test/tools/yaml2obj/elf-gnu-unique-symbols.yaml b/llvm/test/tools/yaml2obj/elf-gnu-unique-symbols.yaml index 9872b5e76c4..06c504e65b3 100644 --- a/llvm/test/tools/yaml2obj/elf-gnu-unique-symbols.yaml +++ b/llvm/test/tools/yaml2obj/elf-gnu-unique-symbols.yaml @@ -16,6 +16,6 @@ FileHeader: Type: ET_REL Machine: EM_X86_64 Symbols: - GNUUnique: - - Name: foo - Type: STT_OBJECT + - Name: foo + Type: STT_OBJECT + Binding: STB_GNU_UNIQUE diff --git a/llvm/test/tools/yaml2obj/elf-symbols-binding-order.yaml b/llvm/test/tools/yaml2obj/elf-symbols-binding-order.yaml new file mode 100644 index 00000000000..1c9fbe30e4e --- /dev/null +++ b/llvm/test/tools/yaml2obj/elf-symbols-binding-order.yaml @@ -0,0 +1,18 @@ +## Check we restrict placing local symbols after global in .symtab +## We might want to change it later to allow doing that +## for producing broken outputs. + +# RUN: not yaml2obj %s -o %t 2>&1 | FileCheck %s +# CHECK: error: Local symbol 'bar' after global in Symbols list. + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Symbols: + - Name: foo + Binding: STB_GLOBAL + - Name: bar + Binding: STB_LOCAL diff --git a/llvm/test/tools/yaml2obj/elf-symtab-shinfo.yaml b/llvm/test/tools/yaml2obj/elf-symtab-shinfo.yaml index 649e5684f63..982c5d4efeb 100644 --- a/llvm/test/tools/yaml2obj/elf-symtab-shinfo.yaml +++ b/llvm/test/tools/yaml2obj/elf-symtab-shinfo.yaml @@ -36,8 +36,8 @@ Sections: Info: 26 Type: SHT_SYMTAB Symbols: - Global: - - Name: foo + - Name: foo + Binding: STB_GLOBAL DynamicSymbols: - Global: - - Name: bar + - Name: bar + Binding: STB_GLOBAL diff --git a/llvm/test/tools/yaml2obj/elf-symtab-shtype.yaml b/llvm/test/tools/yaml2obj/elf-symtab-shtype.yaml index cfa5cf427b7..143c0255b0e 100644 --- a/llvm/test/tools/yaml2obj/elf-symtab-shtype.yaml +++ b/llvm/test/tools/yaml2obj/elf-symtab-shtype.yaml @@ -17,5 +17,5 @@ Sections: - Name: .symtab Type: SHT_DYNAMIC Symbols: - Global: - - Name: foo + - Name: foo + Binding: STB_GLOBAL diff --git a/llvm/test/tools/yaml2obj/relocation-explicit-symbol-index.yaml b/llvm/test/tools/yaml2obj/relocation-explicit-symbol-index.yaml index ac16643b9b0..1a3470fe098 100644 --- a/llvm/test/tools/yaml2obj/relocation-explicit-symbol-index.yaml +++ b/llvm/test/tools/yaml2obj/relocation-explicit-symbol-index.yaml @@ -32,5 +32,5 @@ Sections: Offset: 0 Symbol: 0x1 Symbols: - Global: - - Name: foo + - Name: foo + Binding: STB_GLOBAL diff --git a/llvm/test/tools/yaml2obj/symbol-index.yaml b/llvm/test/tools/yaml2obj/symbol-index.yaml index e5c50735f4c..980c70d52cc 100644 --- a/llvm/test/tools/yaml2obj/symbol-index.yaml +++ b/llvm/test/tools/yaml2obj/symbol-index.yaml @@ -11,25 +11,32 @@ Sections: - Name: .text Type: SHT_PROGBITS Symbols: - Global: - - Name: absolute1 - Index: SHN_ABS - Value: 0x1234 - - Name: absolute2 - Index: 0xfff1 - Value: 0x4321 - - Name: common1 - Index: SHN_COMMON - - Name: common2 - Index: 0xfff2 - - Name: good - Index: 0x1 - - Name: bad - Index: 0x42 - - Name: undef1 - Index: SHN_UNDEF - - Name: undef2 - Index: 0 + - Name: absolute1 + Index: SHN_ABS + Value: 0x1234 + Binding: STB_GLOBAL + - Name: absolute2 + Index: 0xfff1 + Value: 0x4321 + Binding: STB_GLOBAL + - Name: common1 + Index: SHN_COMMON + Binding: STB_GLOBAL + - Name: common2 + Index: 0xfff2 + Binding: STB_GLOBAL + - Name: good + Index: 0x1 + Binding: STB_GLOBAL + - Name: bad + Index: 0x42 + Binding: STB_GLOBAL + - Name: undef1 + Index: SHN_UNDEF + Binding: STB_GLOBAL + - Name: undef2 + Index: 0 + Binding: STB_GLOBAL # CHECK: Symbol table '.symtab' contains 9 entries # CHECK-NEXT: Num: {{.*}} Ndx Name diff --git a/llvm/test/tools/yaml2obj/symbol-type.yaml b/llvm/test/tools/yaml2obj/symbol-type.yaml index 1bca0e41015..5b3bb73c43b 100644 --- a/llvm/test/tools/yaml2obj/symbol-type.yaml +++ b/llvm/test/tools/yaml2obj/symbol-type.yaml @@ -26,18 +26,24 @@ Sections: - Name: .text Type: SHT_PROGBITS Symbols: - Global: - - Name: notype - Type: STT_NOTYPE - - Name: normal_type - Type: STT_OBJECT - - Name: .text - Type: STT_SECTION - - Name: known_hex - Type: 0x1 - - Name: unknown_hex - Type: 0xb - - Name: known_int - Type: 1 - - Name: unknown_int - Type: 11 + - Name: notype + Type: STT_NOTYPE + Binding: STB_GLOBAL + - Name: normal_type + Type: STT_OBJECT + Binding: STB_GLOBAL + - Name: .text + Type: STT_SECTION + Binding: STB_GLOBAL + - Name: known_hex + Type: 0x1 + Binding: STB_GLOBAL + - Name: unknown_hex + Type: 0xb + Binding: STB_GLOBAL + - Name: known_int + Type: 1 + Binding: STB_GLOBAL + - Name: unknown_int + Type: 11 + Binding: STB_GLOBAL diff --git a/llvm/test/tools/yaml2obj/verdef-section.yaml b/llvm/test/tools/yaml2obj/verdef-section.yaml index deac6e736c0..582b8019266 100644 --- a/llvm/test/tools/yaml2obj/verdef-section.yaml +++ b/llvm/test/tools/yaml2obj/verdef-section.yaml @@ -64,6 +64,6 @@ Sections: - VERSION_2 - VERSION_3 DynamicSymbols: - Global: - - Name: foo + - Name: foo + Binding: STB_GLOBAL ... diff --git a/llvm/test/tools/yaml2obj/verneed-section.yaml b/llvm/test/tools/yaml2obj/verneed-section.yaml index 2fc58ad64f0..bdfddff9810 100644 --- a/llvm/test/tools/yaml2obj/verneed-section.yaml +++ b/llvm/test/tools/yaml2obj/verneed-section.yaml @@ -69,5 +69,5 @@ Sections: Flags: 12 Other: 2 DynamicSymbols: - Global: - - Name: f1 + - Name: f1 + Binding: STB_GLOBAL diff --git a/llvm/test/tools/yaml2obj/versym-section.yaml b/llvm/test/tools/yaml2obj/versym-section.yaml index 3c08ddd63d2..506e16cc5e1 100644 --- a/llvm/test/tools/yaml2obj/versym-section.yaml +++ b/llvm/test/tools/yaml2obj/versym-section.yaml @@ -82,7 +82,8 @@ Sections: Flags: 0 Other: 4 DynamicSymbols: - Global: - - Name: f1 - - Name: f2 + - Name: f1 + Binding: STB_GLOBAL + - Name: f2 + Binding: STB_GLOBAL ... |