diff mbox

[binutils/ld] Initialize input statement created in add_archive_member

Message ID 89d23099-259b-0843-25f6-7457758b7081@foss.arm.com
State New
Headers show

Commit Message

Thomas Preudhomme Oct. 24, 2016, 7:44 a.m. UTC
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

Comments

Nick Clifton Oct. 31, 2016, 9:09 a.m. UTC | #1
Hi Thomas,

> 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.


Approved - please apply.

Cheers
  Nick
Thomas Preudhomme Oct. 31, 2016, 9:55 a.m. UTC | #2
Done, thanks.

Best regards,

Thomas

On 31/10/16 09:09, Nick Clifton wrote:
> Hi Thomas,

>

>> 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.

>

> Approved - please apply.

>

> Cheers

>   Nick

>
diff mbox

Patch

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;