aboutsummaryrefslogtreecommitdiff
path: root/binutils/objcopy.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2016-12-05 13:11:01 +0000
committerNick Clifton <nickc@redhat.com>2016-12-05 13:11:01 +0000
commit88add6d8e794073758b5398c52bbb76ab40a2923 (patch)
tree3e65c30add5d29ea1f07dd1d981027982a7228b6 /binutils/objcopy.c
parentdaae68f4f372e0618d6b9c64ec0f1f74eae6ab3d (diff)
downloadgdb-88add6d8e794073758b5398c52bbb76ab40a2923.zip
gdb-88add6d8e794073758b5398c52bbb76ab40a2923.tar.gz
gdb-88add6d8e794073758b5398c52bbb76ab40a2923.tar.bz2
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.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r--binutils/objcopy.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 4910fcf..6a398ce 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -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;