[binutils-gdb] xtensa: properly check reloc address

Alan Modra via Binutils-cvs <[email protected]>
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a9988549d9278ea37a2c64ed3f3229fb6ef2001e

commit a9988549d9278ea37a2c64ed3f3229fb6ef2001e
Author: Alan Modra <[email protected]>
Date:   Thu Mar 19 19:40:16 2026 +1030

    xtensa: properly check reloc address
    
    The existing check didn't take the reloc size into account.
    
            * elf32-xtensa.c (bfd_elf_xtensa_reloc): Use bfd_reloc_offset_in_range.

Diff:
---
 bfd/elf32-xtensa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 1faa884f1d8..8a1e2e064ea 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -2178,7 +2178,7 @@ bfd_elf_xtensa_reloc (bfd *abfd,
     }
 
   /* Is the address of the relocation really within the section?  */
-  if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
+  if (!bfd_reloc_offset_in_range (howto, abfd, input_section, octets))
     return bfd_reloc_outofrange;
 
   /* Work out which section the relocation is targeted at and the
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.