I have an libfoo.a
which contains _start
and all required symbols for an executable. ld.bfd -o foo libfoo.a
works smoothly in my case. However, ld.gold -o foo libfoo.a
fails silently generating an executable with no symbols from libfoo.a
. Creating an empty a.o
and link it with ld.gold -o foo a.o libfoo.a
works.
I was wondering is there any way to directly link a static library into an executable using ld.gold
without creating a redundant empty object files?
You can specify the entry symbol explicitly with the -e _start
option, and the linker will use that to decide that it needs to load the object that defines it.
Unfortunately, gold will not use the implicit start symbol to load an object from the archive library.