]> granicus.if.org Git - llvm/commitdiff
[YAML] - Teach yaml2obj/obj2yaml to work with numeric relocation values.
authorGeorge Rimar <grimar@accesssoftek.com>
Fri, 30 Jun 2017 10:31:03 +0000 (10:31 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Fri, 30 Jun 2017 10:31:03 +0000 (10:31 +0000)
That may be useful if we want to produce or parse object containing
broken relocation values using yaml2obj/obj2yaml.

Previously that was impossible because only enum values were parsed
correctly, this patch allows to put any numeric value as a
relocation type.

Differential revision: https://reviews.llvm.org/D34758

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

lib/ObjectYAML/ELFYAML.cpp
test/Object/X86/yaml-elf-x86-rel-broken.yaml [new file with mode: 0644]

index dbd5498e003d2de54c501caf3e079a9903a14a0d..8578997fe579b57852b3cd963b1942e88c92c5b0 100644 (file)
@@ -542,6 +542,7 @@ void ScalarEnumerationTraits<ELFYAML::ELF_REL>::enumeration(
     llvm_unreachable("Unsupported architecture");
   }
 #undef ELF_RELOC
+  IO.enumFallback<Hex32>(Value);
 }
 
 void ScalarEnumerationTraits<ELFYAML::MIPS_AFL_REG>::enumeration(
diff --git a/test/Object/X86/yaml-elf-x86-rel-broken.yaml b/test/Object/X86/yaml-elf-x86-rel-broken.yaml
new file mode 100644 (file)
index 0000000..edd5dbc
--- /dev/null
@@ -0,0 +1,29 @@
+# RUN: yaml2obj %s > %t
+# RUN: obj2yaml %t | FileCheck %s
+
+# CHECK:       Relocations:
+# CHECK-NEXT:    - Offset:
+# CHECK-NEXT:      Symbol:
+# CHECK-NEXT:      Type: 0x000000FF
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS32
+  Data:            ELFDATA2LSB
+  Type:            ET_REL
+  Machine:         EM_386
+Sections:
+  - Type:            SHT_PROGBITS
+    Name:            .text
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:    0x04
+    Content:         0000000000000000
+  - Type:            SHT_REL
+    Name:            .rel.text
+    Link:            .symtab
+    Info:            .text
+    AddressAlign:    0x04
+    Relocations:
+      - Offset:          0
+        Symbol:          main
+        Type:            0xFF