Re: asan: mips_gprel_reloc segfault
authorAlan Modra <amodra@gmail.com>
Fri, 3 Jun 2022 03:42:01 +0000 (13:12 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 3 Jun 2022 03:42:01 +0000 (13:12 +0930)
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.

bfd/elf32-mips.c
bfd/elf64-mips.c
bfd/elfn32-mips.c

index a4c88c6b089ef2a2613793cd0f628c706276bffd..8989011edc9bba0b14d141ec56132af37273dc73 100644 (file)
@@ -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;
index 6fa9d44300c5d62abbc2874eda054e3e3665b7e4..7f6f7ef0053767a818818f31a3c1d75dae4e0998 100644 (file)
@@ -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;
index 1ae51a4648ce3989fe8bc3e8d86ee0a54a00a5e4..07b753f0cc1e09fd96f99cb1973de9daac5a8f7a 100644 (file)
@@ -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;