]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
MSP430: Enable relaxation of jump instructions to hard-coded pcrel offsets
authorJozef Lawrynowicz <jozef.l@mittosystems.com>
Mon, 10 Feb 2020 20:37:57 +0000 (20:37 +0000)
committerJozef Lawrynowicz <jozef.l@mittosystems.com>
Mon, 10 Feb 2020 21:13:37 +0000 (21:13 +0000)
commitdef23c1b07c3d86c6c13e2448c8279f0072cca69
tree3a0cda6641f7bd11bfb3db6f0fbfa0939ec31332
parent07361958628e74507df1ce2051c935a1a67f7fe9
MSP430: Enable relaxation of jump instructions to hard-coded pcrel offsets

This patch fixes execution failures which occur when the BR in a
sequence such as:
  J<cond> 1f
  BR
  1:
is relaxed to a JMP, and the pc-relative offset for the destination of
the J<cond> instruction is hard-coded to be 2 words ahead of the
instruction.
The hard-coded offset will cause execution to jump 1 word ahead of where
it should actually go.

Instead we now detect the hard-coded offset is one we inserted earlier,
and invert the condition, allowing us to remove the BR entirely.

bfd/ChangeLog:

2020-02-10  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

* elf32-msp430.c (msp430_elf_relax_section): Before relaxing a branch,
check if previous instruction matches a conditional jump inserted
earlier. Invert conditional jump and delete branch in this case.

(cherry picked from commit ac4280dad035bb98fba999c174314435aefdf1a0)
bfd/ChangeLog
bfd/elf32-msp430.c