Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 353
Leonid Avatar asked Oct 05 '10 12:10

Leonid


People also ask

How do linkers resolve symbols?

The linker resolves symbol references by associating each reference with exactly one symbol definition from the symbol tables of its input relocatable object files. Symbol resolution is straightforward for references to local symbols that are defined in the same module as the reference.

Which step does the linker perform after it successfully assigns a reference to each symbol in the code?

Symbol resolution ↑top The linker resolves symbol references by associating each ref with exactly one symbol definition from the symbol tables of its input relocatable obj files. Symbol resolution is easy for references to local variables that are defined in the same module as the ref.

What is meant by symbol resolution in compiler design?

Symbol resolution, in this context, is, once a program has been loaded into memory, assigning proper addresses to all external entities it refers to. This means changing every position in the loaded program where a reference to an external symbol was made.

What is a common symbol linker?

When common symbols are used, the linker will merge all symbols of the same name into a single memory location, the size of which is the largest type of the individual common symbol definitions. For example, if fileA. c defines an uninitialized 32-bit integer myint, and fileB.


1 Answers

Try the below link. I hope it answers your question

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

like image 148
Vaibhav Avatar answered Sep 27 '22 16:09

Vaibhav