From 408082ec1818d43e3552882cea5aa6b09fdc2688 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 2 Jun 2005 03:08:41 +0000 Subject: [PATCH] * ldexp.h (etree_value_type): Use "asection *" in place of "struct lang_output_section_statement_struct *" for "section". (exp_fold_tree): Likewise. (exp_mark_used_section): Likewise. * ldexp.c (new_rel, new_rel_from_section, fold_unary, fold_binary, fold_trinary, fold_name, exp_fold_tree_1, exp_fold_tree, exp_mark_used_section): Likewise for "current_section" param. (make_abs, new_abs, exp_binop, exp_unop, exp_get_vma, exp_get_fill, exp_get_abs_int): Adjust for above changes. * ldlang.c (lang_mark_used_section_1, print_assignment, lang_size_sections_1, lang_do_assignments_1): Likewise. * ldexp.c (fold_name): Init entire result struct. --- ld/ChangeLog | 15 +++++++++ ld/ldexp.c | 99 ++++++++++++++++++++++++++---------------------------------- ld/ldexp.h | 9 +++--- ld/ldlang.c | 30 +++++++++--------- 4 files changed, 77 insertions(+), 76 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 984a385..f940d2c 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,18 @@ +2005-06-02 Alan Modra + + * ldexp.h (etree_value_type): Use "asection *" in place of + "struct lang_output_section_statement_struct *" for "section". + (exp_fold_tree): Likewise. + (exp_mark_used_section): Likewise. + * ldexp.c (new_rel, new_rel_from_section, fold_unary, fold_binary, + fold_trinary, fold_name, exp_fold_tree_1, exp_fold_tree, + exp_mark_used_section): Likewise for "current_section" param. + (make_abs, new_abs, exp_binop, exp_unop, exp_get_vma, exp_get_fill, + exp_get_abs_int): Adjust for above changes. + * ldlang.c (lang_mark_used_section_1, print_assignment, + lang_size_sections_1, lang_do_assignments_1): Likewise. + * ldexp.c (fold_name): Init entire result struct. + 2005-06-01 Maciej W. Rozycki * emulparams/elf32btsmip.sh: Unset DATA_ADDR. diff --git a/ld/ldexp.c b/ld/ldexp.c index 558d475..1790e8c 100644 --- a/ld/ldexp.c +++ b/ld/ldexp.c @@ -42,11 +42,9 @@ #include "safe-ctype.h" static etree_value_type exp_fold_tree_1 - (etree_type *, lang_output_section_statement_type *, - lang_phase_type, bfd_vma, bfd_vma *, bfd_boolean); + (etree_type *, asection *, lang_phase_type, bfd_vma, bfd_vma *, bfd_boolean); static etree_value_type exp_fold_tree_no_dot - (etree_type *, lang_output_section_statement_type *, lang_phase_type, - bfd_boolean); + (etree_type *, asection *, lang_phase_type, bfd_boolean); static bfd_vma align_n (bfd_vma, bfd_vma); @@ -139,9 +137,8 @@ exp_print_token (token_code_type code, int infix_p) static void make_abs (etree_value_type *ptr) { - asection *s = ptr->section->bfd_section; - ptr->value += s->vma; - ptr->section = abs_output_section; + ptr->value += ptr->section->vma; + ptr->section = bfd_abs_section_ptr; } static etree_value_type @@ -149,7 +146,7 @@ new_abs (bfd_vma value) { etree_value_type new; new.valid_p = TRUE; - new.section = abs_output_section; + new.section = bfd_abs_section_ptr; new.value = value; new.str = NULL; return new; @@ -193,7 +190,7 @@ exp_relop (asection *section, bfd_vma value) static etree_value_type new_rel (bfd_vma value, char *str, - lang_output_section_statement_type *section) + asection *section) { etree_value_type new; new.valid_p = TRUE; @@ -204,8 +201,7 @@ new_rel (bfd_vma value, } static etree_value_type -new_rel_from_section (bfd_vma value, - lang_output_section_statement_type *section) +new_rel_from_section (bfd_vma value, asection *section) { etree_value_type new; new.valid_p = TRUE; @@ -213,14 +209,14 @@ new_rel_from_section (bfd_vma value, new.str = NULL; new.section = section; - new.value -= section->bfd_section->vma; + new.value -= section->vma; return new; } static etree_value_type fold_unary (etree_type *tree, - lang_output_section_statement_type *current_section, + asection *current_section, lang_phase_type allocation_done, bfd_vma dot, bfd_vma *dotp, @@ -246,8 +242,8 @@ fold_unary (etree_type *tree, case ABSOLUTE: if (allocation_done != lang_first_phase_enum) { - result.value += result.section->bfd_section->vma; - result.section = abs_output_section; + result.value += result.section->vma; + result.section = bfd_abs_section_ptr; } else result.valid_p = FALSE; @@ -281,7 +277,7 @@ fold_unary (etree_type *tree, case DATA_SEGMENT_END: if (allocation_done != lang_first_phase_enum - && current_section == abs_output_section + && current_section == bfd_abs_section_ptr && (exp_data_seg.phase == exp_dataseg_align_seen || exp_data_seg.phase == exp_dataseg_relro_seen || exp_data_seg.phase == exp_dataseg_adjust @@ -310,7 +306,7 @@ fold_unary (etree_type *tree, static etree_value_type fold_binary (etree_type *tree, - lang_output_section_statement_type *current_section, + asection *current_section, lang_phase_type allocation_done, bfd_vma dot, bfd_vma *dotp, @@ -355,14 +351,14 @@ fold_binary (etree_type *tree, absolute. However, adding or subtracting an absolute value from a relative value is meaningful, and is an exception. */ - if (current_section != abs_output_section - && (other.section == abs_output_section - || (result.section == abs_output_section + if (current_section != bfd_abs_section_ptr + && (other.section == bfd_abs_section_ptr + || (result.section == bfd_abs_section_ptr && tree->type.node_code == '+')) && (tree->type.node_code == '+' || tree->type.node_code == '-')) { - if (other.section != abs_output_section) + if (other.section != bfd_abs_section_ptr) { /* Keep the section of the other term. */ if (tree->type.node_code == '+') @@ -373,7 +369,7 @@ fold_binary (etree_type *tree, } } else if (result.section != other.section - || current_section == abs_output_section) + || current_section == bfd_abs_section_ptr) { make_abs (&result); make_abs (&other); @@ -429,7 +425,7 @@ fold_binary (etree_type *tree, case DATA_SEGMENT_ALIGN: if (allocation_done != lang_first_phase_enum - && current_section == abs_output_section + && current_section == bfd_abs_section_ptr && (exp_data_seg.phase == exp_dataseg_none || exp_data_seg.phase == exp_dataseg_adjust || exp_data_seg.phase == exp_dataseg_relro_adjust @@ -502,7 +498,7 @@ fold_binary (etree_type *tree, static etree_value_type fold_trinary (etree_type *tree, - lang_output_section_statement_type *current_section, + asection *current_section, lang_phase_type allocation_done, bfd_vma dot, bfd_vma *dotp, @@ -525,14 +521,14 @@ fold_trinary (etree_type *tree, static etree_value_type fold_name (etree_type *tree, - lang_output_section_statement_type *current_section, + asection *current_section, lang_phase_type allocation_done, bfd_vma dot, bfd_boolean mark_used) { etree_value_type result; - result.valid_p = FALSE; + memset (&result, 0, sizeof (result)); switch (tree->type.node_code) { @@ -559,7 +555,7 @@ fold_name (etree_type *tree, || h->type == bfd_link_hash_common) && (def_iteration == lang_statement_iteration || def_iteration == -1)); - result.section = abs_output_section; + result.section = bfd_abs_section_ptr; result.valid_p = TRUE; } break; @@ -594,19 +590,13 @@ fold_name (etree_type *tree, tree->name.name); else { - lang_output_section_statement_type *os; - - os = (lang_output_section_statement_lookup - (bfd_get_section_name (output_bfd, - output_section))); - /* FIXME: Is this correct if this section is being linked with -R? */ result = new_rel ((h->u.def.value + h->u.def.section->output_offset), NULL, - os); - os->bfd_section->flags |= SEC_KEEP; + output_section); + output_section->flags |= SEC_KEEP; } } } @@ -634,7 +624,7 @@ fold_name (etree_type *tree, { os->bfd_section->flags |= SEC_KEEP; if (os->processed > 0) - result = new_rel (0, NULL, os); + result = new_rel (0, NULL, os->bfd_section); } } break; @@ -651,10 +641,10 @@ fold_name (etree_type *tree, if (os->processed != 0) { if (os->load_base == NULL) - result = new_rel (0, NULL, os); + result = new_rel (0, NULL, os->bfd_section); else result = exp_fold_tree_no_dot (os->load_base, - abs_output_section, + bfd_abs_section_ptr, allocation_done, mark_used); } @@ -714,7 +704,7 @@ fold_name (etree_type *tree, static etree_value_type exp_fold_tree_1 (etree_type *tree, - lang_output_section_statement_type *current_section, + asection *current_section, lang_phase_type allocation_done, bfd_vma dot, bfd_vma *dotp, @@ -786,7 +776,7 @@ exp_fold_tree_1 (etree_type *tree, einfo (_("%F%S can not PROVIDE assignment to location counter\n")); if (allocation_done == lang_allocating_phase_enum || (allocation_done == lang_final_phase_enum - && current_section == abs_output_section)) + && current_section == bfd_abs_section_ptr)) { /* Notify the folder that this is an assignment to dot. */ assigning_to_dot = TRUE; @@ -806,10 +796,9 @@ exp_fold_tree_1 (etree_type *tree, { bfd_vma nextdot; - nextdot = (result.value - + current_section->bfd_section->vma); + nextdot = result.value + current_section->vma; if (nextdot < dot - && current_section != abs_output_section) + && current_section != bfd_abs_section_ptr) einfo (_("%F%S cannot move location counter backwards (from %V to %V)\n"), dot, nextdot); else @@ -857,7 +846,7 @@ exp_fold_tree_1 (etree_type *tree, lang_update_definedness (tree->assign.dst, h); h->type = bfd_link_hash_defined; h->u.def.value = result.value; - h->u.def.section = result.section->bfd_section; + h->u.def.section = result.section; if (tree->type.node_class == etree_provide) tree->type.node_class = etree_provided; } @@ -881,7 +870,7 @@ exp_fold_tree_1 (etree_type *tree, etree_value_type exp_fold_tree (etree_type *tree, - lang_output_section_statement_type *current_section, + asection *current_section, lang_phase_type allocation_done, bfd_vma dot, bfd_vma *dotp) @@ -892,7 +881,7 @@ exp_fold_tree (etree_type *tree, static etree_value_type exp_fold_tree_no_dot (etree_type *tree, - lang_output_section_statement_type *current_section, + asection *current_section, lang_phase_type allocation_done, bfd_boolean mark_used) { @@ -911,7 +900,7 @@ exp_binop (int code, etree_type *lhs, etree_type *rhs) value.binary.rhs = rhs; value.type.node_class = etree_binary; r = exp_fold_tree_no_dot (&value, - abs_output_section, + bfd_abs_section_ptr, lang_first_phase_enum, FALSE); if (r.valid_p) { @@ -950,7 +939,7 @@ exp_unop (int code, etree_type *child) value.unary.type.node_code = code; value.unary.child = child; value.unary.type.node_class = etree_unary; - r = exp_fold_tree_no_dot (&value, abs_output_section, + r = exp_fold_tree_no_dot (&value, bfd_abs_section_ptr, lang_first_phase_enum, FALSE); if (r.valid_p) return exp_intop (r.value); @@ -1119,7 +1108,7 @@ exp_get_vma (etree_type *tree, if (tree != NULL) { - r = exp_fold_tree_no_dot (tree, abs_output_section, + r = exp_fold_tree_no_dot (tree, bfd_abs_section_ptr, allocation_done, FALSE); if (! r.valid_p && name != NULL) einfo (_("%F%S nonconstant expression for %s\n"), name); @@ -1152,7 +1141,7 @@ exp_get_fill (etree_type *tree, if (tree == NULL) return def; - r = exp_fold_tree_no_dot (tree, abs_output_section, allocation_done, + r = exp_fold_tree_no_dot (tree, bfd_abs_section_ptr, allocation_done, FALSE); if (! r.valid_p && name != NULL) einfo (_("%F%S nonconstant expression for %s\n"), name); @@ -1204,11 +1193,11 @@ exp_get_abs_int (etree_type *tree, lang_phase_type allocation_done) { etree_value_type res; - res = exp_fold_tree_no_dot (tree, abs_output_section, allocation_done, + res = exp_fold_tree_no_dot (tree, bfd_abs_section_ptr, allocation_done, FALSE); if (res.valid_p) - res.value += res.section->bfd_section->vma; + res.value += res.section->vma; else einfo (_("%F%S non constant expression for %s\n"), name); @@ -1226,9 +1215,7 @@ align_n (bfd_vma value, bfd_vma align) } void -exp_mark_used_section - (etree_type *tree, - lang_output_section_statement_type *current_section) +exp_mark_used_section (etree_type *tree, asection *current_section) { switch (tree->type.node_class) { @@ -1294,7 +1281,7 @@ exp_mark_used_section lang_update_definedness (tree->assign.dst, h); h->type = bfd_link_hash_defined; h->u.def.value = result.value; - h->u.def.section = result.section->bfd_section; + h->u.def.section = result.section; if (tree->type.node_class == etree_provide) tree->type.node_class = etree_provided; } diff --git a/ld/ldexp.h b/ld/ldexp.h index 5a48f1d..ae6b874 100644 --- a/ld/ldexp.h +++ b/ld/ldexp.h @@ -1,6 +1,6 @@ /* ldexp.h - Copyright 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2002, - 2003, 2004 Free Software Foundation, Inc. + 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GLD, the Gnu Linker. @@ -26,7 +26,7 @@ typedef struct { bfd_vma value; char *str; - struct lang_output_section_statement_struct *section; + asection *section; bfd_boolean valid_p; } etree_value_type; @@ -130,8 +130,7 @@ etree_type *exp_relop etree_value_type invalid (void); etree_value_type exp_fold_tree - (etree_type *, struct lang_output_section_statement_struct *, - lang_phase_type, bfd_vma, bfd_vma *); + (etree_type *, asection *, lang_phase_type, bfd_vma, bfd_vma *); etree_type *exp_binop (int, etree_type *, etree_type *); etree_type *exp_trinop @@ -157,6 +156,6 @@ fill_type *exp_get_fill bfd_vma exp_get_abs_int (etree_type *, int, char *, lang_phase_type); void exp_mark_used_section - (etree_type *, struct lang_output_section_statement_struct *); + (etree_type *, asection *); #endif diff --git a/ld/ldlang.c b/ld/ldlang.c index 25374cc..b4f767d 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -3080,7 +3080,7 @@ lang_mark_used_section_1 break; case lang_data_statement_enum: exp_mark_used_section (s->data_statement.exp, - abs_output_section); + bfd_abs_section_ptr); break; case lang_reloc_statement_enum: @@ -3095,7 +3095,7 @@ lang_mark_used_section_1 break; case lang_assignment_statement_enum: exp_mark_used_section (s->assignment_statement.exp, - output_section_statement); + output_section_statement->bfd_section); break; case lang_padding_statement_enum: break; @@ -3319,8 +3319,8 @@ print_assignment (lang_assignment_statement_type *assignment, computation_is_valid = is_dot || (scan_for_self_assignment (dst, tree) == FALSE); } - result = exp_fold_tree (tree, output_section, lang_final_phase_enum, - print_dot, &print_dot); + result = exp_fold_tree (tree, output_section->bfd_section, + lang_final_phase_enum, print_dot, &print_dot); if (result.valid_p) { bfd_vma value; @@ -3330,7 +3330,7 @@ print_assignment (lang_assignment_statement_type *assignment, value = result.value; if (result.section) - value += result.section->bfd_section->vma; + value += result.section->vma; minfo ("0x%V", value); if (is_dot) @@ -3347,7 +3347,7 @@ print_assignment (lang_assignment_statement_type *assignment, value = h->u.def.value; if (result.section) - value += result.section->bfd_section->vma; + value += result.section->vma; minfo ("[0x%V]", value); } @@ -4149,7 +4149,7 @@ lang_size_sections_1 os->processed = -1; r = exp_fold_tree (os->addr_tree, - abs_output_section, + bfd_abs_section_ptr, lang_allocating_phase_enum, dot, &dot); os->processed = 0; @@ -4159,7 +4159,7 @@ lang_size_sections_1 " address expression for section %s\n"), os->name); - dot = r.value + r.section->bfd_section->vma; + dot = r.value + r.section->vma; } /* The section starts here. @@ -4199,7 +4199,7 @@ lang_size_sections_1 os->processed = 1; if (os->update_dot_tree != 0) - exp_fold_tree (os->update_dot_tree, abs_output_section, + exp_fold_tree (os->update_dot_tree, bfd_abs_section_ptr, lang_allocating_phase_enum, dot, &dot); /* Update dot in the region ? @@ -4258,7 +4258,7 @@ lang_size_sections_1 /* We might refer to provided symbols in the expression, and need to mark them as needed. */ - exp_fold_tree (s->data_statement.exp, abs_output_section, + exp_fold_tree (s->data_statement.exp, bfd_abs_section_ptr, lang_allocating_phase_enum, dot, &dot); switch (s->data_statement.type) @@ -4347,7 +4347,7 @@ lang_size_sections_1 bfd_vma newdot = dot; exp_fold_tree (s->assignment_statement.exp, - output_section_statement, + output_section_statement->bfd_section, lang_allocating_phase_enum, dot, &newdot); @@ -4580,12 +4580,12 @@ lang_do_assignments_1 etree_value_type value; value = exp_fold_tree (s->data_statement.exp, - abs_output_section, + bfd_abs_section_ptr, lang_final_phase_enum, dot, &dot); if (!value.valid_p) einfo (_("%F%P: invalid data statement\n")); s->data_statement.value - = value.value + value.section->bfd_section->vma; + = value.value + value.section->vma; } { unsigned int size; @@ -4618,7 +4618,7 @@ lang_do_assignments_1 etree_value_type value; value = exp_fold_tree (s->reloc_statement.addend_exp, - abs_output_section, + bfd_abs_section_ptr, lang_final_phase_enum, dot, &dot); s->reloc_statement.addend_value = value.value; if (!value.valid_p) @@ -4644,7 +4644,7 @@ lang_do_assignments_1 case lang_assignment_statement_enum: { exp_fold_tree (s->assignment_statement.exp, - output_section_statement, + output_section_statement->bfd_section, lang_final_phase_enum, dot, &dot); -- 2.7.4