1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00
llvm-mirror/test/tools/llvm-objcopy/ELF/common-symbol.test
George Rimar 60c8d3580e [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
2019-04-03 14:53:42 +00:00

89 lines
2.3 KiB
Plaintext

# RUN: yaml2obj %s > %t
# RUN: llvm-objcopy %t %t2
# RUN: llvm-readobj --symbols %t2 | FileCheck %s
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_HEXAGON
Symbols:
- Name: test
Index: SHN_COMMON
Value: 0x1234
Binding: STB_GLOBAL
- Name: test2
Index: SHN_HEXAGON_SCOMMON
Value: 0x1235
Binding: STB_GLOBAL
- Name: test3
Index: SHN_HEXAGON_SCOMMON_2
Value: 0x1236
Binding: STB_GLOBAL
- Name: test4
Index: SHN_HEXAGON_SCOMMON_4
Value: 0x1237
Binding: STB_GLOBAL
- Name: test5
Index: SHN_HEXAGON_SCOMMON_8
Value: 0x1238
Binding: STB_GLOBAL
#CHECK: Symbols [
#CHECK-NEXT: Symbol {
#CHECK-NEXT: Name:
#CHECK-NEXT: Value: 0x0
#CHECK-NEXT: Size: 0
#CHECK-NEXT: Binding: Local (0x0)
#CHECK-NEXT: Type: None (0x0)
#CHECK-NEXT: Other: 0
#CHECK-NEXT: Section: Undefined (0x0)
#CHECK-NEXT: }
#CHECK-NEXT: Symbol {
#CHECK-NEXT: Name: test
#CHECK-NEXT: Value: 0x1234
#CHECK-NEXT: Size: 0
#CHECK-NEXT: Binding: Global (0x1)
#CHECK-NEXT: Type: None (0x0)
#CHECK-NEXT: Other: 0
#CHECK-NEXT: Section: Common (0xFFF2)
#CHECK-NEXT: }
#CHECK-NEXT: Symbol {
#CHECK-NEXT: Name: test2
#CHECK-NEXT: Value: 0x1235
#CHECK-NEXT: Size: 0
#CHECK-NEXT: Binding: Global (0x1)
#CHECK-NEXT: Type: None (0x0)
#CHECK-NEXT: Other: 0
#CHECK-NEXT: Section: Processor Specific (0xFF00)
#CHECK-NEXT: }
#CHECK-NEXT: Symbol {
#CHECK-NEXT: Name: test3
#CHECK-NEXT: Value: 0x1236
#CHECK-NEXT: Size: 0
#CHECK-NEXT: Binding: Global (0x1)
#CHECK-NEXT: Type: None (0x0)
#CHECK-NEXT: Other: 0
#CHECK-NEXT: Section: Processor Specific (0xFF02)
#CHECK-NEXT: }
#CHECK-NEXT: Symbol {
#CHECK-NEXT: Name: test4
#CHECK-NEXT: Value: 0x1237
#CHECK-NEXT: Size: 0
#CHECK-NEXT: Binding: Global (0x1)
#CHECK-NEXT: Type: None (0x0)
#CHECK-NEXT: Other: 0
#CHECK-NEXT: Section: Processor Specific (0xFF03)
#CHECK-NEXT: }
#CHECK-NEXT: Symbol {
#CHECK-NEXT: Name: test5
#CHECK-NEXT: Value: 0x1238
#CHECK-NEXT: Size: 0
#CHECK-NEXT: Binding: Global (0x1)
#CHECK-NEXT: Type: None (0x0)
#CHECK-NEXT: Other: 0
#CHECK-NEXT: Section: Processor Specific (0xFF04)
#CHECK-NEXT: }
#CHECK-NEXT:]