Adding Position Independent Code support
David Malcolm
dmalcolm@redhat.com
Thu Jan 1 00:00:00 GMT 2015
On Thu, 2015-04-23 at 20:10 -0700, Mukul Sabharwal wrote:
> I'm not familiar with GCC internals at all, so I maybe I proposing
> something drastic, but it would be a great feature to have libgccjit
> be able to generate Position Independent Code.
>
> In my language project, I often compile and cache code, re-load parts
> of the program from a different address (it's a long story ...) and
> have to re-generate old code to get fixups, it would be nice to be
> able to ask GCC to generate PIC for me, which I can manage myself.
>
> What do others think? A great feature? Or no-one will ever use it?
I don't think it's documented anywhere, but libgccjit should already be
generating position-independent code.
Specifically, the code is generated with the equivalent of the "-fPIC"
command-line flag [1]
So I hope that covers the kinds of use-cases you're thinking of... or
did you run into an issue that suggested it wasn't PIC?
Dave
[1] gcc/jit/jit-playback.c: playback::context::make_fake_args is where
"-fPIC" is added to the simulated command-line arguments.
More information about the Jit
mailing list