Question about archive search behavior vs. --defsym

Mark Mitchell mark@codesourcery.com
Thu Sep 9 14:53:00 GMT 2010


On 9/9/2010 7:47 AM, H.J. Lu wrote:

> Gold behaves the same. I am not sure if it is a bug. --defsym or
> assignment in linker script overwrites any symbols, which may
> be defined in object, archive or DSO.

I think a straightforward reading of the --defsym documentation (or an
assignment in a linker script, which is equivalent) says that you're
defining a symbol.  Objects are only included from archives if they
define a currently undefined symbol.  Why would you pull an object from
an archive if the symbol is already defined?

A practical example, of course, is not --defsym=f=4, but rather
something like --defsym=f=g.  Why would we include an archive defining
"f" in that case, which will just include code in the program that can't
e called, since the linker will resolve all references to "f" to "g"?
And if the object we include from the archive has other undefined
references, we will include more code to satisfy those references,
making the program much bigger than it needs to be.

Can you justify the current behavior as useful in some way?

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713



More information about the Binutils mailing list