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]

ld's output_prev_sec_find


Make output_prev_sec_find go faster, and some insignificant tidying.

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

Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.205
diff -u -p -r1.205 ldlang.c
--- ld/ldlang.c	16 Nov 2005 07:17:20 -0000	1.205
+++ ld/ldlang.c	16 Nov 2005 07:23:35 -0000
@@ -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_has
 			 (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
 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 +5214,9 @@ lang_enter_output_section_statement (con
 {
   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 +5244,9 @@ lang_enter_output_section_statement (con
 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 +5608,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 +5632,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 +5678,9 @@ lang_add_reloc (bfd_reloc_code_real_type
 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 +5688,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: ld/ldlang.h
===================================================================
RCS file: /cvs/src/src/ld/ldlang.h,v
retrieving revision 1.55
diff -u -p -r1.55 ldlang.h
--- ld/ldlang.h	3 Nov 2005 02:54:10 -0000	1.55
+++ ld/ldlang.h	16 Nov 2005 06:11:24 -0000
@@ -130,6 +130,7 @@ typedef struct lang_output_section_state
   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;

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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