* what's difference between "relocatable link" and "final link"?
@ 2006-06-11 8:39 Huang, Chunhao
2006-06-12 9:19 ` Ian Lance Taylor
2006-06-12 11:32 ` Simon Richter
0 siblings, 2 replies; 5+ messages in thread
From: Huang, Chunhao @ 2006-06-11 8:39 UTC (permalink / raw)
To: binutils; +Cc: Huang, Chunhao
Greetings,
This is chunhao.
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. My rough comprehension is that "relocatable link"
done by assembler, which is something like parsing the local
symbols in sections. while "final link" done by linker.
But I find such sentence in bfdint.text:
"Make sure you clearly understand the operations the linker must
perform during a relocatable link and during a final link."
Which means that both "relocatable link" and "final link" are
performed by linker. So my orignal comprehension is not correct.
Is there any guy who can provide me the difference between them?
If you can provide me some simple examples in ARM or x86, that's
great.
Thanks a lot.
Best Regards
Chunhao
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: what's difference between "relocatable link" and "final link"?
2006-06-11 8:39 what's difference between "relocatable link" and "final link"? Huang, Chunhao
@ 2006-06-12 9:19 ` Ian Lance Taylor
2006-06-12 11:11 ` Nick Clifton
2006-06-12 11:32 ` Simon Richter
1 sibling, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2006-06-12 9:19 UTC (permalink / raw)
To: Huang, Chunhao; +Cc: binutils
"Huang, Chunhao" <Chunhao.Huang@sony.com.cn> writes:
> 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. My rough comprehension is that "relocatable link"
> done by assembler, which is something like parsing the local
> symbols in sections. while "final link" done by linker.
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.
Ian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: what's difference between "relocatable link" and "final link"?
2006-06-12 9:19 ` Ian Lance Taylor
@ 2006-06-12 11:11 ` Nick Clifton
0 siblings, 0 replies; 5+ messages in thread
From: Nick Clifton @ 2006-06-12 11:11 UTC (permalink / raw)
To: Chunhao.Huang; +Cc: binutils
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: what's difference between "relocatable link" and "final link"?
2006-06-11 8:39 what's difference between "relocatable link" and "final link"? Huang, Chunhao
2006-06-12 9:19 ` Ian Lance Taylor
@ 2006-06-12 11:32 ` Simon Richter
1 sibling, 0 replies; 5+ messages in thread
From: Simon Richter @ 2006-06-12 11:32 UTC (permalink / raw)
To: Huang, Chunhao; +Cc: binutils
[-- Attachment #1: Type: text/plain, Size: 1318 bytes --]
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.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 307 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: what's difference between "relocatable link" and "final link"?
@ 2006-06-13 2:58 Huang, Chunhao
0 siblings, 0 replies; 5+ messages in thread
From: Huang, Chunhao @ 2006-06-13 2:58 UTC (permalink / raw)
To: Ian Lance Taylor, nickc, Simon Richter; +Cc: binutils, Huang, Chunhao
Dear Ian, Nick, and Simon:
Thank you very much for your information provided, I can catch the
difference between these 2 kinds of link now. :-)
If I need more help from you, I will send you next time.
Best Regards
Chunhao
> -----Original Message-----
> From: Simon Richter [mailto:Simon.Richter@hogyros.de]
> Sent: Monday, June 12, 2006 7:11 PM
> To: Huang, Chunhao
> Cc: binutils@sourceware.org
> Subject: Re: what's difference between "relocatable link" and "final
link"?
>
> 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).
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-06-13 1:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-11 8:39 what's difference between "relocatable link" and "final link"? Huang, Chunhao
2006-06-12 9:19 ` Ian Lance Taylor
2006-06-12 11:11 ` Nick Clifton
2006-06-12 11:32 ` Simon Richter
2006-06-13 2:58 Huang, Chunhao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).