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

Andreas Bießmann
2010-11-04T10:41:48Z

Dear all,

Am 04.11.2010 02:23, schrieb Joakim Tjernlund:
> Graeme Russ <graeme.russ@gmail.com> wrote on 2010/11/04 02:13:44:
>>
>> On Thu, Nov 4, 2010 at 12:00 PM, Joakim Tjernlund
>> <joakim.tjernlund@transmode.se> wrote:
>>>
>>>>
>>>> The arm920t compiler/linker dif not handle weak functions correctely.
>>>> Therefore the linker tried to link outside the ELF (isn't that lazy
>>>> linking?). This leads to segfault of linker in the end.
>>>>
>>>> This patch adds a empty stub for weak function reset_board() to catch
>>>> that case.
>>>
>>> I believe this is the wrong approach.
>>> Instead you should fix the relocation/fixup routine not to relocate
>>> NULL ptrs. NULL ptrs are absolute values and should be left as is.

This is ok and should be fixed in reloc routine. But it seems these
undefined weak functions are _not_ null for me (have to check this ...).

>> I personally think weak functions are 'cleaner' but may result in slightly
>> larger and slower code due to the call overhead (is the optimiser clever
>> enough to strip these out if the stub function is empty?)
>
> No idea.

It seems my linker do not strip these functions. As Sebastian pointed
out the linker adds .plt sections for these undefined weak functions. Do
we use the linker in right way?

>> Would converting all instances of "if (function())" to weak functions be
>> such a bad thing?
>
> nope, but I still think the reloc routine(s) needs to be fixed.

If reloc routine is defective, it will be fixed ... currently the link
of weak functions is the bigger problem. Without the empty stub for
reset_board() my linker segfaults. Can please one test this issue with
e.g. ELDK or other toolchains? CS 2010-q1 is known to be defective too!

To test the described issue use '[PATCH v3] arm920t: implement elf
relocation' and build for at91rm9200ek.

regards

Andreas Bie?mann