This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, binutils/ld] Initialize input statement created in add_archive_member


add_archive_member creates an input statement structure but fails to initialize the type of the structure accordingly. I noticed this while trying to browse all input statement structures in the statement, file and input file list in ld as some structures were skipped due to the wrong type.

This patch adds the necessary initialization and adds an assert in plugin_object_p which assumes input statement and was receiving one of the badly initialized structures.

ChangeLog entry is as follows:


*** ld/ChangeLog ***

2016-10-21  Thomas Preud'homme  <thomas.preudhomme@arm.com>

        * ldmain.c (add_archive_element): Initialize input->header.type.
        * plugin.c (plugin_maybe_claim): Assert the statement is an input
        statement.


Testsuite shows no regression on arm-none-eabi and armeb-none-eabi.

Is this ok for master branch?

Best regards,

Thomas
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 29ef77f4f02f43e4c167c2e4794d1e60d81394d2..2f15ba72a9c6aeddf40761c3ff6d5a4b13428bf5 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -800,6 +800,7 @@ add_archive_element (struct bfd_link_info *info,
 
   input = (lang_input_statement_type *)
       xcalloc (1, sizeof (lang_input_statement_type));
+  input->header.type = lang_input_statement_enum;
   input->filename = abfd->filename;
   input->local_sym_name = abfd->filename;
   input->the_bfd = abfd;
diff --git a/ld/plugin.c b/ld/plugin.c
index 80d22e222d097cbc8004759bf71ac7fa678f5461..804294049af6daa4b9449c8abbd4d25277c07e6c 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -1195,6 +1195,7 @@ plugin_object_p (bfd *ibfd)
 void
 plugin_maybe_claim (lang_input_statement_type *entry)
 {
+  ASSERT (entry->header.type == lang_input_statement_enum);
   if (plugin_object_p (entry->the_bfd))
     {
       bfd *abfd = entry->the_bfd->plugin_dummy_bfd;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]