[PATCH] [yaml2obj] ELF Relocations Support

Simon Atanasyan simon at atanasyan.com
Mon Apr 7 13:39:27 PDT 2014



================
Comment at: lib/Object/ELFYAML.cpp:339-379
@@ +338,43 @@
+    IO &IO, ELFYAML::ELF_REL &Value) {
+#define ECase(X) IO.enumCase(Value, #X, ELF::X);
+  // X86_64
+  ECase(R_X86_64_NONE)
+  ECase(R_X86_64_64)
+  ECase(R_X86_64_PC32)
+  ECase(R_X86_64_GOT32)
+  ECase(R_X86_64_PLT32)
+  ECase(R_X86_64_COPY)
+  ECase(R_X86_64_GLOB_DAT)
+  ECase(R_X86_64_JUMP_SLOT)
+  ECase(R_X86_64_RELATIVE)
+  ECase(R_X86_64_GOTPCREL)
+  ECase(R_X86_64_32)
+  ECase(R_X86_64_32S)
+  ECase(R_X86_64_16)
+  ECase(R_X86_64_PC16)
+  ECase(R_X86_64_8)
+  ECase(R_X86_64_PC8)
+  ECase(R_X86_64_DTPMOD64)
+  ECase(R_X86_64_DTPOFF64)
+  ECase(R_X86_64_TPOFF64)
+  ECase(R_X86_64_TLSGD)
+  ECase(R_X86_64_TLSLD)
+  ECase(R_X86_64_DTPOFF32)
+  ECase(R_X86_64_GOTTPOFF)
+  ECase(R_X86_64_TPOFF32)
+  ECase(R_X86_64_PC64)
+  ECase(R_X86_64_GOTOFF64)
+  ECase(R_X86_64_GOTPC32)
+  ECase(R_X86_64_GOT64)
+  ECase(R_X86_64_GOTPCREL64)
+  ECase(R_X86_64_GOTPC64)
+  ECase(R_X86_64_GOTPLT64)
+  ECase(R_X86_64_PLTOFF64)
+  ECase(R_X86_64_SIZE32)
+  ECase(R_X86_64_SIZE64)
+  ECase(R_X86_64_GOTPC32_TLSDESC)
+  ECase(R_X86_64_TLSDESC_CALL)
+  ECase(R_X86_64_TLSDESC)
+  ECase(R_X86_64_IRELATIVE)
+  // MIPS
+  ECase(R_MIPS_NONE)
----------------
Shankar Kalpathi Easwaran wrote:
> Simon Atanasyan wrote:
> > Shankar Kalpathi Easwaran wrote:
> > > will this switch become too long ? also I think some of the relocation values might overlap too.
> > # Yes, the switch is long. But I cannot figure out how and why do we need to leave only subset of X86_64 relocations here.
> > # All these relocation types are unique constants. But in general `llvm::yaml::Input::matchEnumScalar` and `llvm::yaml::Output::matchEnumScalar` methods accept overlapped constants. In case of a YAML file reading that allow to use different names for the same constant. In case of YAML file writing, we write out the first name matched to the numerical code.
> should the architecture be specified as a namespace too like how its with lld ?
Ah, now I probably see the point. This code is not ready for writing yaml file indeed. To make this routine better we need to check current target architecture and select an appropriate set of relocation type constants. Unfortunately now we cannot test this approach because the `obj2yaml` tool does not handle ELF files. That is why I keep this function simple.

Anyway I will look at this function once again. Maybe I will be able to add some target checks and cover them by tests even now.


http://reviews.llvm.org/D3302






More information about the llvm-commits mailing list