From bd4d42c17411128324b921c2648e8b3d4f97df2c Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 16 Nov 2005 08:32:54 +0000 Subject: [PATCH] * 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. --- ld/ChangeLog | 11 +++++++++++ ld/ldlang.c | 44 +++++++++++++++++++------------------------- ld/ldlang.h | 1 + 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 60ff9b3..06c7815 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,16 @@ 2005-11-16 Alan Modra + * 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 + * ld.texinfo (Forced Output Alignment): Specify that this is an alignment increase, not an override. * ldlang.c (init_os): Set output section alignment here.. diff --git a/ld/ldlang.c b/ld/ldlang.c index 8ceb8ad..198abba 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -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 diff --git a/ld/ldlang.h b/ld/ldlang.h index 12523a4..454a87c 100644 --- a/ld/ldlang.h +++ b/ld/ldlang.h @@ -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; -- 2.7.4