[LLVMdev] "-relocation-model=static" does not work in llc compiler ?
Tim Northover
t.p.northover at gmail.com
Wed Nov 6 10:37:03 PST 2013
Hi Pengcheng,
> When I compile code using llc with options " -relocation-model=static", the generated code still has
> relative addressing using *rip* frame pointer. May I know how to get rid of frame pointer and totally
> using absolute addressing ?
>
> E.g.
> callq *addr(%rip).
> Here *addr* is a global variable, and I want the global address shows up here,
> instead of relative addressing.
> In this sense, can we say " -relocation-model=static" doesn't work ?
I think you may be misinterpreting "static". It doesn't mean "only use
absolute relocations" but rather "you don't *have* to use
position-independent relocations" (as PIC requires to make shared
libraries work).
In this case, the default ("small") code model in x86-64 guarantees
that all code and data will be in the low 2GB of the address space so
it's more efficient for the compiler to use PC-relative addressing
anyway.
If you also give "-code-model=large" then LLVM won't assume that
"addr" is nearby so it'll use a movabsq with a static relocation.
Cheers.
Tim.
More information about the llvm-dev
mailing list