[LLVMdev] Generating PIC object files from the LLVM API

Josh Klontz josh.klontz at gmail.com
Tue Jan 7 12:46:56 PST 2014


I'm trying to add static code generation capabilities to my MCJIT compiler
on LLVM 3.4. To that extent I have:

    targetMachine = engineBuilder.selectTarget();
    // ...
    targetMachine->addPassesToEmitFile(<...>);

At first glance this appears to work, but when linking the object file I
get the warning:

    ld: warning: PIE disabled. Absolute addressing (perhaps
-mdynamic-no-pic) not allowed in code signed PIE, but used in <...>. To fix
this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie

This novice developer thought that the solution would be:

    engineBuilder.setRelocationModel(Reloc::PIC_);

However this has no diff in the resulting object file. Have I overlooked
something simple? Is this feature not supported and I need to link with
-Wl,-no_pie?

Thanks in advance!

v/r
Josh

TL;DR: engineBuilder.setRelocationModel(Reloc::PIC_) appears to have no
effect when generating object file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140107/7de9e98b/attachment.html>


More information about the llvm-dev mailing list