thumb-2 and crt0.S init_hooks
Bill Tompkins
bill+newlib@key-square.com
Mon Oct 6 19:22:00 GMT 2008
Hi Nick,
On Oct 3, 2008, at 3:24 PM, Nick Clifton wrote:
> Hi Bill,
>
>> ldr r3, .Lhwinit
>
>> The LR then contains a word-aligned address, rather than having bit
>> 0 set to indicate thumb mode.
>
> I think that the problem might be that you have not told the linker
> that hardware_init_hook and software_init_hook are thumb function
> names, and so it does not know that it needs to set the bottom bit
> when their addresses are taken. Try adding:
>
> .thumb_func
>
> just before you declare the hooks and see if that works.
>
> Cheers
> Nick
The problem isn't the address of the hardware_init_hook, though,
but of the return address that was set up by the
mov lr, pc
instruction. It looks to me as though the pc value (transferred to
the lr)
does not have the low bit set, and so a function that returns with
bx lr
rather than
mov pc, lr
will fault.
The hooks are compiled with arm-elf-gcc -mcpu=cortex-m3 -mthumb ,
etc... so the address in .Lhwinit of hardware_init_hook does
appropriately
have the low bit set (and the function executes correctly, just faults
when
it tries to return).
Thanks,
-Bill
More information about the Newlib
mailing list