aboutsummaryrefslogtreecommitdiff
path: root/bfd/coff-mips.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-06-03 12:32:00 +0930
committerAlan Modra <amodra@gmail.com>2022-06-03 12:32:00 +0930
commit679dc6e71647adf2719c411de5006358d27978b7 (patch)
tree25da4b40d135d9eca6d63690a265f264c7872655 /bfd/coff-mips.c
parentdcefca4019c6f7646d633e71639f6faf4f2702bf (diff)
downloadgdb-679dc6e71647adf2719c411de5006358d27978b7.zip
gdb-679dc6e71647adf2719c411de5006358d27978b7.tar.gz
gdb-679dc6e71647adf2719c411de5006358d27978b7.tar.bz2
asan: mips_gprel_reloc segfault
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.
Diffstat (limited to 'bfd/coff-mips.c')
-rw-r--r--bfd/coff-mips.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c
index 9614d33..d4dc1bd 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