@@ -62,17 +62,26 @@ Sections:
62
62
Size: 0
63
63
64
64
## Check we print symbol versions, when they are available.
65
-
66
- # RUN: yaml2obj --docnum=4 %s -o %t4.o
67
- # RUN: llvm-nm --dynamic %t4.o 2>&1 | \
68
- # RUN: FileCheck %s -DFILE=%t4.o --check-prefix=VERSIONED-SYMS
69
-
70
- # VERSIONED-SYMS: U globalversym
71
- # VERSIONED-SYMS-NEXT: U localversym
72
- # VERSIONED-SYMS-NEXT: U version2sym@v2
73
- # VERSIONED-SYMS-NEXT: U version3sym@v3hidden
74
- # VERSIONED-SYMS-NEXT: U version4sym@v4
75
- # VERSIONED-SYMS-NEXT: U version5sym@v5hidden
65
+ ## A default version is one that is contained in the version table (SHT_GNU_versym)
66
+ ## and only available for defined symbols. Check we use the "@@" prefix to print it.
67
+
68
+ # RUN: yaml2obj --docnum=4 %s -o %t4-undef.o
69
+ # RUN: llvm-nm --dynamic %t4-undef.o 2>&1 | \
70
+ # RUN: FileCheck %s -DFILE=%t4-undef.o -DTYPE=U \
71
+ # RUN: --check-prefixes=VERSIONED-SYMS,VERSIONED-UNDEF-SYMS
72
+
73
+ # RUN: yaml2obj --docnum=4 -DINDEX=0x1 %s -o %t4-def.o
74
+ # RUN: llvm-nm --dynamic %t4-def.o 2>&1 | \
75
+ # RUN: FileCheck %s -DFILE=%t4-def.o -DTYPE=r \
76
+ # RUN: --check-prefixes=VERSIONED-SYMS,VERSIONED-DEF-SYMS
77
+
78
+ # VERSIONED-SYMS: [[TYPE]] globalversym
79
+ # VERSIONED-SYMS-NEXT: [[TYPE]] localversym
80
+ # VERSIONED-UNDEF-SYMS-NEXT: [[TYPE]] version2sym@v2
81
+ # VERSIONED-DEF-SYMS-NEXT: [[TYPE]] version2sym@@v2
82
+ # VERSIONED-SYMS-NEXT: [[TYPE]] version3sym@v3hidden
83
+ # VERSIONED-SYMS-NEXT: [[TYPE]] version4sym@v4
84
+ # VERSIONED-SYMS-NEXT: [[TYPE]] version5sym@v5hidden
76
85
77
86
--- !ELF
78
87
FileHeader:
@@ -120,13 +129,22 @@ Sections:
120
129
Hash: 0
121
130
Flags: 0
122
131
Other: 5
132
+ - Name: .dynsym
133
+ Type: SHT_DYNSYM
134
+ EntSize: [[ENTSIZE=<none>]]
123
135
DynamicSymbols:
124
- - Name: localversym
125
- - Name: globalversym
126
- - Name: version2sym
127
- - Name: version3sym
128
- - Name: version4sym
129
- - Name: version5sym
136
+ - Name: localversym
137
+ Index: [[INDEX=<none>]]
138
+ - Name: globalversym
139
+ Index: [[INDEX=<none>]]
140
+ - Name: version2sym
141
+ Index: [[INDEX=<none>]]
142
+ - Name: version3sym
143
+ Index: [[INDEX=<none>]]
144
+ - Name: version4sym
145
+ Index: [[INDEX=<none>]]
146
+ - Name: version5sym
147
+ Index: [[INDEX=<none>]]
130
148
131
149
## In the following cases we check we report warnings when unable to read symbol version.
132
150
## Check that we still print unversioned symbol names.
@@ -137,7 +155,7 @@ DynamicSymbols:
137
155
138
156
# RUN: yaml2obj --docnum=4 -DVERDEFOFFSET=0xffffffff %s -o %t4-broken-verdef.o
139
157
# RUN: llvm-nm --dynamic %t4-broken-verdef.o 2>&1 | \
140
- # RUN: FileCheck %s -DFILE=%t4-broken-verdef.o - -check-prefixes=VERSION-ERR,VERSION-ERR1
158
+ # RUN: FileCheck %s --check-prefixes=VERSION-ERR,VERSION-ERR1
141
159
142
160
# VERSION-ERR1: warning: unable to read symbol versions: cannot read content of SHT_GNU_verdef section with index 2: section [index 2] has a sh_offset (0xffffffff) + sh_size (0x38) that is greater than the file size (0x438)
143
161
# VERSION-ERR2: warning: unable to read symbol versions: unable to read an entry with index 1 from SHT_GNU_versym section with index 1: section [index 1] has an invalid sh_size (255) which is not a multiple of its sh_entsize (2)
@@ -155,11 +173,21 @@ DynamicSymbols:
155
173
156
174
# RUN: yaml2obj --docnum=4 -DVERSYMSIZE=0xff %s -o %t4-broken-versym.o
157
175
# RUN: llvm-nm --dynamic %t4-broken-versym.o 2>&1 | \
158
- # RUN: FileCheck %s -DFILE=%t4-broken-versym.o - -check-prefixes=VERSION-ERR,VERSION-ERR2
176
+ # RUN: FileCheck %s --check-prefixes=VERSION-ERR,VERSION-ERR2
159
177
160
- ## Case 3: check we report a warning when we are unable to get a vesrion for a SHT_GNU_versym section entry.
178
+ ## Case 3: check we report a warning when we are unable to get a version for a SHT_GNU_versym section entry.
161
179
## In this case the SHT_GNU_versym section refers to a version index 255 which is missing.
162
180
163
181
# RUN: yaml2obj --docnum=4 -DVERSYMENTRY=0xff %s -o %t4-broken-index.o
164
182
# RUN: llvm-nm --dynamic %t4-broken-index.o 2>&1 | \
165
- # RUN: FileCheck %s -DFILE=%t4-broken-index.o --check-prefixes=VERSION-ERR,VERSION-ERR3
183
+ # RUN: FileCheck %s --check-prefixes=VERSION-ERR,VERSION-ERR3
184
+
185
+ ## Case 4: check we report a warning when we are unable to get symbol flags.
186
+ ## In this case the dynamic symbol table has a wrong sh_entsize and we can't read a symbol.
187
+
188
+ # RUN: yaml2obj --docnum=4 -DENTSIZE=0xff %s -o %t4-broken-dynsym.o
189
+ # RUN: not llvm-nm --dynamic %t4-broken-dynsym.o 2>&1 | \
190
+ # RUN: FileCheck %s -DFILE=%t4-broken-dynsym.o --check-prefix=VERSION-ERR4
191
+
192
+ # VERSION-ERR4: warning: unable to read symbol versions: unable to read flags for symbol with index 1: section [index 4] has invalid sh_entsize: expected 24, but got 255
193
+ # VERSION-ERR4: error: [[FILE]] section [index 4] has invalid sh_entsize: expected 24, but got 255
0 commit comments