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]

Re: Possible weak linker bug in ld


Alan Modra wrote:

On Wed, Oct 15, 2003 at 02:39:58PM +0200, Svein E. Seldal wrote:

I think I run across a bug in ld when linking files with weak symbols.


See http://www.caldera.com/developers/gabi/latest/ch4.symtab.html

"When the link editor searches archive libraries [see ``Archive File''
in Chapter 7], it extracts archive members that contain definitions of
undefined global symbols. The member's definition may be either a global
or a weak symbol. **The link editor does not extract archive members to
resolve undefined weak symbols.** Unresolved weak symbols have a zero
value."

May I ask why not?


In AVR target and the avr-libc, weak symbols are used for each of the interrupt-vectors (in the gcrt1.S file). If the application does not define a ISR handler for a specific function, it uses the default dummy one. If the application implements a ISR handler, it will of course override the weak symbol and use the "real" handler.

The case that I've run into is when you have a library that represents a specific function for this target, like a library for, say a serialport. This library is also dependent on having an ISR handler to work properly.

It would be very convenient if this library was able to override the local weak symbol, and in this manner be able to automagically install the ISR handler correctly.

Now I need to distribute the library *and* the ISR handler source file in two files. When linking I need to add the library and the ISR handler file to be able to make it work properly.

I respect this policy if there's a reason behind it. But, if there's none, I would suggest that we alter this behavior to be able to seach libs for strong symbol overrides, please.


Regards, Svein



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