This is the mail archive of the binutils@sources.redhat.com 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]

[PATCH] Emit undefined weak symbols only when used


http://gcc.gnu.org/ml/gcc-patches/2001-10/msg01382.html:

On Fri, Oct 26, 2001 at 09:55:17AM -0700, Richard Henderson wrote:
> On Fri, Oct 26, 2001 at 11:01:03AM +0200, Jakub Jelinek wrote:
> > Every weak prototype, even if it is not used at all, adds an entry to
> > .dynsym and symbol name to .dynstr...
> 
> Seems like this is something that ought to get fixed in 
> the assembler.  We shouldn't add the symbol to the table
> unless it is used elsewhere.
> 

Here is a patch to implement that.
gas will not emit foo symbol for input like:
.weak foo
but will for either:
.weak foo
foo:
or
.weak foo
movl foo, %eax
, the first one will handle .protected/.hidden/.internal the same way.
Note that Sun assembler will always emit the weak symbols (current gas
behaviour), but during linking if the same symbol is weak undef in one file
and non-weak undef in another file, it will be non-weak, so the only
difference is if foo is actually not used anywhere for anything, in which
case it just pollutes .symtab/.dynsymtab and e.g. in case of
__register_frame_info_bases () __attribute__((weak)); which is never used
causes binaries/libraries to require GCC_3.0 symbol version from glibc which
isn't actually needed for anything.

	Jakub

Attachment: P2
Description: Text document


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