I'm using Gold linker from binutils-2.24 to link an application for target: i686-pc-linux-gnu .
I got an out of virtual memory error when I ran Gold on my i686-pc-linux-gnu machine, so I built it on a x86_64-linux-gnu host (to get more virtual memory), and I'm running it on this machine as well, but I'm using it to link my application for target: i686-pc-linux-gnu.
The first link is successful - I don't have an executable yet - so Gold reverts to --incremental-full and I get a working executable which I can run successfully on my i686-pc-linux-gnu machine:
gold-ld -o stam32 -dynamic-linker /lib/ld-linux.so.2 -L/usr/lib32 /usr/lib32/crti.o /usr/lib32/crtn.o /usr/lib32/crt1.o main.o try.o -lc --incremental
*stam32: stat: No such file or directory linking with --incremental-full*
The second link fails with the following error:
../objs-binutils-2.24/gold/ld -o stam32 -dynamic-linker /lib/ld-linux.so.2 -L/usr/lib32 /usr/lib32/crti.o /usr/lib32/crtn.o /usr/lib32/crt1.o main.o try.o -lc --incremental
../objs-binutils-2.24/gold/ld: internal error in init_got_plt_for_update, at ../../binutils-2.24/gold/target.h:949
I looked at the source code and found that "init_got_plt_for_update" is implemented only for x86_64 and tilegx. For other targets init_got_plt_for_update simply calls gold_unreachable() which exits gold with an error.
On the other hand - there's a whole lecture on Gold's incremental linking (https://video.linux.com/videos/incremental-linking-with-gold) and i386 is specifically mentioned there, as a Gold supported target, and the speaker does not mention any limitations regarding the use of --incremental flag with i386 targets (and as far as I know i686-pc-linux-gnu is an i386 target).
So does anyone know why my incremental linking fails?
Thanks in advance, Galit Keret
Asked and answered in binutils mailing list:
There's currently no incremental linking support for gold's i386 target.