On Sun, Dec 27, 2020 at 12:23:48PM +0300, Alexander Monakov wrote: > On Sat, 26 Dec 2020, Andrew Pinski via Gcc wrote: > > > Two things, this should really be on the binutils mailing list rather > > than the GCC mailing list. Second you can't generate a flat binary > > which has a GOT as it requires relocations and there is no way to > > represent relocations in flat binary. So you need to use non PIE or > > still use elf format. > > PIE requires the use of the GOT. > > You can annotate 'func' in prog.c with __attribute__((visibility("hidden"))), > then GCC should not use a GOT relocation for the reference. Note that you do > need to set visibility via the attribute or the pragma, not the command-line > flag -fvisibility=hidden, because the flag does not affect declarations. > > (this is for x86-64; as 32-bit x86 lack eip-relative addressing, GCC uses > GOT relocation for taking the address anyway; it will work if the linker > places an "imaginary" empty GOT somewhere, just to have a stable anchor > against which to resolve GOTOFF relocations) > > Please consider filing a bug against binutils on sourceware.org, this looks > like a QoI issue in the linker: it should emit a diagnostic rather than > non-sensical code. > > Alexander
Thanks for the input Alexander. I've gone ahead and filed https://sourceware.org/bugzilla/show_bug.cgi?id=27119 against binutils. Cheers, Rhys