Yiannis Tsiouris
2014-Feb-04 21:51 UTC
[LLVMdev] Generate ELF in x86 with RELA relocations
Hi guys, 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:> "REL relocations thus take 2 words of storage, and RELA relocations, > 3. On x86, the ELF ABI *only* uses REL relocations, and words are 32 > bits, making each relocation take 8 bytes ; on x86-64, the ELF ABI > only uses RELA relocations, and words are 64 bits, thus making each > relocation take 24 bytes, 3 times that of x86 relocations. On ARM, > both may be used, but apparently the compiler and the linker only use > REL relocations."However, I am not convinced that I should start hacking on the loader, yet! :-) Cheers, Yiannis [1]: http://glandium.org/blog/?m=201011 -- Yiannis Tsiouris Ph.D. student, Software Engineering Laboratory, National Technical University of Athens WWW: http://www.softlab.ntua.gr/~gtsiour -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 259 bytes Desc: OpenPGP digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140204/02aec7a0/attachment.sig>
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.