Fix seg-fault running strip on a corrupt binary.

PR ld/20923
	* objcopy.c (mark_symbols_used_in_relocations): Check for a null
	symbol pointer before attempting to mark the symbol as kept.
This commit is contained in:
Nick Clifton 2016-12-05 13:11:01 +00:00
parent daae68f4f3
commit 88add6d8e7
2 changed files with 9 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2016-12-05 Nick Clifton <nickc@redhat.com>
PR ld/20923
* objcopy.c (mark_symbols_used_in_relocations): Check for a null
symbol pointer before attempting to mark the symbol as kept.
2016-12-01 Luis Machado <lgustavo@codesourcery.com>
* nm.c (sort_symbols_by_size): Don't read symbol size if symbol

View File

@ -3551,7 +3551,9 @@ mark_symbols_used_in_relocations (bfd *ibfd, sec_ptr isection, void *symbolsarg)
special bfd section symbols, then mark it with BSF_KEEP. */
for (i = 0; i < relcount; i++)
{
if (*relpp[i]->sym_ptr_ptr != bfd_com_section_ptr->symbol
/* See PR 20923 for a reproducer for the NULL test. */
if (relpp[i]->sym_ptr_ptr != NULL
&& *relpp[i]->sym_ptr_ptr != bfd_com_section_ptr->symbol
&& *relpp[i]->sym_ptr_ptr != bfd_abs_section_ptr->symbol
&& *relpp[i]->sym_ptr_ptr != bfd_und_section_ptr->symbol)
(*relpp[i]->sym_ptr_ptr)->flags |= BSF_KEEP;