How does linker know which symbols should be resolved at runtime?
Asked Answered
C

3

14

How does linker know which symbols should be resolved at runtime? Particularly I'm interested what information shared object files carry that instruct linker to resolve symbols at runtime. How does the dynamic symbol resolution work at runtime, i.e. what executable will do to find the symbol and in case multiple symbols with the same name were defined which would be found?

What happens if the file was linked only statically, but then it's linked dynamically at run-time as part of a shared library? Which symbol will be used by the executable? In other words, is that possible to override symbols in an executable by linking those symbols into a shared library?

The platform in question is SUN OS.

Carrycarryall answered 5/10, 2010 at 12:59 Comment(1)
Every run-time is different. You have to be more specific about platform.Valero
G
3

Check out this article from Linux Journal. For more information -- perhaps specifically related to Windows, AIX, OSx, etc -- I would recommend the Wikipedia article on Linker (computing) and the references therein.

Gaseous answered 5/10, 2010 at 13:9 Comment(0)
D
4

Try the below link. I hope it answers your question

http://www.linuxjournal.com/article/6463

Dissipated answered 5/10, 2010 at 13:5 Comment(4)
:O) Beat me to it. I referenced the same article in my answer. Up-vote for speed.Gaseous
I actually use this article as an example for people starting with C++ programming and is quite effective.Dissipated
What happens if the file was linked only statically, but then it's linked dynamically at run-time as part of a shared library? Which symbol will be used by the executable? In other words, is that possible to override symbols in an executable by linking those symbols into a shared library?Carrycarryall
The library is only used to resolve symbols that have not been resolved in all the object files of the program. So, I believe static linkage will override.Dissipated
G
3

Check out this article from Linux Journal. For more information -- perhaps specifically related to Windows, AIX, OSx, etc -- I would recommend the Wikipedia article on Linker (computing) and the references therein.

Gaseous answered 5/10, 2010 at 13:9 Comment(0)
L
0

If a file is statically linked there is no run time resolution to speak of. If a shared object links to that same library either dynamically or statically, the version linked to the library will only effect code executed in the library. This can cause problems if you link to two different versions of the same library that are incompatible and shift data back and forth.

Lift answered 5/10, 2010 at 13:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.