[PATCH] Fix SuperH relaxation overriding wrong intruction

Quentin Boswank qubos@outlook.de
Fri May 9 14:29:25 GMT 2025


>From efcaee7155b26208915e0dc066d168076a4f7ae2 Mon Sep 17 00:00:00 2001
From: QBos07 <qubos@outlook.de>
Date: Fri, 9 May 2025 13:49:44 +0000
Subject: [PATCH] Fix SuperH relaxation overriding wrong intruction

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 | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 612b1581..1e6f5500 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -1431,9 +1431,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)
-- 
2.49.0

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20250509/71ac02a8/attachment.htm>


More information about the Binutils mailing list