Weird object file link issue
Tom Kacvinsky
tkacvins@gmail.com
Tue Nov 22 20:16:50 GMT 2022
Hi,
Using binutils 2.39 and GCC 12.1, built from source on CentOS 7
This is a really weird one. I have a simple "hello world" C program.
When I link this against a third party object file foo.o, symbols from
foo.o are in my hello world main program, even though the main
program does not have any symbol dependencies from foo.o.
Sample link driver:
gcc -fuse-ld=gold -o bar bar.c foo.o
I would have thought that foo.o would just have been discarded from the
final link, but using -Wl,--trace or -Wl,-Map=link shows it is indeed
used in the final link. This is happening with both the gold and bfd
linkers. Any ideas on what I should do to diagnose this? Completely new
to me - I have always seen unused object files and archives discarded
from the file link.
I'd like to file an issue with the third party company I am working with,
but
I want to go to them with concrete data as to why this is happening, in the
hopes they can fix it.
Yes, I know I can just drop the object file from the link line as it is not
really needed. That poses a problem from how we build with cmake.
That and I am curious as to the black magic that is causing this.
Thanks,
Tom
More information about the Binutils
mailing list