Fix ld uninitialized read of script ASSERT data structure
authorAlan Modra <amodra@gmail.com>
Tue, 7 Mar 2017 01:50:00 +0000 (12:20 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 7 Mar 2017 02:03:28 +0000 (12:33 +1030)
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
ld/ldlang.c

index cbe44a2f79a31abda8fce25d02dfd2b2081e0391..3883bcbd4d531a58185e424ea90d244eb66b6381 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-07  Alan Modra  <amodra@gmail.com>
+
+       * ldlang.c (open_input_bfds): Check that lang_assignment_statement
+       is not an assert before referencing defsym.
+
 2017-03-05  Alan Modra  <amodra@gmail.com>
 
        * testsuite/ld-elf/eh3.d: Adjust for eh_frame alignment change.
index 1396c5b3d1dcb27b7e9398cac379060e06ae855c..ff6ef395b5decc50883fb0932d4d704621a09b59 100644 (file)
@@ -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;