[U-Boot-Users] Can't get strong symbol to override weak one

Ben Warren biggerbadderben at gmail.com
Fri Jun 13 14:38:51 CEST 2008


Hi Wolfgang,

On Fri, Jun 13, 2008 at 12:09 AM, Wolfgang Denk <wd at denx.de> wrote:
> In message <f8328f7c0806122238p24054afcx5190acfda8a794c6 at mail.gmail.com> you wrote:
>>
>> I've played around a bit more and found that if I move my function to
>> an existing file containing functions called from elsewhere, my code
>> gets linked in.  Further research shows that a 'feature' of ld is that
>> it won't pull in a module that only has symbols that have already been
>> resolved, even if the previously found version is weak.
>
> Argh...
>
> That's evil, but given the way ld works, I think I can understand it.
>
>> IMHO, developers should be able to write board and cpu code to
>> override weak symbols in libraries/drivers without having to worry
>> about whether the intention was obeyed or not.  ld has a switch
>> '--whole-archive', that will pull in an entire archive, not just the
>> modules that are referenced elsewhere with strong linkage.
>
> Oh no. Please don;t even mention this...
>
>> I propose to wrap both the 'board/$(BOARDDIR)/lib$(BOARD).a' and
>> 'cpu/$(CPU)/lib$(CPU).a' arguments to ld in
>> --whole-module/--no-whole-module in order to accomplish this goal.  We
>> definitely don't want to do this across the board because image size
>> will increase quite a bit due to unused code.  I believe that the
>> board and cpu code, though, should be mostly free of cruft.  If not,
>> it should be restructured with appropriate CONFIGs, either in
>> Makefiles or C code.
>
> No, please do NOT do that. This will become a PITA.
>
OK.  We'll try to figure out something else.  Makefile modification
looked like a major PITA to do this anyway, which is why I didn't just
go ahead and do it.

> Maybe somebody has a really clever idea, but I'm afraid we might  end
> up  having  to  put  all  "strong"  functions  that  are  supposed to
> overwrite  weak  ones  into  separate  modules  that  get  pulled  in
> unconditionally :-(
>
> Best regards,
>
> Wolfgang Denk
>
thanks,
Ben




More information about the U-Boot mailing list