[LLVMdev] Generate ELF in x86 with RELA relocations

Tim Northover t.p.northover at gmail.com
Thu Feb 6 02:22:12 PST 2014


Hi Yiannis,

> I 'd like to generate an ELF object file in x86 that uses RELA instead
> of REL for relocations. The reason I want that is because I have a
> custom loader that only works with Elf32_Rela. Is there any flag in LLVM
> to force that relocation scheme?
>
> Is this demand reasonable? The only thing that I managed to dig out of
> Google was [1] that states, among other things:

It's not controlled by a flag in LLVM at the moment. Each target picks
.rel or .rela based on the ABIs it supports (the key decision is made
in X86ELFObjectWriter.cpp, in the HasRelocationAddend setting).

Adding support for .rela is probably much easier than for .rel (which
would definitely need real compiler support), but I'd still be
slightly wary of assuming everything will just work. The linker might
well decide to rewrite the file with .rel for example, or some odd
corner case may rely on non-idempotency of .rel relocations (I
sincerely hope not!).

Cheers.

Tim.



More information about the llvm-dev mailing list