* mips_gprel_reloc segfault
@ 2022-06-03 3:10 Alan Modra
2022-06-03 3:47 ` Alan Modra
0 siblings, 1 reply; 2+ messages in thread
From: Alan Modra @ 2022-06-03 3:10 UTC (permalink / raw)
To: binutils
Not just the undefined section has a NULL owner, the absolute section
has too. Which means we can't find output_bfd for __gp. Also, may as
well test directly for output_bfd == NULL.
* coff-mips.c (mips_gprel_reloc): Don't segfault on any of
bfd_is_const_section sections.
diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c
index 9614d338abe..d4dc1bd3c19 100644
--- a/bfd/coff-mips.c
+++ b/bfd/coff-mips.c
@@ -593,11 +593,10 @@ mips_gprel_reloc (bfd *abfd ATTRIBUTE_UNUSED,
{
relocatable = false;
output_bfd = symbol->section->output_section->owner;
+ if (output_bfd == NULL)
+ return bfd_reloc_undefined;
}
- if (bfd_is_und_section (symbol->section) && ! relocatable)
- return bfd_reloc_undefined;
-
/* We have to figure out the gp value, so that we can adjust the
symbol value correctly. We look up the symbol _gp in the output
BFD. If we can't find it, we're stuck. We cache it in the ECOFF
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: mips_gprel_reloc segfault
2022-06-03 3:10 mips_gprel_reloc segfault Alan Modra
@ 2022-06-03 3:47 ` Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2022-06-03 3:47 UTC (permalink / raw)
To: binutils
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 --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;
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-03 3:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-03 3:10 mips_gprel_reloc segfault Alan Modra
2022-06-03 3:47 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).