]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR 3298 Fix SuperH relaxation overriding wrong intruction
authorQBos07 <qubos@outlook.de>
Fri, 9 May 2025 13:49:44 +0000 (13:49 +0000)
committerAlan Modra <amodra@gmail.com>
Thu, 22 May 2025 23:27:50 +0000 (08:57 +0930)
when doing load store switching it wrongly adjusts the address of the
R_SH_USES reloc and not the actual offset from that instruction. This is
an issue if the pc-relative function call relaxation gets done in a
later pass wich will result in overriding the wrong instruction.

bfd/elf32-sh.c

index 39a837ce3d875c913a216b9153424ec2c8dc7fb4..abb7f5eb8aba264f0352ec012256e58df0c3d56e 100644 (file)
@@ -1429,9 +1429,9 @@ sh_elf_swap_insns (bfd *abfd, asection *sec, void *relocs,
 
          off = irel->r_offset + 4 + irel->r_addend;
          if (off == addr)
-           irel->r_offset += 2;
+           irel->r_addend += 2;
          else if (off == addr + 2)
-           irel->r_offset -= 2;
+           irel->r_addend -= 2;
        }
 
       if (irel->r_offset == addr)