]> granicus.if.org Git - llvm/commitdiff
[yaml2obj][obj2yaml] Remove section type range markers from allowed mappings and...
authorJames Henderson <jh7370@my.bristol.ac.uk>
Tue, 19 Feb 2019 16:22:21 +0000 (16:22 +0000)
committerJames Henderson <jh7370@my.bristol.ac.uk>
Tue, 19 Feb 2019 16:22:21 +0000 (16:22 +0000)
yaml2obj/obj2yaml previously supported SHT_LOOS, SHT_HIOS, and
SHT_LOPROC for section types. These are simply values that delineate a
range and don't really make sense as valid values. For example if a
section has type value 0x70000000, obj2yaml shouldn't print this value
as SHT_LOPROC. Additionally, this was missing the three other range
markers (SHT_HIPROC, SHT_LOUSER and SHT_HIUSER).

This change removes these three range markers. It also adds support for
specifying the type as an integer, to allow section types that LLVM
doesn't know about.

Reviewed by: grimar

Differential Revision: https://reviews.llvm.org/D58383

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354344 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ObjectYAML/ELFYAML.cpp
test/tools/obj2yaml/section-type.yaml [new file with mode: 0644]
test/tools/yaml2obj/section-type.yaml [new file with mode: 0644]

index 8460ad04cd07c948bbed105eeb819c6a29d96230..7c52a6c31e44093ba2fadb4d688362fc047703e0 100644 (file)
@@ -446,7 +446,6 @@ void ScalarEnumerationTraits<ELFYAML::ELF_SHT>::enumeration(
   ECase(SHT_GROUP);
   ECase(SHT_SYMTAB_SHNDX);
   ECase(SHT_RELR);
-  ECase(SHT_LOOS);
   ECase(SHT_ANDROID_REL);
   ECase(SHT_ANDROID_RELA);
   ECase(SHT_ANDROID_RELR);
@@ -459,8 +458,6 @@ void ScalarEnumerationTraits<ELFYAML::ELF_SHT>::enumeration(
   ECase(SHT_GNU_verdef);
   ECase(SHT_GNU_verneed);
   ECase(SHT_GNU_versym);
-  ECase(SHT_HIOS);
-  ECase(SHT_LOPROC);
   switch (Object->Header.Machine) {
   case ELF::EM_ARM:
     ECase(SHT_ARM_EXIDX);
@@ -485,6 +482,7 @@ void ScalarEnumerationTraits<ELFYAML::ELF_SHT>::enumeration(
     break;
   }
 #undef ECase
+  IO.enumFallback<Hex32>(Value);
 }
 
 void ScalarBitSetTraits<ELFYAML::ELF_PF>::bitset(IO &IO,
diff --git a/test/tools/obj2yaml/section-type.yaml b/test/tools/obj2yaml/section-type.yaml
new file mode 100644 (file)
index 0000000..ca054eb
--- /dev/null
@@ -0,0 +1,28 @@
+# RUN: yaml2obj %s -o %t
+# RUN: obj2yaml %t | FileCheck %s
+
+# CHECK:      Sections:
+# CHECK-NEXT:   - Name: known_type
+# CHECK-NEXT:     Type: SHT_PROGBITS
+# CHECK:        - Name: unknown_type
+# CHECK-NEXT:     Type: 0x0000ABCD
+# CHECK:        - Name: machine_specific
+# CHECK-NEXT:     Type: SHT_X86_64_UNWIND
+# CHECK:        - Name: unknown_machine_specific
+# CHECK-NEXT:     Type: 0x70000000
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name:  known_type
+    Type:  SHT_PROGBITS
+  - Name:  unknown_type
+    Type:  0xabcd
+  - Name:  machine_specific
+    Type:  SHT_X86_64_UNWIND
+  - Name:  unknown_machine_specific
+    Type:  0x70000000
diff --git a/test/tools/yaml2obj/section-type.yaml b/test/tools/yaml2obj/section-type.yaml
new file mode 100644 (file)
index 0000000..ad2edd9
--- /dev/null
@@ -0,0 +1,27 @@
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-readobj --sections %t | FileCheck %s
+
+# CHECK: Name: enum
+# CHECK: Type: SHT_PROGBITS
+# CHECK: Name: machine-specific
+# CHECK: Type: SHT_X86_64_UNWIND
+# CHECK: Name: hex
+# CHECK: Type: Unknown (0xABCD)
+# CHECK: Name: decimal
+# CHECK: Type: Unknown (0x4D2)
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name:  enum
+    Type:  SHT_PROGBITS
+  - Name:  machine-specific
+    Type:  SHT_X86_64_UNWIND
+  - Name:  hex
+    Type:  0xabcd
+  - Name:  decimal
+    Type:  1234