]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
MIPS64/BFD: Fix a crash with invalid `r_sym' in relocation
authorMaciej W. Rozycki <macro@mips.com>
Mon, 9 Apr 2018 12:42:00 +0000 (13:42 +0100)
committerMaciej W. Rozycki <macro@mips.com>
Mon, 9 Apr 2018 12:42:00 +0000 (13:42 +0100)
commit9ccfa98b4cbc86ac34734ecf9d35466461c7e34c
treede4fe55a92162611993cb53bf9fdae71ec45d180
parent3e04d7655bf63f4e5a0d0354c21aa3fa2ece3681
MIPS64/BFD: Fix a crash with invalid `r_sym' in relocation

Prevent an out-of-range access and a possible segmentation fault in
`mips_elf64_slurp_one_reloc_table':

Program received signal SIGSEGV, Segmentation fault.
mips_elf64_slurp_one_reloc_table (abfd=0x71bd90, asect=0x71cf70,
    rel_hdr=<value optimized out>, reloc_count=1,
    relents=<value optimized out>, symbols=0x7218c0, dynamic=0)
    at .../bfd/elf64-mips.c:3758
3757       ps = symbols + rela.r_sym - 1;
3758       s = *ps;

in the MIPS64 (n64 MIPS) ELF backend whenever an invalid symbol index is
retrieved from the `r_sym' field of a relocation seen in input while
running `objcopy' or `strip'.  Issue an error instead, like the generic
ELF backend does, taking code from `elf_slurp_reloc_table_from_section',
except for relocation types that do not refer to a symbol.

This complements commit 1f70368c21a8 ("Stop objdump crash on corrupt
reloc table"), <https://sourceware.org/ml/binutils/2002-09/msg00332.html>,
and commit 05a487dc8c39 ("make check fails on i686-linux-gnu"),
<https://sourceware.org/ml/binutils/2002-09/msg00340.html>, where the
generic ELF backend code comes from.

bfd/
* elf64-mips.c (mips_elf64_slurp_one_reloc_table): Issue an
error for out-of-range `r_sym' values.
bfd/ChangeLog
bfd/elf64-mips.c