[binutils-gdb] Re: asan: mips_gprel_reloc segfault

Alan Modra amodra@sourceware.org
Fri Jun 3 03:46:01 GMT 2022


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

commit 6b8b24bb688e53e251bbe2f3f9ddc44bca122bde
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Jun 3 13:12:01 2022 +0930

    Re: asan: mips_gprel_reloc segfault
    
    Similarly for the elf mips support.
    
            * elf32-mips.c (mips_elf_final_gp): Don't segfault on symbols
            in any of the bfd_is_const_section sections.
            * elf64-mips.c (mips_elf64_final_gp): Likewise.
            * elfn32-mips.c (mips_elf_final_gp): Likewise.

Diff:
---
 bfd/elf32-mips.c  | 3 +--
 bfd/elf64-mips.c  | 3 +--
 bfd/elfn32-mips.c | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index a4c88c6b089..8989011edc9 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -1720,8 +1720,7 @@ static bfd_reloc_status_type
 mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bool relocatable,
 		   char **error_message, bfd_vma *pgp)
 {
-  if (bfd_is_und_section (symbol->section)
-      && ! relocatable)
+  if (output_bfd == NULL)
     {
       *pgp = 0;
       return bfd_reloc_undefined;
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index 6fa9d44300c..7f6f7ef0053 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -3427,8 +3427,7 @@ static bfd_reloc_status_type
 mips_elf64_final_gp (bfd *output_bfd, asymbol *symbol, bool relocatable,
 		     char **error_message, bfd_vma *pgp)
 {
-  if (bfd_is_und_section (symbol->section)
-      && ! relocatable)
+  if (output_bfd == NULL)
     {
       *pgp = 0;
       return bfd_reloc_undefined;
diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c
index 1ae51a4648c..07b753f0cc1 100644
--- a/bfd/elfn32-mips.c
+++ b/bfd/elfn32-mips.c
@@ -3254,8 +3254,7 @@ static bfd_reloc_status_type
 mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bool relocatable,
 		   char **error_message, bfd_vma *pgp)
 {
-  if (bfd_is_und_section (symbol->section)
-      && ! relocatable)
+  if (output_bfd == NULL)
     {
       *pgp = 0;
       return bfd_reloc_undefined;


More information about the Binutils-cvs mailing list