[PATCH 1/5] RISC-V: free PC-relative relocation state on IFUNC errors

Harshit Kumar harshit7kr@gmail.com
Tue Nov 10 20:15:18 GMT 2026


The RISC-V relocation function allocates PC-relative relocation state at
entry.  On error paths for STT_GNU_IFUNC symbols, the function previously
returned false directly without freeing this state.

Branch to the existing out label to free the PC-relative relocation state
before exiting.

bfd/
	* elfnn-riscv.c (riscv_elf_relocate_section): Free PC-relative
	relocation state on the IFUNC error exit.

Signed-off-by: Harshit Kumar <harshit7kr@gmail.com>
---
 bfd/elfnn-riscv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 17c714ab2c..5dd09fed8a 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -3198,7 +3198,7 @@ riscv_elf_relocate_section (struct bfd_link_info *info,
 		       "symbol `%s' has non-zero addend: %" PRId64),
 		     input_bfd, howto->name, name, (int64_t) rel->r_addend);
 		  bfd_set_error (bfd_error_bad_value);
-		  return false;
+		  goto out;
 		}
 
 		/* Generate dynamic relocation only when there is a non-GOT
@@ -3368,7 +3368,7 @@ riscv_elf_relocate_section (struct bfd_link_info *info,
 		 "symbol `%s' isn't supported"), input_bfd,
 	       howto->name, name);
 	      bfd_set_error (bfd_error_bad_value);
-	      return false;
+	      goto out;
 	    }
 	}
 

base-commit: 49465fb034a8e92b01589cf0ce8db2843de4218c
-- 
2.55.0




More information about the Binutils mailing list