This is the mail archive of the binutils@sourceware.org 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"?


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.


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