I'm building a staticlib crate with a custom target using xargo for managing the sysroot (rustc 1.53.0-nightly). The generated code is PIC. The generated binary (a .a with .o inside) uses GOTPCREL instead of generating a PLT. How can I revert back to generating a PIE? See https://internals.rust-lang.org/t/function-calls-plt-vs-gotpcrel/8909
The target I'm linking against does not support GOTPCREL relocations, this is why I need a PLT.
I tried this in the target json (unsuccesfully):
It seems that irrespective of the needs-plt option, the .o file corresponding to my crate has no GOTPCREL relocs, which is what I want. Those relocs appear in the .o files associated with libcore. Is there a way I can control xargo to compile the sysroot with PLT? Should I not use xargo and build it myself?.
Ultimately I want to extract the .o files and link them in a single ld -relocatable *.o -o final.o, the final.o should not have GOTPCREL relocations, instead, a PLT. Thanks.