[llvm-dev] armv7 pc-rel bx thumb instruction

Jonas Devlieghere via llvm-dev llvm-dev at lists.llvm.org
Tue Aug 1 00:35:32 PDT 2017


Thanks a lot for the explanation!

I've done some more testing and while -mdisable-tail-calls does solve
the problem for some samples, there are others where the error
remains. Any chance you or anyone else has another idea what might
cause this? Some sample show a different error "unknown ARM scattered
relocation type 11" which also seems to be related to jump islands
(being out of range?).

Thank you,
Jonas

On Wed, Jul 26, 2017 at 11:36 PM, Tim Northover <t.p.northover at gmail.com> wrote:
> Hi Jonas,
>
> On 26 July 2017 at 13:56, Jonas Devlieghere via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
>> So it seems that a branch island is glue code added by the linker to do the
>> actual mode switch if necessary. But why would we need a mode switch for a
>> jump to a function that is also in thumb mode?
>
> We wouldn't unless shim is in ARM mode; that's what the code actually
> has to jump to. But it's just speculation, I haven't read the ld64
> code nearly enough to pinpoint the error there.
>
>> And why is the branch island arm code and not thumb?
>
> If that really is the issue, it'll just be an oversight.
>
>> Would you mind helping me understand how these branch islands work?
>
> The basic idea is that if a call destination is too far away for the
> instruction to make it there in one step the linker inserts a code
> sequence roughly like this:
>
>     ldr ip, Laddr
>     bx ip
> Laddr:
>     .word real_function_dest
>
> that is in range and converts the original call to jump there instead.
> This allows the jump to reach anywhere in the 32-bit address since the
> pointer at Laddr can be anything it wants.
>
> There are bells and whistles for PIC code, and obviously linker
> internal details get involved, but for those you're probably better
> off just looking at the code.
>
> Tim.


More information about the llvm-dev mailing list