From d933941d6c5ce5b2dcaaa869919b6f3de06b725d Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 7 Mar 2017 12:20:00 +1030 Subject: [PATCH] Fix ld uninitialized read of script ASSERT data structure lang_assignment_statement serves both assignments and asserts. * ldlang.c (open_input_bfds): Check that lang_assignment_statement is not an assert before referencing defsym. --- ld/ChangeLog | 5 +++++ ld/ldlang.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index cbe44a2f79a..3883bcbd4d5 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,8 @@ +2017-03-07 Alan Modra + + * ldlang.c (open_input_bfds): Check that lang_assignment_statement + is not an assert before referencing defsym. + 2017-03-05 Alan Modra * testsuite/ld-elf/eh3.d: Adjust for eh_frame alignment change. diff --git a/ld/ldlang.c b/ld/ldlang.c index 1396c5b3d1d..ff6ef395b5d 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -3374,7 +3374,8 @@ open_input_bfds (lang_statement_union_type *s, enum open_bfd_mode mode) #endif break; case lang_assignment_statement_enum: - if (s->assignment_statement.exp->assign.defsym) + if (s->assignment_statement.exp->type.node_class != etree_assert + && s->assignment_statement.exp->assign.defsym) /* This is from a --defsym on the command line. */ exp_fold_tree_no_dot (s->assignment_statement.exp); break; -- 2.30.2