[LLVMdev] [MCJIT] Why does it produce non-PIC ELF code?

Yuri yuri at rawbw.com
Fri Jul 8 10:25:14 PDT 2011

ELF that MCJIT writes on x86_64 has relocations in it. Particularly, 
R_X86_64_PC32 relocations are used for the sections .gcc_except_table 
and .eh_frame related to exception processing.
I am not sure where is general documentation on relocation types, 
including R_X86_64_PC32. Looks like it's nowhere to be found on the web.
But 32-bit relocation can't be used in 64-bit code since it causes 
overflows in general case. And particularly in case of .gcc_except_table 
and .eh_frame in MCJIT-printed ELF.

So it this a bug, or I just miss something?

Another question is: Why PIC code instead isn't written by MCJIT? When I 
look at the code, it looks like the variable IsPCRel is used to 
determine if code is non-PIC, and this variable is calculated by 
isFixupKindPCRel based on some fixup types.
Is there a way to make all code PIC?


More information about the llvm-dev mailing list