[U-Boot] weak functions not being over-ridden (location dependent)

Ben Warren biggerbadderben at gmail.com
Wed Nov 26 21:48:55 CET 2008


Graeme Russ wrote:
> Ben Warren wrote:
>   
>> Graeme,
>>
>> Graeme Russ wrote:
>>     
>>> Wolfgang Denk wrote:
>>>  
>>>       
>>>> I think this has been answered before: it doesn't work when the
>>>> functions are in libraries. It only works when the respective
>>>> functions are in explicitely linked object files.
>>>>
>>>>
>>>>     
>>>>         
>>> This doesn't seem right - reset_cpu () will be in a library no matter
>>> where
>>> I put it (either libsc520.a or libeNET.a)
>>>   
>>>       
>> Is the overriding function the only one in the source file (and thus the
>> object file)?  I've found that overriding functions will link only if
>> there's other code in the source file that is strongly-linked.
>>
>> regards,
>> Ben
>>     
>
> That solves the problem - Thanks
>
> I think this is an ld bug IMHO - will submit to binutils mailing list for
> comment
>
>   
I found discussions through Google where this was talked about, and for 
whatever reason it's intended behavior.  There are ways to force linking 
with ld switches, but they're only supported in newer versions of 
gcc/binutils and we're constrained here to supporting older tools.

 From a software architecture standpoint, it seems wrong, but the easy 
fix is to add your overriding functions to existing files.  For example, 
you'll see that all implementations of cpu_eth_init() are in 
cpu/<cpu>/cpu.c, although I would have preferred to create a new file 
called something like cpu/<cpu>/enet.c

Fun stuff...

cheers,
Ben


More information about the U-Boot mailing list