[U-Boot] [PATCH v2 1/2] arm920t/at91/reset.c: fix weak reset_board()

Sebastien Carlier sebastien.carlier at gmail.com
Thu Nov 4 04:27:17 CET 2010


These weakly defined empty functions prevent the strong definition
from being linked in.

For example, libarm.a contains a weak symbol 'red_LED_on', which is
expected to be defined (strongly) in the board library. Because
archive libraries are being used, this fails (testing with binutils
2.20.1), and only the empty __red_LED_on stub is linked in; the
red_LED_on definition in the board library is throw away.

This behavior is documented and it is the intended one; from
http://www.sco.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.

Empty weak definitions would have to be supplied to the linker only
_after_ the strong definitions have been provided.

Leaving undefined weak symbols and testing for NULL-ity at call sites
seems to be a more robust approach.

Note that with some ld versions (at least with 2.20.1), ld creates PLT
entries for undefined weak symbols and crashes when the PLT-related
sections (.plt, .got.plt, and .rel.plt) are discarded...

--
Sebastien Carlier


More information about the U-Boot mailing list