[LLVMdev] Relocation issue with jump tables in ELF object files on X86_64

Eli Friedman eli.friedman at gmail.com
Thu Jun 17 13:05:45 PDT 2010


On Thu, Jun 17, 2010 at 12:38 PM, Smith, Tim <tim at bioware.com> wrote:
> (llvm 2.6)
>
>
>
> We have an application where we are using LLVM to generate ELF object files
> for X86_64.   At runtime we load these objects files into memory using our
> own ELF loader.
>
>
>
> Everything is working except for the jump tables.
>
>
>
> The ELF emitter is generating JMPQ instructions using
> X86::reloc_absolute_word_sext relocations which we are unable to patch to
> the jump table in the .rodata segment unless we force that segment to load
> in the low 2GB of the address range.  Currently we just request pages of
> memory from the OS and that memory is much deeper in the address space.
>
>
>
> Is there proper way to patch the address or instruction (ewww) or have the
> ELF emitter generate a RIP based instruction.  If a real linker doesn’t
> patch the instruction, does the ELF loader always try to load .rodata
> segments in the low 2GB of memory regardless of if it is from the main image
> or from a shared library?
>
>
>
> Thanks for any help.

Perhaps you're missing a call to TargetMachine::setRelocationModel?
It sounds like you need PIC codegen.

-Eli




More information about the llvm-dev mailing list