* ldlang.h (lang_output_section_statement_type): Add prev.
authorAlan Modra <amodra@gmail.com>
Wed, 16 Nov 2005 08:32:54 +0000 (08:32 +0000)
committerAlan Modra <amodra@gmail.com>
Wed, 16 Nov 2005 08:32:54 +0000 (08:32 +0000)
* ldlang.c (new_afile): Always init header.type.
(output_statement_newfunc): Set os.prev.
(output_prev_sec_find): Use os.prev.
(lang_enter_output_section_statement): Formatting.
(lang_final, lang_add_target, lang_add_fill): Likewise.
(lang_add_data, lang_add_reloc): Likewise.
(lang_add_attribute): Only alloc the header.

ld/ChangeLog
ld/ldlang.c
ld/ldlang.h

index 60ff9b387184741d258343b7eb497d94ed809099..06c7815e5a7816a20557f57136f5be09edcff9a3 100644 (file)
@@ -1,3 +1,14 @@
+2005-11-16  Alan Modra  <amodra@bigpond.net.au>
+
+       * ldlang.h (lang_output_section_statement_type): Add prev.
+       * ldlang.c (new_afile): Always init header.type.
+       (output_statement_newfunc): Set os.prev.
+       (output_prev_sec_find): Use os.prev.
+       (lang_enter_output_section_statement): Formatting.
+       (lang_final, lang_add_target, lang_add_fill): Likewise.
+       (lang_add_data, lang_add_reloc): Likewise.
+       (lang_add_attribute): Only alloc the header.
+
 2005-11-16  Alan Modra  <amodra@bigpond.net.au>
 
        * ld.texinfo (Forced Output Alignment): Specify that this is an
index 8ceb8ad2e0eaa3ffd335c664205c185edbcf5d9a..198abba4bc7fdca7a62b2b98d56d3aaa89e8ddee 100644 (file)
@@ -783,6 +783,7 @@ new_afile (const char *name,
   else
     {
       p = stat_alloc (sizeof (lang_input_statement_type));
+      p->header.type = lang_input_statement_enum;
       p->header.next = NULL;
     }
 
@@ -911,6 +912,8 @@ output_statement_newfunc (struct bfd_hash_entry *entry,
                         (lang_statement_union_type *) &ret->os,
                         &ret->os.header.next);
 
+  ret->os.prev = &((*lang_output_section_statement.tail)
+                  ->output_section_statement);
   /* GCC's strict aliasing rules prevent us from just casting the
      address, so we store the pointer in a variable and cast that
      instead.  */
@@ -1295,20 +1298,15 @@ lang_output_section_find_by_flags (const asection *sec,
 static asection *
 output_prev_sec_find (lang_output_section_statement_type *os)
 {
-  asection *s = (asection *) NULL;
   lang_output_section_statement_type *lookup;
 
-  for (lookup = &lang_output_section_statement.head->output_section_statement;
-       lookup != NULL;
-       lookup = lookup->next)
+  for (lookup = os->prev; lookup != NULL; lookup = lookup->prev)
     {
       if (lookup->constraint == -1)
        continue;
-      if (lookup == os)
-       return s;
 
       if (lookup->bfd_section != NULL && lookup->bfd_section->owner != NULL)
-       s = lookup->bfd_section;
+       return lookup->bfd_section;
     }
 
   return NULL;
@@ -5221,10 +5219,9 @@ lang_enter_output_section_statement (const char *output_section_statement_name,
 {
   lang_output_section_statement_type *os;
 
-  current_section =
-   os =
-    lang_output_section_statement_lookup_1 (output_section_statement_name,
-                                           constraint);
+   os = lang_output_section_statement_lookup_1 (output_section_statement_name,
+                                               constraint);
+   current_section = os;
 
   /* Make next things chain into subchain of this.  */
 
@@ -5252,9 +5249,9 @@ lang_enter_output_section_statement (const char *output_section_statement_name,
 void
 lang_final (void)
 {
-  lang_output_statement_type *new =
-    new_stat (lang_output_statement, stat_ptr);
+  lang_output_statement_type *new;
 
+  new = new_stat (lang_output_statement, stat_ptr);
   new->name = output_filename;
 }
 
@@ -5616,11 +5613,10 @@ lang_default_entry (const char *name)
 void
 lang_add_target (const char *name)
 {
-  lang_target_statement_type *new = new_stat (lang_target_statement,
-                                             stat_ptr);
+  lang_target_statement_type *new;
 
+  new = new_stat (lang_target_statement, stat_ptr);
   new->target = name;
-
 }
 
 void
@@ -5641,22 +5637,20 @@ lang_add_map (const char *name)
 void
 lang_add_fill (fill_type *fill)
 {
-  lang_fill_statement_type *new = new_stat (lang_fill_statement,
-                                           stat_ptr);
+  lang_fill_statement_type *new;
 
+  new = new_stat (lang_fill_statement, stat_ptr);
   new->fill = fill;
 }
 
 void
 lang_add_data (int type, union etree_union *exp)
 {
+  lang_data_statement_type *new;
 
-  lang_data_statement_type *new = new_stat (lang_data_statement,
-                                           stat_ptr);
-
+  new = new_stat (lang_data_statement, stat_ptr);
   new->exp = exp;
   new->type = type;
-
 }
 
 /* Create a new reloc statement.  RELOC is the BFD relocation type to
@@ -5689,9 +5683,9 @@ lang_add_reloc (bfd_reloc_code_real_type reloc,
 lang_assignment_statement_type *
 lang_add_assignment (etree_type *exp)
 {
-  lang_assignment_statement_type *new = new_stat (lang_assignment_statement,
-                                                 stat_ptr);
+  lang_assignment_statement_type *new;
 
+  new = new_stat (lang_assignment_statement, stat_ptr);
   new->exp = exp;
   return new;
 }
@@ -5699,7 +5693,7 @@ lang_add_assignment (etree_type *exp)
 void
 lang_add_attribute (enum statement_enum attribute)
 {
-  new_statement (attribute, sizeof (lang_statement_union_type), stat_ptr);
+  new_statement (attribute, sizeof (lang_statement_header_type), stat_ptr);
 }
 
 void
index 12523a4fac4ce1f294abb168fc9bb010033a0f1c..454a87c3b4eabcfdc24971492a55b917ce9f63a1 100644 (file)
@@ -130,6 +130,7 @@ typedef struct lang_output_section_statement_struct
   lang_statement_header_type header;
   lang_statement_list_type children;
   struct lang_output_section_statement_struct *next;
+  struct lang_output_section_statement_struct *prev;
   const char *name;
   asection *bfd_section;
   lang_memory_region_type *region;
This page took 0.043425 seconds and 4 git commands to generate.