[U-Boot] [PATCH v2 1/2] arm920t/at91/reset.c: fix weak reset_board()
Sebastien Carlier
sebastien.carlier at gmail.com
Thu Nov 4 12:12:27 CET 2010
On Thu, Nov 4, 2010 at 11:54 AM, Andreas Bießmann
<andreas.devel at googlemail.com> wrote:
>
> --->8---
> __LIBS := $(subst $(obj),,$(LIBBOARD)) $(subst $(obj),,$(LIBS))
> ---8<---
Still, why would the linker pull definitions from libboard.a? Library
archive are only searched by the linker to resolved undefined
definitions. Weak symbols do not count as undefined.
I think the following should work:
- In the u-boot code, forward declare (no 'weak' attribute) functions
which are to have a default implementation.
- Keep the linking order as it is now (main u-boot libs, then board
lib), and append a library containing all the weak definitions.
> But this is just a work around and will not fit any use-case of weak
> functions. The root cause seems to be a linker problem. But I dunno
> whether it is a mis-usage or a bug. Any gcc-guys here to comment?
I think the answer is that weak symbols are not meant to be used with
library archives. They work well with dynamic libraries.
>> 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...
>
> This seems to be the main issue here ... but how to get it solved?
I think there is no way around including the PLT. If I understand
well, weak symbols are meant to be resolved during dynamic linking, so
the extra indirection going through the PLT is needed to alter the
address of the weak symbols when dynamic objects are loaded.
--
Sebastien
More information about the U-Boot
mailing list