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

Nick Clifton nickc@redhat.com
Mon Jun 12 11:11:00 GMT 2006


Hi Chunhao,

> A relocateable link is what the linker does when you use the -r
> option.
> 
> A final link is what the linker does when you do not use the -r
> option.

To expand on Ian's answer, a relocatable link is one where only some of 
the relocations in the input files are resolved.  Any relocations that 
cannot be resolved are preserved and recorded in the output file.

A final link is one where all(1) of the relocations in the input files 
are resolved.  If a relocation cannot be resolved the linker will 
produce an error message.

The purpose of a relocatable link is to create an object file where some 
of the relocation work has already been done.  Thus when this file is 
included in a final link, the linker will take less time to complete its 
task.

Cheers
   Nick

(1) Really we are talking about static relocations here.  Dynamic 
relocations (against symbols in dynamic libraries) are not completely 
rresolved by the linker even during a final link.  They have to be 
resolved by the dynamic loader when the executable starts running.



More information about the Binutils mailing list