This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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. :-)


[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.

Attachment: signature.asc
Description: OpenPGP digital signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]