diff options
author | Alan Modra <amodra@gmail.com> | 2019-03-16 09:34:47 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-03-16 11:55:28 +1030 |
commit | 6835821be8bab8702e41e6946a7d8ee9441f0eee (patch) | |
tree | 2c8006c5192f86416c9a7bfb34f6e8f1848727ba /bfd/elf.c | |
parent | fdc01131eb74cf28ae6e7eb3f55ebe0d38839d3e (diff) | |
download | gdb-6835821be8bab8702e41e6946a7d8ee9441f0eee.zip gdb-6835821be8bab8702e41e6946a7d8ee9441f0eee.tar.gz gdb-6835821be8bab8702e41e6946a7d8ee9441f0eee.tar.bz2 |
PR24337, segfault in _bfd_elf_rela_local_sym, again
Reverts commit 1ff31e135f, fixing the problem more generally. There
are likely other place that will segfault on a NULL section.
PR 24337
* elf.c (_bfd_elf_rela_local_sym): Revert last change.
(_bfd_elf_rel_local_sym): Likewise.
* elflink.c (elf_link_input_bfd): Use bfd_und_section for
section of symbols with unrecognized shndx.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -11822,10 +11822,9 @@ _bfd_elf_rela_local_sym (bfd *abfd, asection *sec = *psec; bfd_vma relocation; - relocation = sym->st_value; - if (sec == NULL) - return relocation; - relocation += sec->output_section->vma + sec->output_offset; + relocation = (sec->output_section->vma + + sec->output_offset + + sym->st_value); if ((sec->flags & SEC_MERGE) && ELF_ST_TYPE (sym->st_info) == STT_SECTION && sec->sec_info_type == SEC_INFO_TYPE_MERGE) @@ -11859,7 +11858,7 @@ _bfd_elf_rel_local_sym (bfd *abfd, { asection *sec = *psec; - if (sec == NULL || sec->sec_info_type != SEC_INFO_TYPE_MERGE) + if (sec->sec_info_type != SEC_INFO_TYPE_MERGE) return sym->st_value + addend; return _bfd_merged_section_offset (abfd, psec, |