diff options
author | Alan Modra <amodra@gmail.com> | 2019-03-15 16:49:42 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-03-15 20:05:18 +1030 |
commit | 1ff31e135f04b2773e10d3e5072776c1072edbfb (patch) | |
tree | a009a112837e7dca9e982a152165d61d7bd54239 /bfd/elf.c | |
parent | f55b1e3248e4950464ea120027cc6881003e0ead (diff) | |
download | gdb-1ff31e135f04b2773e10d3e5072776c1072edbfb.zip gdb-1ff31e135f04b2773e10d3e5072776c1072edbfb.tar.gz gdb-1ff31e135f04b2773e10d3e5072776c1072edbfb.tar.bz2 |
PR24337, segfault in _bfd_elf_rela_local_sym
PR 24337
* elf.c (_bfd_elf_rela_local_sym): Don't segfault on NULL sec.
(_bfd_elf_rel_local_sym): Likewise.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -11822,9 +11822,10 @@ _bfd_elf_rela_local_sym (bfd *abfd, asection *sec = *psec; bfd_vma relocation; - relocation = (sec->output_section->vma - + sec->output_offset - + sym->st_value); + relocation = sym->st_value; + if (sec == NULL) + return relocation; + relocation += sec->output_section->vma + sec->output_offset; if ((sec->flags & SEC_MERGE) && ELF_ST_TYPE (sym->st_info) == STT_SECTION && sec->sec_info_type == SEC_INFO_TYPE_MERGE) @@ -11858,7 +11859,7 @@ _bfd_elf_rel_local_sym (bfd *abfd, { asection *sec = *psec; - if (sec->sec_info_type != SEC_INFO_TYPE_MERGE) + if (sec == NULL || sec->sec_info_type != SEC_INFO_TYPE_MERGE) return sym->st_value + addend; return _bfd_merged_section_offset (abfd, psec, |