On Sunday, 15 April 2012 at 23:16:10 UTC, Walter Bright wrote:
On 4/14/2012 9:23 PM, Vladimir Panteleev wrote:
On Saturday, 14 April 2012 at 19:41:22 UTC, Walter Bright
wrote:
On 4/14/2012 2:40 AM, Vladimir Panteleev wrote:
So object files take priority over library files?
Yes, because object files are NOT searched. They are
incorporated. Libraries
get recursively searched for unresolved symbols.
Right, I understand the case when you declare an assert
handler and use it in
the same module (thus, object file) - then, an external is not
used and for PIC
there might not even be a relocation record. However, if the
assert statement
and my assert handler are in different modules, how does the
linker know not to
search the libraries without first searching other object
files?
?? The linker takes the list of object files supplied on the
command line and incorporates them. Then it looks in the
library for any unresolved symbols.
The linker does NOT "search" object files passed on the command
line. It ALWAYS simply incorporates them.
It is far far simpler than you are imagining it is. A linker is
a very simple, stupid program.
No, I think I am imagining it right, but we have a
misunderstanding of terminology used.
If an object file uses a symbol not present in the object file,
the linker doesn't inherently know the address of that symbol,
and can't write its address without first looking at all other
object files (and possibly libraries) to find 1) in which object
file it is, and 2) its offset within that object file. Assuming
the linker builds a hash table of sorts for all symbols in all
object files, I suppose the word "search" doesn't really apply,
since you don't search a hash table.
Anyway, thanks, I think you answered my question.