what's difference between "relocatable link" and "final link"?

Simon Richter Simon.Richter@hogyros.de
Mon Jun 12 11:32:00 GMT 2006


Hello,

Huang, Chunhao schrieb:

> When I study the BFD library, I meet "relocatable link" and
> "final link" several times, but I can NOT find out the difference
> between them.

Basically, after a "relocatable" link, you have an object file that is 
similar to the input files, that is, it consists of multiple (in most 
cases zero-based) code blocks (sections) along with relocation (i.e. 
what to change if you move the code to another address) and symbol (i.e. 
how specific addresses are named) information. This format makes sense 
for further linking, but you would need a lot of postprocessing to 
actually get executable code. After a "final" link, the sections are 
concatenated into segments (this is what the loader cares about), and 
have absolute addresses in the virtual address space[1], and all symbols 
have been resolved and replaced by either their numerical value, or by a 
"dynamic symbol" if you have a (runtime) linker that supports shared 
libraries. After a final link, you can drop the symbol and relocation 
information at no harm, it is no longer needed (except for debugging).

Gee, somebody should document this. :-)

    Simon

[1] if there is no virtual address space, the output of a final link may 
still have relocation information, and the executable is relocated by 
the loader.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 307 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/binutils/attachments/20060612/b5db7021/attachment.sig>


More information about the Binutils mailing list