c 库链接到什么点
假设我在内存调试程序电围栏中重新定义了 malloc。电围栏表示必须将库与 gcc -g -Wall -Wstrict-prototypes -lefence test.c 链接起来。所以我的理解是,如果 gcc 在任何库中都找不到符号,那么它会查找 C 库。这种理解正确吗?
Let's say I redefine malloc e.g. in a memory debugging program electric fence. electric fence says that one must link the library with the gcc -g -Wall -Wstrict-prototypes -lefence test.c. So my understanding is that if gcc does not find the symbols in any of the libraries then it looks into the C libraries. Is this understanding correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,要了解 gcc 实际上在做什么,以及它如何启动链接器 ld 来完成链接的实际工作,您可以传递
-v
标记为gcc
。Yes, and to understand what
gcc
is actually doing, and how does it starts the linkerld
which does the real work of linking, you can pass the-v
flag togcc
.我认为你是对的:链接器尝试首先使用显式作为参数传递的库来解析符号,然后在 C 标准库中查找符号。
I think you are correct: the linker tries to resolve symbols using the libraries explicitly passed as parameters first, then it's looking up symbols in the C standard libraries.