mips and score check_relocs r_symndx upper bound

Message ID auJ2pT-SInvbwe9a@squeak.grove.modra.org
State New
Headers
Series mips and score check_relocs r_symndx upper bound |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Alan Modra Oct. 28, 2026, 10:26 p.m. UTC
  The maximum allowed r_symndx is fairly obviously that of the last
symbol in .symtab.  Also, sym_hashes is indexed by r_symndx-extsymoff
and sized as NUM_SHDR_ENTRIES-extsymoff.  extsymoff cancels.

(And yes, I delete this check entirely with a later patch.)

	* elfxx-mips.c (_bfd_mips_elf_check_relocs): Correct upper
	bound for r_symndx.
	* elf32-score.c (s3_bfd_score_elf_check_relocs): Likewise.
	* elf32-score7.c (s7_bfd_score_elf_check_relocs): Likewise.
  

Patch

diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c
index 227e7ca245c..d8db6e53b37 100644
--- a/bfd/elf32-score.c
+++ b/bfd/elf32-score.c
@@ -2843,7 +2843,7 @@  s3_bfd_score_elf_check_relocs (bfd *abfd,
 	{
 	  h = NULL;
 	}
-      else if (r_symndx >= extsymoff + NUM_SHDR_ENTRIES (symtab_hdr))
+      else if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c
index 6b8f0ae2ea6..16934058bfd 100644
--- a/bfd/elf32-score7.c
+++ b/bfd/elf32-score7.c
@@ -2645,7 +2645,7 @@  s7_bfd_score_elf_check_relocs (bfd *abfd,
 	{
 	  h = NULL;
 	}
-      else if (r_symndx >= extsymoff + NUM_SHDR_ENTRIES (symtab_hdr))
+      else if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 5f3eb3463f1..1ad03454574 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -8794,7 +8794,7 @@  _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
       if (r_symndx < extsymoff)
 	h = NULL;
-      else if (r_symndx >= extsymoff + NUM_SHDR_ENTRIES (symtab_hdr))
+      else if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
 	{
 	  _bfd_error_handler
 	    /* xgettext:c-format */