reducing number of relocations

Bruno Haible bruno@clisp.org
Tue Apr 14 22:15:40 GMT 2020


Andreas Schwab wrote:
> > As an application programmer, I don't really want to spend time minimizing
> > the number of relocations of a library or (now that -fPIE is in wide use)
> > of an executable. I wish GCC would offer attributes that make this task
> > easier.
> 
> See -fsection-anchors.

Thanks. Unfortunately this option has no effect for some CPUs [1], and in
particular not for x86_64.

Among the major targets, it seems to be only supported for alpha, arm, arm64,
mips, powerpc, riscv.

And on a platform where it is supported, it has no effect in the given case:

$ mips64-linux-gnuabi64-gcc-5 -O2 -c -Wall foo.c -fsection-anchors
$ mips64-linux-gnuabi64-readelf -r foo.o

shows as many relocations as

$ mips64-linux-gnuabi64-gcc-5 -O2 -c -Wall foo.c
$ mips64-linux-gnuabi64-readelf -r foo.o

Bruno

[1] https://gcc.gnu.org/onlinedocs/gcc-9.3.0/gcc/Optimize-Options.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.c
Type: text/x-csrc
Size: 3741 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20200415/37df962a/attachment.bin>


More information about the Binutils mailing list