diff options
author | Alan Modra <amodra@gmail.com> | 2023-06-20 09:46:03 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-06-20 10:01:50 +0930 |
commit | 75e73c6cadcc064c2a0fd03396666574cd5335ca (patch) | |
tree | f6e218f4775f094f072eb48ded852c0a5b792cb8 /bfd/elfxx-mips.c | |
parent | a89e364b45a93acd20f48abd787ef5cb7c07f683 (diff) | |
download | gdb-75e73c6cadcc064c2a0fd03396666574cd5335ca.zip gdb-75e73c6cadcc064c2a0fd03396666574cd5335ca.tar.gz gdb-75e73c6cadcc064c2a0fd03396666574cd5335ca.tar.bz2 |
Don't segfault in mips reloc special_functions
A symbol defined in a section from a shared library will have a NULL
section->output_section during linking.
* elf32-mips.c (gprel32_with_gp): Don't segfault on NULL
symbol->section->output_section.
* elf64-mips.c (mips_elf64_gprel32_reloc): Likewise.
* elfn32-mips.c (mips_elf_gprel16_reloc): Likewise.
(mips_elf_literal_reloc, mips_elf_gprel32_reloc): Likewise.
(gprel32_with_gp, mips16_gprel_reloc): Likewise.
* elfxx-mips.c (_bfd_mips_elf_gprel16_with_gp): Likewise.
(_bfd_mips_elf_generic_reloc): Likewise.
Diffstat (limited to 'bfd/elfxx-mips.c')
-rw-r--r-- | bfd/elfxx-mips.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 4dfd8d0..71f2dc9 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -2481,8 +2481,11 @@ _bfd_mips_elf_gprel16_with_gp (bfd *abfd, asymbol *symbol, else relocation = symbol->value; - relocation += symbol->section->output_section->vma; - relocation += symbol->section->output_offset; + if (symbol->section->output_section != NULL) + { + relocation += symbol->section->output_section->vma; + relocation += symbol->section->output_offset; + } /* Set val to the offset into the section or symbol. */ val = reloc_entry->addend; @@ -2673,7 +2676,8 @@ _bfd_mips_elf_generic_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry, /* Build up the field adjustment in VAL. */ val = 0; - if (!relocatable || (symbol->flags & BSF_SECTION_SYM) != 0) + if ((!relocatable || (symbol->flags & BSF_SECTION_SYM) != 0) + && symbol->section->output_section != NULL) { /* Either we're calculating the final field value or we have a relocation against a section symbol. Add in the section's |