ARM/THUMB long calls stubs
Richard Earnshaw
rearnsha@arm.com
Mon Aug 12 09:43:00 GMT 2002
> Hi Andy,
>
> > By way of a suggestion, how about the _call_via.. functions be made
> > inline?
>
> Ah no, you see the entire point of the __call_via functions is that
> they are reached via the BL instruction so that the link register
> (r14) contains the return address. Then the code can just use the BX
> instruction to jump to the address held in the relevant register.
> (The BLX instruction for the Thumb only exists in v5 based
> architectures). If you inline the function you will eliminate the
> initialisation of the link register and that would be bad.
>
> Of course what you could do is to copy the PC into r14, adjust it as
> necessary and then do the jump, as in:
>
> BL 0
> BX <register_rX>
This won't work, because lr will point to the BX instruction. The
following would, but it still doesn't solve the overall problem of
unreachable libcalls.
bl 1f
1:
add lr, lr, #4
bx Rn
I really don't like this, though. It makes every call-via site 8 bytes
long. Thumb code is about reducing code size and if that means calling a
helper function, then so be it -- at least those can be shared.
R.
More information about the Gcc-bugs
mailing list