[PATCH] D58445: [yaml2obj]Allow symbol Index field to take values lower than SHN_LORESERVE
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 20 06:22:11 PST 2019
jhenderson created this revision.
jhenderson added reviewers: grimar, jakehehrlich, mcgrathr, silvas.
Herald added a subscriber: arphaman.
Herald added a project: LLVM.
In order to test tool handling of invalid section indexes, I need to create an object contianing such an invalid section index. I could create a hex-edited binary, but having the ability to use yaml2obj is preferable. Prior to this change, yaml2obj would reject any explicit section indexes less than SHN_LORESERVE. This patch changes it to allow any value.
I had to change the test to use llvm-readelf instead of llvm-readobj, because llvm-readobj does not like invalid section indexes. I've also expanded the test to show that the most common SHN_* values are accepted (SHN_UNDEF, SHN_ABS, SHN_COMMON).
Repository:
rL LLVM
https://reviews.llvm.org/D58445
Files:
lib/ObjectYAML/ELFYAML.cpp
test/tools/yaml2obj/symbol-index.yaml
Index: test/tools/yaml2obj/symbol-index.yaml
===================================================================
--- test/tools/yaml2obj/symbol-index.yaml
+++ test/tools/yaml2obj/symbol-index.yaml
@@ -1,5 +1,5 @@
# RUN: yaml2obj %s > %t
-# RUN: llvm-readobj -symbols %t | FileCheck %s
+# RUN: llvm-readelf -symbols %t | FileCheck %s
!ELF
FileHeader:
@@ -7,29 +7,38 @@
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
Symbols:
Global:
- - Name: test
+ - 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
-#CHECK: Symbols [
-#CHECK-NEXT: Symbol {
-#CHECK-NEXT: Name: (0)
-#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 (1)
-#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: Absolute (0xFFF1)
-#CHECK-NEXT: }
-#CHECK-NEXT:]
+# CHECK: Symbol table '.symtab' contains 9 entries
+# CHECK-NEXT: Num: {{.*}} Ndx Name
+# CHECK-NEXT: 0: {{.*}} UND
+# CHECK-NEXT: 1: {{.*}} ABS absolute1
+# CHECK-NEXT: 2: {{.*}} ABS absolute2
+# CHECK-NEXT: 3: {{.*}} COM common1
+# CHECK-NEXT: 4: {{.*}} COM common2
+# CHECK-NEXT: 5: {{.*}} 1 good
+# CHECK-NEXT: 6: {{.*}} 66 bad
+# CHECK-NEXT: 7: {{.*}} UND undef1
+# CHECK-NEXT: 8: {{.*}} UND undef2
Index: lib/ObjectYAML/ELFYAML.cpp
===================================================================
--- lib/ObjectYAML/ELFYAML.cpp
+++ lib/ObjectYAML/ELFYAML.cpp
@@ -831,9 +831,6 @@
if (Symbol.Index && *Symbol.Index == ELFYAML::ELF_SHN(ELF::SHN_XINDEX)) {
return "Large indexes are not supported";
}
- if (Symbol.Index && *Symbol.Index < ELFYAML::ELF_SHN(ELF::SHN_LORESERVE)) {
- return "Use a section name to define which section a symbol is defined in";
- }
return StringRef();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58445.187561.patch
Type: text/x-patch
Size: 2523 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190220/0366b0ab/attachment.bin>
More information about the llvm-commits
mailing list