[LLVMdev] Generating PIC object files from the LLVM API
t.p.northover at gmail.com
Wed Jan 8 00:22:05 PST 2014
> This novice developer thought that the solution would be:
Hmm. That's exactly what I'd expect too. I don't suppose you're
calling setRelocationModel after selectTarget or something odd like
The only other wrinkle I see is that COFF targets (only Windows, I
believe) don't seem to support PIC yet (from a very cursory reading of
X86TargetMachine.cpp). You seem to be using ld so this is a long shot,
but are you trying to use a COFF triple?
Another possibility (which I assume you've checked) is that the
absolute relocations might not be coming from a bog-standard
addressing situation that -fPIC would fix. I'd take a quick look at
the exact section and function ld is telling you about to make sure
there's nothing odd going on there.
If neither of those apply, I'd start delving into a debugger: put a
break-point on X86TargetMachine's constructor and see where the value
for the Reloc::Model comes from (and whether it is actually PIC).
More information about the llvm-dev