collect2.exe 有什么作用?

2022-01-11 00:00:00 gcc c linker c++ ld

当我检查 gcc -v -o proggy.exe proggy.o 生成的代码时,我发现命令行扩展为一大堆库选项和库,所有这些都使用 collect2.exe 链接.ld.exe怎么了?为什么我看不到?有人可以向我解释一下 collect2.exe 的作用吗?

When I examine the code generated by gcc -v -o proggy.exe proggy.o I find that the command line expands into a large bunch of library options and libraries, all of which are linked using collect2.exe. What happened to ld.exe? Why don't I see that? Can someone explain to me what collect2.exe does?

推荐答案

collect2 是一个实用程序,用于生成构造函数表,__main(自动生成的函数在 main 的开头调用)依赖于.通常你看不到它,因为它在文件系统上被命名为 ld,然后它又调用了真正的 ld(通常称为 real-ld,尽管 collect2 会检查一个寻找它的地方的数量)

collect2 is a utility used to generate a table of constructors that __main (an auto-generated function called at the beginning of main) depends on. Normally you don't see it because it's named ld on the file system, and it in turn calls the real ld (typically called real-ld, although collect2 will check a number of places looking for it)

相关文章