diff options
author | Maciej W. Rozycki <macro@mips.com> | 2018-04-09 13:42:00 +0100 |
---|---|---|
committer | Maciej W. Rozycki <macro@mips.com> | 2018-04-09 13:42:00 +0100 |
commit | aec2e0d252342aa7575aff608e999a36f27a9147 (patch) | |
tree | 9a1a5ce7f6f2ba6e37b7e5babdd8a8d3f8aaf07b /binutils | |
parent | 3f97ba9fc82dbb1bca72fd8a137b2de132348367 (diff) | |
download | gdb-aec2e0d252342aa7575aff608e999a36f27a9147.zip gdb-aec2e0d252342aa7575aff608e999a36f27a9147.tar.gz gdb-aec2e0d252342aa7575aff608e999a36f27a9147.tar.bz2 |
MIPS64/BFD: Fix a crash with STN_UNDEF in relocation
Prevent a null BFD pointer dereference and a resulting segmentation
fault in `mips_elf64_write_rel' or `mips_elf64_write_rela':
Program received signal SIGSEGV, Segmentation fault.
0x0000000000437690 in mips_elf64_write_rela (abfd=0x71e130, sec=0x720700,
rela_hdr=0x721ff8, count=0x7fffffffb82c, data=0x7fffffffb88c)
at .../bfd/elf64-mips.c:4123
4123 if ((*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
4124 && ! _bfd_elf_validate_reloc (abfd, ptr))
in the MIPS64 (n64 MIPS) ELF backend whenever the STN_UNDEF symbol index
is retrieved from the `r_sym' field of a relocation seen in input while
running `objcopy' or `strip'. The reason for the null BFD pointer is
that internally in BFD an STN_UNDEF symbol reference resolves to an
absolute zero symbol that does not have a BFD associated. Check the
pointer then before using it, like the generic ELF backend does in
`elf_write_relocs'.
This complements the same change made for generic ELF bundled with:
commit e35765a9a2eaff0df62757f3e6480c8ba5ab8ee8
Author: Ian Lance Taylor <ian@airs.com>
Date: Sun Dec 15 19:59:18 1996 +0000
which (obviously due to a CVS -> GIT repository conversion inaccuracy)
seems to be one corresponding to this ChangeLog entry:
* elfcode.h (write_relocs): Handle absolute symbol.
from:
commit c86158e591edd8450f49f8cd75f82e4313d4b6d8
Author: Ian Lance Taylor <ian@airs.com>
Date: Fri Aug 30 22:09:51 1996 +0000
("Add SH ELF support."), which also updated RELA only and not REL (which
has been since fixed with: commit 947216bf8f34 ("ELF reloc code tidy"),
<https://sourceware.org/ml/binutils/2002-11/msg00727.html>).
bfd/
* elf64-mips.c (mips_elf64_write_rel): Handle a NULL BFD pointer
in the BFD symbol referred by the relocation.
(mips_elf64_write_rela): Likewise.
Diffstat (limited to 'binutils')
0 files changed, 0 insertions, 0 deletions