[binutils-gdb] Revert "rl78: check relaxation delete range, propagate failures"

Jan Beulich jbeulich@sourceware.org
Fri Nov 13 15:28:07 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fd5333215c5e32db090d4c9fb17a79102716c99f

commit fd5333215c5e32db090d4c9fb17a79102716c99f
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Nov 13 16:27:15 2026 +0100

    Revert "rl78: check relaxation delete range, propagate failures"
    
    This reverts commit aaf62c2437f48ff65e4585d4b65859f8b8a8c49e. It
    went in to early, by (my) mistake.

Diff:
---
 bfd/elf32-rl78.c                              | 31 ++--------
 ld/testsuite/ld-rl78/rl78-relax-underflow.exp | 83 ---------------------------
 2 files changed, 6 insertions(+), 108 deletions(-)

diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c
index 7e4332f1f8b..b684b891199 100644
--- a/bfd/elf32-rl78.c
+++ b/bfd/elf32-rl78.c
@@ -1695,9 +1695,6 @@ elf32_rl78_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr, int count
 
   irelend = irel + sec->reloc_count;
 
-  if (! _bfd_elf_relax_delete_range_ok (abfd, sec, addr, count, toaddr))
-    return false;
-
   /* Actually delete the bytes.  */
   memmove (contents + addr, contents + addr + count,
 	   (size_t) (toaddr - addr - count));
