[binutils-gdb] MIPS: Fix addend handling with rela R_MIPS16_GOT16 and R_MICROMIPS_GOT16

Maciej W. Rozycki macro@sourceware.org
Tue Jul 1 14:11:56 GMT 2025


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

commit a17dd69b3370d1c61ca720fe02ddaed04ed84e59
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Jul 1 14:05:07 2025 +0100

    MIPS: Fix addend handling with rela R_MIPS16_GOT16 and R_MICROMIPS_GOT16
    
    In rela howtos these relocations should not be using
    _bfd_mips_elf_got16_reloc.  That special function is for extracting
    addends from section contents, and only for that (ie. it doesn't
    subtract gp).  Make these rela howtos like the corresponding
    R_MIPS_GOT16 rela howto.
    
            * elf64-mips.c (mips16_elf64_howto_table_rela <R_MIPS16_GOT16>):
            Use _bfd_mips_elf_generic_reloc.
            (micromips_elf64_howto_table_rela <R_MICROMIPS_GOT16>): Likewise.
            * elfn32-mips.c (elf_mips16_howto_table_rela <R_MIPS16_GOT16>):
            Likewise.
            (elf_micromips_howto_table_rela <R_MICROMIPS_GOT16>): Likewise.

Diff:
---
 bfd/elf64-mips.c  | 4 ++--
 bfd/elfn32-mips.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index 8af7190a3e7..30923ef062e 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -1931,7 +1931,7 @@ static reloc_howto_type mips16_elf64_howto_table_rela[] =
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 _bfd_mips_elf_got16_reloc, /* special_function */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS16_GOT16",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -2675,7 +2675,7 @@ static reloc_howto_type micromips_elf64_howto_table_rela[] =
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
-	 _bfd_mips_elf_got16_reloc, /* special_function */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_GOT16",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c
index 25f989b5b21..9df93e11c18 100644
--- a/bfd/elfn32-mips.c
+++ b/bfd/elfn32-mips.c
@@ -1911,7 +1911,7 @@ static reloc_howto_type elf_mips16_howto_table_rela[] =
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_dont, /* complain_on_overflow */
-	 _bfd_mips_elf_got16_reloc, /* special_function */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS16_GOT16",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */
@@ -2655,7 +2655,7 @@ static reloc_howto_type elf_micromips_howto_table_rela[] =
 	 false,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
-	 _bfd_mips_elf_got16_reloc, /* special_function */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_GOT16",	/* name */
 	 false,			/* partial_inplace */
 	 0,			/* src_mask */


More information about the Binutils-cvs mailing list