duplicate-symbol-and-section-names.yaml
3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
## Check that obj2yaml is able to produce YAML from
## an object containing symbols and sections with duplicate
## names and produces same-named sections and symbols
## with distinguishing suffixes.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readobj -s -t %t1 | FileCheck %s
# CHECK: Name: .foo (
# CHECK: Name: .foo (
# CHECK: Name: .foo (
# CHECK: Name: .bar (
# CHECK: Name: .bar (
# CHECK: Name: .bar (
# CHECK: Name: localfoo (
# CHECK: Name: localfoo (
# CHECK: Name: localfoo (
# CHECK: Name: localbar (
# CHECK: Name: localbar (
# CHECK: Name: localbar (
# RUN: obj2yaml %t1 | FileCheck %s --check-prefix=CASE1
# CASE1: --- !ELF
# CASE1-NEXT: FileHeader:
# CASE1-NEXT: Class: ELFCLASS64
# CASE1-NEXT: Data: ELFDATA2LSB
# CASE1-NEXT: Type: ET_REL
# CASE1-NEXT: Sections:
# CASE1-NEXT: - Name: .foo
# CASE1-NEXT: Type: SHT_PROGBITS
# CASE1-NEXT: - Name: '.foo (1)'
# CASE1-NEXT: Type: SHT_PROGBITS
# CASE1-NEXT: - Name: '.foo (2)'
# CASE1-NEXT: Type: SHT_PROGBITS
# CASE1-NEXT: - Name: .bar
# CASE1-NEXT: Type: SHT_PROGBITS
# CASE1-NEXT: - Name: '.bar (1)'
# CASE1-NEXT: Type: SHT_PROGBITS
# CASE1-NEXT: - Name: '.bar (2)'
# CASE1-NEXT: Type: SHT_PROGBITS
# CASE1-NEXT: Symbols:
# CASE1-NEXT: - Name: localfoo
# CASE1-NEXT: - Name: 'localfoo (1)'
# CASE1-NEXT: - Name: 'localfoo (2)'
# CASE1-NEXT: - Name: localbar
# CASE1-NEXT: - Name: 'localbar (1)'
# CASE1-NEXT: - Name: 'localbar (2)'
# CASE1-NEXT: ...
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Sections:
- Name: .foo
Type: SHT_PROGBITS
- Name: '.foo (555)'
Type: SHT_PROGBITS
- Name: '.foo (random_tag)'
Type: SHT_PROGBITS
- Name: .bar
Type: SHT_PROGBITS
- Name: '.bar (666)'
Type: SHT_PROGBITS
- Name: '.bar (random_tag)'
Type: SHT_PROGBITS
Symbols:
- Name: 'localfoo (111)'
- Name: 'localfoo (222)'
- Name: 'localfoo (random_tag)'
- Name: 'localbar (333)'
- Name: 'localbar (444)'
- Name: 'localbar (random_tag)'
## Check we can refer to symbols with the same
## name from relocations.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: obj2yaml %t2 | FileCheck %s --check-prefix=CASE2
# CASE2: Relocations:
# CASE2-NEXT: - Symbol: 'foo (1)'
# CASE2-NEXT: Type: R_X86_64_PC32
# CASE2-NEXT: - Offset: 0x0000000000000004
# CASE2-NEXT: Symbol: foo
# CASE2-NEXT: Type: R_X86_64_PC32
# CASE2-NEXT: Symbols:
# CASE2-NEXT: - Name: foo
# CASE2-NEXT: - Name: 'foo (1)'
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Size: 8
- Name: .rela.text
Type: SHT_RELA
Info: .text
Link: .symtab
Relocations:
- Type: R_X86_64_PC32
Symbol: 'foo (1)'
- Type: R_X86_64_PC32
Offset: 4
Symbol: foo
Symbols:
- Name: foo
- Name: 'foo (1)'
## Check obj2yaml does not add a suffix to a name if the
## symbol is in .symtab and .dynsym at the same time.
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: obj2yaml %t3 | FileCheck %s --check-prefix=CASE3
# CASE3: Symbols:
# CASE3-NEXT: - Name: foo
# CASE3-NEXT: Binding: STB_GLOBAL
# CASE3-NEXT: DynamicSymbols:
# CASE3-NEXT: - Name: foo
# CASE3-NEXT: Binding: STB_GLOBAL
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Symbols:
- Name: foo
Binding: STB_GLOBAL
DynamicSymbols:
- Name: foo
Binding: STB_GLOBAL