[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gas/18625] Thumb2 branch out of range error

From: wilson at gcc dot gnu.org
Subject: [Bug gas/18625] Thumb2 branch out of range error
Date: Thu, 09 Jul 2015 23:23:53 +0000


Jim Wilson <wilson at gcc dot gnu.org> changed:

           What    |Removed                     |Added
                 CC|                            |wilson at gcc dot gnu.org

--- Comment #1 from Jim Wilson <wilson at gcc dot gnu.org> ---
This is a 1.5GB assembly file, which creates an 18MB text section.  Thumb2
branches have a range +/-16MB.  So yes, the branches are out of range.

One thing the assembler can do is branch relaxation.  It can convert an
out-of-range branch into a different longer sequence with a longer range via
branch relaxation.  You can see examples in gas/config/tc-mips.c after the
RELAX_ENCODE macro definition.  The mips gas port can convert a conditional
branch with 16-bits of offset into an unconditional branch (jump) with 28 bits
(?) of offset.

We could do something similar in the ARM port.  Except in the arm case, we are
trying to fix a branch/call, which would have to be converted into a sequence
to load the address into a register and then use a branch on register
instruction.  It looks like we can use the IP register for this.  The linker
may use IP for trampolines and PLTs, but that happens after the call, and we
are doing this before the call, so it appears that it will work.  Unless
perhaps there are other places in the ABI where IP is used, I don't know the
ARM ABI very well.  This is an enhancement request, not an assembler bug, as
this kind of relaxation is optional.  This would be a bit of work in the
assembler, and the gain would be small, since it is rare to see text sections
larger than 16MB.

The arm gas port already have relaxation to handle the section between 4-byte
and 2-byte thumb encodings.  See inst.relax and output_relax_insn.  This could
be extended to handle the out-of-range bl to blr case.  This would require a
little reorganization to support more than one type of relaxation.

Otherwise, you need the compiler to emit long calls to avoid out-of-range
calls, which you already mentioned works.

I would not call this a gas or gcc bug.  It is more of a feature conflict.  You
are trying to create a single text section which is larger than the hardware
and/or ABI directly supports, and you can't expect this to work without a
workaround of some sort.

You are receiving this mail because:
You are on the CC list for the bug.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]