[PATCH] D57822: [yaml2obj]Allow number for ELF symbol type

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 6 08:18:03 PST 2019


jhenderson created this revision.
jhenderson added reviewers: grimar, amontanez, mstorsjo, jakehehrlich.
Herald added a project: LLVM.

yaml2obj previously only recognised standard STT_* names, and didn't allow arbitrary numbers. This change allows the user to specify a number for the type instead. It also adds a test to verify the existing behaviour for obj2yaml for unkown symbol types.


Repository:
  rL LLVM

https://reviews.llvm.org/D57822

Files:
  lib/ObjectYAML/ELFYAML.cpp
  test/tools/obj2yaml/symbol-type.yaml
  test/tools/yaml2obj/symbol-type.yaml


Index: test/tools/yaml2obj/symbol-type.yaml
===================================================================
--- test/tools/yaml2obj/symbol-type.yaml
+++ test/tools/yaml2obj/symbol-type.yaml
@@ -0,0 +1,43 @@
+# RUN: yaml2obj %s > %t
+# RUN: llvm-readobj --symbols %t | FileCheck %s
+
+# CHECK: Name: notype
+# CHECK: Type: None
+# CHECK: Name: normal_type
+# CHECK: Type: Object
+# CHECK: Name: .text
+# CHECK: Type: Section
+# CHECK: Name: known_hex
+# CHECK: Type: Object
+# CHECK: Name: unknown_hex
+# CHECK: Type: 0xB
+# CHECK: Name: known_int
+# CHECK: Type: Object
+# CHECK: Name: unknown_int
+# CHECK: Type: 0xB
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_REL
+  Machine:         EM_X86_64
+Sections:
+  - Name: .text
+    Type: SHT_PROGBITS
+Symbols:
+  Global:
+    - Name: notype
+      Type: STT_NOTYPE
+    - Name: normal_type
+      Type: STT_OBJECT
+    - Name: .text
+      Type: STT_SECTION
+    - Name: known_hex
+      Type: 0x1
+    - Name: unknown_hex
+      Type: 0xb
+    - Name: known_int
+      Type: 1
+    - Name: unknown_int
+      Type: 11
Index: test/tools/obj2yaml/symbol-type.yaml
===================================================================
--- test/tools/obj2yaml/symbol-type.yaml
+++ test/tools/obj2yaml/symbol-type.yaml
@@ -0,0 +1,22 @@
+# RUN: yaml2obj %s > %t
+# RUN: obj2yaml %t | FileCheck %s
+
+# CHECK:      Symbols:
+# CHECK-NEXT:   Global:
+# CHECK-NEXT:     - Name: a_known_type
+# CHECK-NEXT:       Type: STT_OBJECT
+# CHECK-NEXT:     - Name: an_unknown_type
+# CHECK-NEXT:       Type: 0x07
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_REL
+  Machine:         EM_X86_64
+Symbols:
+  Global:
+    - Name: a_known_type
+      Type: STT_OBJECT
+    - Name: an_unknown_type
+      Type: 0x7
Index: lib/ObjectYAML/ELFYAML.cpp
===================================================================
--- lib/ObjectYAML/ELFYAML.cpp
+++ lib/ObjectYAML/ELFYAML.cpp
@@ -572,6 +572,7 @@
   ECase(STT_TLS);
   ECase(STT_GNU_IFUNC);
 #undef ECase
+  IO.enumFallback<Hex8>(Value);
 }
 
 void ScalarEnumerationTraits<ELFYAML::ELF_STV>::enumeration(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57822.185561.patch
Type: text/x-patch
Size: 2209 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190206/91f07c58/attachment.bin>


More information about the llvm-commits mailing list