Arm: Fix forward thumb references [PR gas/25235]
authorTamar Christina <tamar.christina@arm.com>
Tue, 25 May 2021 15:04:04 +0000 (16:04 +0100)
committerTamar Christina <tamar.christina@arm.com>
Tue, 25 May 2021 15:04:52 +0000 (16:04 +0100)
commitd3e52e120b68bf19552743fbc078e0a759f48cb7
treeeaf641175d369046e8213b1eefd887d899202950
parent74fd118fb91f49377b63931d092b6d42dd8b3b3c
Arm: Fix forward thumb references [PR gas/25235]

When assembling a forward reference the symbol will be unknown and so during
do_t_adr we cannot set the thumb bit.  The bit it set so early to prevent
relaxations that are invalid. i.e. relaxing a Thumb2 to Thumb1 insn when the
symbol is Thumb.

But because it's done so early we miss the case for forward references.
This patch changes it so that we additionally check the thumb bit during the
internal relocation processing.

In principle we should be able to only set the bit during reloc processing but
that would require changes to the other relocations that the instruction could
be relaxed to.

This approach still allows early relaxations (which means that we have less
iteration of internal reloc processing) while still fixing the forward reference
case.

gas/ChangeLog:

2021-05-24  Tamar Christina  <tamar.christina@arm.com>

PR gas/25235
* config/tc-arm.c (md_convert_frag): Set LSB when Thumb symbol.
(relax_adr): Thumb symbols 4 bytes.
* testsuite/gas/arm/pr25235.d: New test.
* testsuite/gas/arm/pr25235.s: New test.
gas/ChangeLog
gas/config/tc-arm.c
gas/testsuite/gas/arm/pr25235.d [new file with mode: 0644]
gas/testsuite/gas/arm/pr25235.s [new file with mode: 0644]