开发者

How does compiler(gcc) know whether a function is to be dynamically linked or not?

开发者 https://www.devze.com 2023-02-22 00:57 出处:网络
For example,printf is dynamically linked. But how does the compiler(g开发者_如何学编程cc) know that?gcc doesn\'t know that. It knows there is a function printf and it knows how to call it, but the ob

For example,printf is dynamically linked.

But how does the compiler(g开发者_如何学编程cc) know that?


gcc doesn't know that. It knows there is a function printf and it knows how to call it, but the object file it generates contains a call to an unresolved symbol.

The symbol is then resolved by the linker, which is given all your object files and libraries. The linker finds the symbol printf in a library, and after its combined all the relevant modules, it updates the unresolved calls.

0

精彩评论

暂无评论...
验证码 换一张
取 消