xref: /llvm-project/llvm/test/tools/yaml2obj/ELF/symbol-name.yaml (revision 82b4368f7f89e2b16b9eb09787b7a7af07e3b7cd)
1## Check we are able to use integers as both
2## symbol name indices (st_name values) and symbol names.
3# RUN: yaml2obj --docnum=1 %s -o %t
4# RUN: llvm-readobj --symbols %t | FileCheck %s
5
6# CHECK: Name: test (1)
7# CHECK: Name: test (1)
8# CHECK: Name: est (2)
9# CHECK: Name: 1 (8)
10# CHECK: Name: 2 (6)
11
12--- !ELF
13FileHeader:
14  Class: ELFCLASS64
15  Data:  ELFDATA2LSB
16  Type:  ET_REL
17Symbols:
18  - Name:   test
19  - StName: 1
20  - StName: 2
21  - Name:   1
22  - Name:   2
23
24## Check we allow specifying both Name and StName at once.
25## In this case StName has priority, but the symbol Name is still added
26## to the symbol string table.
27
28# RUN: yaml2obj --docnum=2 %s -o %t2
29# RUN: llvm-readobj --symbols --sections --section-data -r --expand-relocs %t2 | FileCheck %s --check-prefix=BOTH
30
31# BOTH:      Name: .strtab
32# BOTH:      SectionData (
33# BOTH-NEXT:   0000: 00666F6F 00 |.foo.|
34# BOTH-NEXT: )
35
36# BOTH:       Relocations [
37# BOTH-NEXT:   Section (1) .rela.data {
38# BOTH-NEXT:     Relocation {
39# BOTH-NEXT:       Offset: 0x0
40# BOTH-NEXT:       Type: R_X86_64_NONE (0)
41# BOTH-NEXT:       Symbol: <null> (1)
42# BOTH-NEXT:       Addend: 0x0
43# BOTH-NEXT:     }
44# BOTH-NEXT:   }
45# BOTH-NEXT: ]
46
47# BOTH:      Symbols [
48# BOTH-NEXT:   Symbol {
49# BOTH-NEXT:     Name:  (0)
50# BOTH-NEXT:     Value: 0x0
51# BOTH-NEXT:     Size: 0
52# BOTH-NEXT:     Binding: Local (0x0)
53# BOTH-NEXT:     Type: None (0x0)
54# BOTH-NEXT:     Other: 0
55# BOTH-NEXT:     Section: Undefined (0x0)
56# BOTH-NEXT:   }
57# BOTH-NEXT:   Symbol {
58# BOTH-NEXT:     Name:  (0)
59# BOTH-NEXT:     Value: 0x0
60# BOTH-NEXT:     Size: 0
61# BOTH-NEXT:     Binding: Local (0x0)
62# BOTH-NEXT:     Type: None (0x0)
63# BOTH-NEXT:     Other: 0
64# BOTH-NEXT:     Section: Undefined (0x0)
65# BOTH-NEXT:   }
66# BOTH-NEXT: ]
67
68--- !ELF
69FileHeader:
70  Class:   ELFCLASS64
71  Data:    ELFDATA2LSB
72  Type:    ET_REL
73  Machine: EM_X86_64
74Sections:
75  - Name: .rela.data
76    Type: SHT_RELA
77    Relocations:
78      - Type:   R_X86_64_NONE
79        Symbol: foo
80Symbols:
81  - Name:   foo
82    StName: 0
83