@@ -2256,11 +2253,8 @@ rl78_elf_relax_section (bfd *abfd,
 	  nbytes /= alignment;
 	  nbytes *= alignment;
 
-	  if (! elf32_rl78_relax_delete_bytes (abfd, sec,
-					       erel->r_offset - nbytes,
-					       nbytes, next_alignment,
-					       erel->r_offset == sec->size))
-	    goto error_return;
+	  elf32_rl78_relax_delete_bytes (abfd, sec, erel->r_offset - nbytes, nbytes,
+					 next_alignment, erel->r_offset == sec->size);
 	  *again = true;
 
 	  continue;
@@ -2299,25 +2293,12 @@ rl78_elf_relax_section (bfd *abfd,
       pcrel = symval - pc + srel->r_addend;		\
       nrelocs --;
 
-      /* Delete bytes within an instruction pattern; on range check
-	 failure, abort relaxation and branch to error_return.  */
-#define SNIPNR(offset, nbytes)						\
-  do									\
-    {									\
-      if (! elf32_rl78_relax_delete_bytes (abfd, sec,			\
-					   (insn - contents) + offset,	\
-					   nbytes, next_alignment, 0))	\
-	goto error_return;						\
-    }									\
-  while (0)
+#define SNIPNR(offset, nbytes) \
+	elf32_rl78_relax_delete_bytes (abfd, sec, (insn - contents) + offset, nbytes, next_alignment, 0);
 
 #define SNIP(offset, nbytes, newtype)					\
-  do									\
-    {									\
-      SNIPNR (offset, nbytes);						\
-      srel->r_info = ELF32_R_INFO (ELF32_R_SYM (srel->r_info), newtype); \
-    }									\
-  while (0)
+	SNIPNR (offset, nbytes);					\
+	srel->r_info = ELF32_R_INFO (ELF32_R_SYM (srel->r_info), newtype)
 
       /* The order of these bit tests must match the order that the
 	 relocs appear in.  Since we sorted those by offset, we can
diff --git a/ld/testsuite/ld-rl78/rl78-relax-underflow.exp b/ld/testsuite/ld-rl78/rl78-relax-underflow.exp
deleted file mode 100644
index da90fc54ba1..00000000000
--- a/ld/testsuite/ld-rl78/rl78-relax-underflow.exp
+++ /dev/null
@@ -1,83 +0,0 @@
-# Expect script for RL78 ELF linker relaxation range tests.
-# Copyright (C) 2026 Free Software Foundation, Inc.
-#
-# This file is part of the GNU Binutils.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
-
-# Valid control case:
-# Encodes ELF32 RL78 object with .text (6 bytes: nop,
-# br $!target opcode 0xee, nop, target: nop), .rela.text with
-# R_RL78_RH_RELAX (type 45) at offset 1 and R_RL78_DIR16S_PCREL
-# (type 10) at offset 2 referencing target (offset 5), .symtab,
-# .strtab, and .shstrtab.
-# Branch relaxation converts 3B long branch to 2B short branch
-# (0xef), calling elf32_rl78_relax_delete_bytes with addr=3,
-# count=1, toaddr=6.
-# Range check validates offs <= limit, count <= limit - offs,
-# and limit <= sec->size.
-# .text shrinks from 6 bytes to 5 bytes.
-set ctrl_valid_hex {
-    7f454c460101010000000000000000000100c500010000000000000000000000
-    140100000000000034000000000028000800070000ee00000000000000000000
-    0000000000000000000000000000000000000000000000000300010000000000
-    0000000000000000030003000000000000000000000000000300040001000000
-    0500000000000000000001000800000000000000000000001000000015000000
-    00000000000000001000010000746172676574005f5f726c37385f6162735f5f
-    005f737461727400010000002d00000011000000020000000a04000000000000
-    002e73796d746162002e737472746162002e7368737472746162002e72656c61
-    2e74657874002e64617461002e62737300000000000000000000000000000000
-    0000000000000000000000000000000000000000000000000000000020000000
-    0100000006000000000000003400000006000000000000000000000001000000
-    000000001b000000040000004000000000000000c80000001800000005000000
-    01000000040000000c000000260000000100000003000000000000003a000000
-    00000000000000000000000001000000000000002c0000000800000003000000
-    000000003a000000000000000000000000000000010000000000000001000000
-    0200000000000000000000003c00000070000000060000000500000004000000
-    1000000009000000030000000000000000000000ac0000001c00000000000000
-    00000000010000000000000011000000030000000000000000000000e0000000
-    3100000000000000000000000100000000000000
-}
-
-# Malformed test case:
-# Truncates .text sh_size to 3 bytes (0x03) in section header.
-# Instruction to relax is a 3-byte branch starting at offset 1.
-# Relaxation attempts to delete 1 byte at offs=3 with limit=3.
-# Since count (1) > limit - offs (3 - 3 = 0), the check fails
-# and branches to error_return, cleanly rejecting the link with
-# status 1.
-set underflow_hex {
-    7f454c460101010000000000000000000100c500010000000000000000000000
-    140100000000000034000000000028000800070000ee00000000000000000000
-    0000000000000000000000000000000000000000000000000300010000000000
-    0000000000000000030003000000000000000000000000000300040001000000
-    0500000000000000000001000800000000000000000000001000000015000000
-    00000000000000001000010000746172676574005f5f726c37385f6162735f5f
-    005f737461727400010000002d00000011000000020000000a04000000000000
-    002e73796d746162002e737472746162002e7368737472746162002e72656c61
-    2e74657874002e64617461002e62737300000000000000000000000000000000
-    0000000000000000000000000000000000000000000000000000000020000000
-    0100000006000000000000003400000003000000000000000000000001000000
-    000000001b000000040000004000000000000000c80000001800000005000000
-    01000000040000000c000000260000000100000003000000000000003a000000
-    00000000000000000000000001000000000000002c0000000800000003000000
-    000000003a000000000000000000000000000000010000000000000001000000
-    0200000000000000000000003c00000070000000060000000500000004000000
-    1000000009000000030000000000000000000000ac0000001c00000000000000
-    00000000010000000000000011000000030000000000000000000000e0000000
-    3100000000000000000000000100000000000000
-}
-
-ld_relax_underflow_test "elf32rl78" "-m elf32rl78 --relax -e _start" "RL78" \
-    $ctrl_valid_hex "5" $underflow_hex


More information about the Binutils-cvs mailing list