gcc链接选项,以查看为什么某些目标文件链接到二进制文件

dim*_*mba 8 linux linker gcc compilation ld

我有一些链接问题.

为了研究这个问题,我添加了-t linker flag(gcc -Wl,-t)来打印使用哪些库以及使用静态库中的哪些对象.

有一个静态库,在某些配置中使用一组目标文件,而在另一组配置中使用.

是否有任何方法(可能是ld标志)看到为什么特定对象(在目标文件中定义了什么以前未定义的符号)被链接到二进制和其他来自相同的静态库不是?

dim*_*mba 5

我一直在寻找的标志是-M,它将打印链接映射到标准输出。

从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.
Run Code Online (Sandbox Code Playgroud)

列表中的第二项是我一直在寻找的东西。