[llvm] r306814 - [YAML] - Teach yaml2obj/obj2yaml to work with numeric relocation values.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 30 03:31:03 PDT 2017
Author: grimar
Date: Fri Jun 30 03:31:03 2017
New Revision: 306814
URL: http://llvm.org/viewvc/llvm-project?rev=306814&view=rev
Log:
[YAML] - Teach yaml2obj/obj2yaml to work with numeric relocation values.
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
Added:
llvm/trunk/test/Object/X86/yaml-elf-x86-rel-broken.yaml
Modified:
llvm/trunk/lib/ObjectYAML/ELFYAML.cpp
Modified: llvm/trunk/lib/ObjectYAML/ELFYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/ELFYAML.cpp?rev=306814&r1=306813&r2=306814&view=diff
==============================================================================
--- llvm/trunk/lib/ObjectYAML/ELFYAML.cpp (original)
+++ llvm/trunk/lib/ObjectYAML/ELFYAML.cpp Fri Jun 30 03:31:03 2017
@@ -542,6 +542,7 @@ void ScalarEnumerationTraits<ELFYAML::EL
llvm_unreachable("Unsupported architecture");
}
#undef ELF_RELOC
+ IO.enumFallback<Hex32>(Value);
}
void ScalarEnumerationTraits<ELFYAML::MIPS_AFL_REG>::enumeration(
Added: llvm/trunk/test/Object/X86/yaml-elf-x86-rel-broken.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/X86/yaml-elf-x86-rel-broken.yaml?rev=306814&view=auto
==============================================================================
--- llvm/trunk/test/Object/X86/yaml-elf-x86-rel-broken.yaml (added)
+++ llvm/trunk/test/Object/X86/yaml-elf-x86-rel-broken.yaml Fri Jun 30 03:31:03 2017
@@ -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
More information about the llvm-commits
mailing list