Gcc link to find out why some object file is associated with binary

I have a problem with links.

To investigate the problem, I add the linker flag -t (gcc -Wl, -t) to print which libraries are used and which objects from the static libraries are used.

There is one static library, which in one configuration uses one set of object files and in another different set.

Is there any way (possibly ld ) to find out why a particular object (which was previously designated undefined in the object file) is associated with a binary and another from the same static library is not?

+8
gcc linux compilation linker ld
source share
2 answers

The flag I was looking for is -M , which prints a map of links to standard output.

From ld (1):

-M --print-map Print a link map to the standard output. A link map provides information about the link, including the following: ยท Where object files are mapped into memory. ยท How common symbols are allocated. ยท All archive members included in the link, with a mention of the symbol which caused the archive member to be brought in. ยท The values assigned to symbols. 

The second item on the list is what I was looking for.

+4
source share

Since you added generosity more than a month after your last change to the question and answer, I assume that you do not like your own answer.

As I understand it, you are trying to figure out which object (A) is binding to another object (B).

If you are compiling / linking without B (i.e. not on the command line), then you should get error messages telling you why it is necessary, what will refer to A.

If B is in a library, you may have to create a special version of this library that does not include B.

+1
source share

All Articles