X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=ld%2Fldexp.c;h=ec449fd8d5f2298456e524206e9a9bc5f530bda7;hb=97cb79ae08640ad0b6cee32c4d1b89735a25afc9;hp=6c9d726ec1920fc2a7e2396d8468f518799f886f;hpb=252b5132c753830d5fd56823373aed85f2a0db63;p=deliverable%2Fbinutils-gdb.git diff --git a/ld/ldexp.c b/ld/ldexp.c index 6c9d726ec1..ec449fd8d5 100644 --- a/ld/ldexp.c +++ b/ld/ldexp.c @@ -1,6 +1,8 @@ /* This module handles expression trees. -Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. -Written by Steve Chamberlain of Cygnus Support (sac@cygnus.com). + Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, + 2001 + Free Software Foundation, Inc. + Written by Steve Chamberlain of Cygnus Support . This file is part of GLD, the Gnu Linker. @@ -19,15 +21,12 @@ along with GLD; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* -This module is in charge of working out the contents of expressions. - -It has to keep track of the relative/absness of a symbol etc. This is -done by keeping all values in a struct (an etree_value_type) which -contains a value, a section to which it is relative and a valid bit. - -*/ +/* This module is in charge of working out the contents of expressions. + It has to keep track of the relative/absness of a symbol etc. This + is done by keeping all values in a struct (an etree_value_type) + which contains a value, a section to which it is relative and a + valid bit. */ #include "bfd.h" #include "sysdep.h" @@ -39,6 +38,7 @@ contains a value, a section to which it is relative and a valid bit. #include "ldexp.h" #include "ldgram.h" #include "ldlang.h" +#include "libiberty.h" static void exp_print_token PARAMS ((token_code_type code)); static void make_abs PARAMS ((etree_value_type *ptr)); @@ -69,70 +69,77 @@ exp_print_token (code) token_code_type code; { static CONST struct - { - token_code_type code; - char *name; - } table[] = - { - { INT, "int" }, - { REL, "relocateable" }, - { NAME,"NAME" }, - { PLUSEQ,"+=" }, - { MINUSEQ,"-=" }, - { MULTEQ,"*=" }, - { DIVEQ,"/=" }, - { LSHIFTEQ,"<<=" }, - { RSHIFTEQ,">>=" }, - { ANDEQ,"&=" }, - { OREQ,"|=" }, - { OROR,"||" }, - { ANDAND,"&&" }, - { EQ,"==" }, - { NE,"!=" }, - { LE,"<=" }, - { GE,">=" }, - { LSHIFT,"<<" }, - { RSHIFT,">>=" }, - { ALIGN_K,"ALIGN" }, - { BLOCK,"BLOCK" }, - { SECTIONS,"SECTIONS" }, - { SIZEOF_HEADERS,"SIZEOF_HEADERS" }, - { NEXT,"NEXT" }, - { SIZEOF,"SIZEOF" }, - { ADDR,"ADDR" }, - { LOADADDR,"LOADADDR" }, - { MEMORY,"MEMORY" }, - { DEFINED,"DEFINED" }, - { TARGET_K,"TARGET" }, - { SEARCH_DIR,"SEARCH_DIR" }, - { MAP,"MAP" }, - { QUAD,"QUAD" }, - { SQUAD,"SQUAD" }, - { LONG,"LONG" }, - { SHORT,"SHORT" }, - { BYTE,"BYTE" }, - { ENTRY,"ENTRY" }, - { 0,(char *)NULL } - }; + { + token_code_type code; + char * name; + } + table[] = + { + { INT, "int" }, + { NAME, "NAME" }, + { PLUSEQ, "+=" }, + { MINUSEQ, "-=" }, + { MULTEQ, "*=" }, + { DIVEQ, "/=" }, + { LSHIFTEQ, "<<=" }, + { RSHIFTEQ, ">>=" }, + { ANDEQ, "&=" }, + { OREQ, "|=" }, + { OROR, "||" }, + { ANDAND, "&&" }, + { EQ, "==" }, + { NE, "!=" }, + { LE, "<=" }, + { GE, ">=" }, + { LSHIFT, "<<" }, + { RSHIFT, ">>" }, + { ALIGN_K, "ALIGN" }, + { BLOCK, "BLOCK" }, + { QUAD, "QUAD" }, + { SQUAD, "SQUAD" }, + { LONG, "LONG" }, + { SHORT, "SHORT" }, + { BYTE, "BYTE" }, + { SECTIONS, "SECTIONS" }, + { SIZEOF_HEADERS, "SIZEOF_HEADERS" }, + { MEMORY, "MEMORY" }, + { DEFINED, "DEFINED" }, + { TARGET_K, "TARGET" }, + { SEARCH_DIR, "SEARCH_DIR" }, + { MAP, "MAP" }, + { ENTRY, "ENTRY" }, + { NEXT, "NEXT" }, + { SIZEOF, "SIZEOF" }, + { ADDR, "ADDR" }, + { LOADADDR, "LOADADDR" }, + { MAX_K, "MAX_K" }, + { REL, "relocateable" }, + }; unsigned int idx; - for (idx = 0; table[idx].name != (char*)NULL; idx++) { - if (table[idx].code == code) { - fprintf(config.map_file, "%s", table[idx].name); - return; + for (idx = ARRAY_SIZE (table); idx--;) + { + if (table[idx].code == code) + { + fprintf (config.map_file, " %s ", table[idx].name); + return; + } } - } - /* Not in table, just print it alone */ - fprintf(config.map_file, "%c",code); + + /* Not in table, just print it alone. */ + if (code < 127) + fprintf (config.map_file, " %c ", code); + else + fprintf (config.map_file, " ", code); } -static void +static void make_abs (ptr) etree_value_type *ptr; { - asection *s = ptr->section->bfd_section; - ptr->value += s->vma; - ptr->section = abs_output_section; + asection *s = ptr->section->bfd_section; + ptr->value += s->vma; + ptr->section = abs_output_section; } static etree_value_type @@ -146,7 +153,7 @@ new_abs (value) return new; } -static void +static void check (os, name, op) lang_output_section_statement_type *os; const char *name; @@ -162,7 +169,7 @@ etree_type * exp_intop (value) bfd_vma value; { - etree_type *new = (etree_type *) stat_alloc(sizeof(new->value)); + etree_type *new = (etree_type *) stat_alloc (sizeof (new->value)); new->type.node_code = INT; new->value.value = value; new->type.node_class = etree_value; @@ -207,12 +214,12 @@ new_rel_from_section (value, section) new.value = value; new.section = section; - new.value -= section->bfd_section->vma; + new.value -= section->bfd_section->vma; return new; } -static etree_value_type +static etree_value_type fold_binary (tree, current_section, allocation_done, dot, dotp) etree_type *tree; lang_output_section_statement_type *current_section; @@ -230,7 +237,7 @@ fold_binary (tree, current_section, allocation_done, dot, dotp) other = exp_fold_tree (tree->binary.rhs, current_section, - allocation_done, dot,dotp) ; + allocation_done, dot, dotp); if (other.valid_p) { /* If the values are from different sections, or this is an @@ -259,11 +266,11 @@ fold_binary (tree, current_section, allocation_done, dot, dotp) else if (result.section != other.section || current_section == abs_output_section) { - make_abs(&result); - make_abs(&other); + make_abs (&result); + make_abs (&other); } - switch (tree->type.node_code) + switch (tree->type.node_code) { case '%': if (other.value == 0) @@ -280,22 +287,22 @@ fold_binary (tree, current_section, allocation_done, dot, dotp) break; #define BOP(x,y) case x : result.value = result.value y other.value; break; - BOP('+',+); - BOP('*',*); - BOP('-',-); - BOP(LSHIFT,<<); - BOP(RSHIFT,>>); - BOP(EQ,==); - BOP(NE,!=); - BOP('<',<); - BOP('>',>); - BOP(LE,<=); - BOP(GE,>=); - BOP('&',&); - BOP('^',^); - BOP('|',|); - BOP(ANDAND,&&); - BOP(OROR,||); + BOP ('+', +); + BOP ('*', *); + BOP ('-', -); + BOP (LSHIFT, <<); + BOP (RSHIFT, >>); + BOP (EQ, ==); + BOP (NE, !=); + BOP ('<', <); + BOP ('>', >); + BOP (LE, <=); + BOP (GE, >=); + BOP ('&', &); + BOP ('^', ^); + BOP ('|', |); + BOP (ANDAND, &&); + BOP (OROR, ||); case MAX_K: if (result.value < other.value) @@ -308,7 +315,7 @@ fold_binary (tree, current_section, allocation_done, dot, dotp) break; default: - FAIL(); + FAIL (); } } else @@ -320,7 +327,7 @@ fold_binary (tree, current_section, allocation_done, dot, dotp) return result; } -etree_value_type +etree_value_type invalid () { etree_value_type new; @@ -328,155 +335,158 @@ invalid () return new; } -static etree_value_type +static etree_value_type fold_name (tree, current_section, allocation_done, dot) etree_type *tree; lang_output_section_statement_type *current_section; - lang_phase_type allocation_done; + lang_phase_type allocation_done; bfd_vma dot; { etree_value_type result; - switch (tree->type.node_code) - { - case SIZEOF_HEADERS: - if (allocation_done != lang_first_phase_enum) - { - result = new_abs ((bfd_vma) - bfd_sizeof_headers (output_bfd, - link_info.relocateable)); - } - else - { - result.valid_p = false; - } - break; - case DEFINED: - if (allocation_done == lang_first_phase_enum) + + switch (tree->type.node_code) + { + case SIZEOF_HEADERS: + if (allocation_done != lang_first_phase_enum) + { + result = new_abs ((bfd_vma) + bfd_sizeof_headers (output_bfd, + link_info.relocateable)); + } + else + { result.valid_p = false; - else - { - struct bfd_link_hash_entry *h; - - h = bfd_wrapped_link_hash_lookup (output_bfd, &link_info, - tree->name.name, - false, false, true); - result.value = (h != (struct bfd_link_hash_entry *) NULL - && (h->type == bfd_link_hash_defined - || h->type == bfd_link_hash_defweak - || h->type == bfd_link_hash_common)); - result.section = 0; - result.valid_p = true; - } - break; - case NAME: + } + break; + case DEFINED: + if (allocation_done == lang_first_phase_enum) result.valid_p = false; - if (tree->name.name[0] == '.' && tree->name.name[1] == 0) - { - if (allocation_done != lang_first_phase_enum) - result = new_rel_from_section(dot, current_section); - else - result = invalid(); - } - else if (allocation_done != lang_first_phase_enum) - { - struct bfd_link_hash_entry *h; - - h = bfd_wrapped_link_hash_lookup (output_bfd, &link_info, - tree->name.name, - false, false, true); - if (h != NULL - && (h->type == bfd_link_hash_defined - || h->type == bfd_link_hash_defweak)) - { - if (bfd_is_abs_section (h->u.def.section)) - result = new_abs (h->u.def.value); - else if (allocation_done == lang_final_phase_enum - || allocation_done == lang_allocating_phase_enum) - { - asection *output_section; - - output_section = h->u.def.section->output_section; - if (output_section == NULL) - einfo (_("%X%S: unresolvable symbol `%s' referenced in expression\n"), - 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), - os); - } - } - } - else if (allocation_done == lang_final_phase_enum) - einfo (_("%F%S: undefined symbol `%s' referenced in expression\n"), - tree->name.name); - } - break; - - case ADDR: - if (allocation_done != lang_first_phase_enum) - { - lang_output_section_statement_type *os; - - os = lang_output_section_find (tree->name.name); - check (os, tree->name.name, "ADDR"); + else + { + struct bfd_link_hash_entry *h; + + h = bfd_wrapped_link_hash_lookup (output_bfd, &link_info, + tree->name.name, + false, false, true); + result.value = (h != (struct bfd_link_hash_entry *) NULL + && (h->type == bfd_link_hash_defined + || h->type == bfd_link_hash_defweak + || h->type == bfd_link_hash_common)); + result.section = 0; + result.valid_p = true; + } + break; + case NAME: + result.valid_p = false; + if (tree->name.name[0] == '.' && tree->name.name[1] == 0) + { + if (allocation_done != lang_first_phase_enum) + result = new_rel_from_section (dot, current_section); + else + result = invalid (); + } + else if (allocation_done != lang_first_phase_enum) + { + struct bfd_link_hash_entry *h; + + h = bfd_wrapped_link_hash_lookup (output_bfd, &link_info, + tree->name.name, + false, false, true); + if (h != NULL + && (h->type == bfd_link_hash_defined + || h->type == bfd_link_hash_defweak)) + { + if (bfd_is_abs_section (h->u.def.section)) + result = new_abs (h->u.def.value); + else if (allocation_done == lang_final_phase_enum + || allocation_done == lang_allocating_phase_enum) + { + asection *output_section; + + output_section = h->u.def.section->output_section; + if (output_section == NULL) + einfo (_("%X%S: unresolvable symbol `%s' referenced in expression\n"), + 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), + os); + } + } + } + else if (allocation_done == lang_final_phase_enum) + einfo (_("%F%S: undefined symbol `%s' referenced in expression\n"), + tree->name.name); + } + break; + + case ADDR: + if (allocation_done != lang_first_phase_enum) + { + lang_output_section_statement_type *os; + + os = lang_output_section_find (tree->name.name); + check (os, tree->name.name, "ADDR"); + result = new_rel (0, os); + } + else + result = invalid (); + break; + + case LOADADDR: + if (allocation_done != lang_first_phase_enum) + { + lang_output_section_statement_type *os; + + os = lang_output_section_find (tree->name.name); + check (os, tree->name.name, "LOADADDR"); + if (os->load_base == NULL) result = new_rel (0, os); - } - else - result = invalid (); - break; - - case LOADADDR: - if (allocation_done != lang_first_phase_enum) - { - lang_output_section_statement_type *os; - - os = lang_output_section_find (tree->name.name); - check (os, tree->name.name, "LOADADDR"); - if (os->load_base == NULL) - result = new_rel (0, os); - else - result = exp_fold_tree_no_dot (os->load_base, - abs_output_section, - allocation_done); - } - else - result = invalid (); - break; - - case SIZEOF: - if (allocation_done != lang_first_phase_enum) - { - lang_output_section_statement_type *os; - - os = lang_output_section_find (tree->name.name); - check (os, tree->name.name, "SIZEOF"); - result = new_abs (os->bfd_section->_raw_size); - } - else - result = invalid (); - break; - - default: - FAIL(); - break; - } + else + result = exp_fold_tree_no_dot (os->load_base, + abs_output_section, + allocation_done); + } + else + result = invalid (); + break; + + case SIZEOF: + if (allocation_done != lang_first_phase_enum) + { + int opb = bfd_octets_per_byte (output_bfd); + lang_output_section_statement_type *os; + + os = lang_output_section_find (tree->name.name); + check (os, tree->name.name, "SIZEOF"); + result = new_abs (os->bfd_section->_raw_size / opb); + } + else + result = invalid (); + break; + + default: + FAIL (); + break; + } return result; } -etree_value_type + +etree_value_type exp_fold_tree (tree, current_section, allocation_done, dot, dotp) etree_type *tree; lang_output_section_statement_type *current_section; - lang_phase_type allocation_done; + lang_phase_type allocation_done; bfd_vma dot; bfd_vma *dotp; { @@ -488,7 +498,7 @@ exp_fold_tree (tree, current_section, allocation_done, dot, dotp) return result; } - switch (tree->type.node_class) + switch (tree->type.node_class) { case etree_value: result = new_rel (tree->value.value, current_section); @@ -506,8 +516,8 @@ exp_fold_tree (tree, current_section, allocation_done, dot, dotp) case etree_assert: result = exp_fold_tree (tree->assert_s.child, - current_section, - allocation_done, dot, dotp); + current_section, + allocation_done, dot, dotp); if (result.valid_p) { if (! result.value) @@ -522,7 +532,7 @@ exp_fold_tree (tree, current_section, allocation_done, dot, dotp) allocation_done, dot, dotp); if (result.valid_p) { - switch (tree->type.node_code) + switch (tree->type.node_code) { case ALIGN_K: if (allocation_done != lang_first_phase_enum) @@ -538,7 +548,7 @@ exp_fold_tree (tree, current_section, allocation_done, dot, dotp) result.value += result.section->bfd_section->vma; result.section = abs_output_section; } - else + else result.valid_p = false; break; @@ -593,10 +603,11 @@ exp_fold_tree (tree, current_section, allocation_done, dot, dotp) case etree_assign: case etree_provide: + case etree_provided: if (tree->assign.dst[0] == '.' && tree->assign.dst[1] == 0) { - /* Assignment to dot can only be done during allocation */ - if (tree->type.node_class == etree_provide) + /* Assignment to dot can only be done during allocation. */ + if (tree->type.node_class != etree_assign) einfo (_("%F%S can not PROVIDE assignment to location counter\n")); if (allocation_done == lang_allocating_phase_enum || (allocation_done == lang_final_phase_enum @@ -620,12 +631,10 @@ exp_fold_tree (tree, current_section, allocation_done, dot, dotp) + current_section->bfd_section->vma); if (nextdot < dot && current_section != abs_output_section) - { - einfo (_("%F%S cannot move location counter backwards (from %V to %V)\n"), - dot, nextdot); - } + einfo (_("%F%S cannot move location counter backwards (from %V to %V)\n"), + dot, nextdot); else - *dotp = nextdot; + *dotp = nextdot; } } } @@ -666,6 +675,8 @@ exp_fold_tree (tree, current_section, allocation_done, dot, dotp) h->type = bfd_link_hash_defined; h->u.def.value = result.value; h->u.def.section = result.section->bfd_section; + if (tree->type.node_class == etree_provide) + tree->type.node_class = etree_provided; } } } @@ -683,14 +694,14 @@ exp_fold_tree (tree, current_section, allocation_done, dot, dotp) return result; } -static etree_value_type +static etree_value_type exp_fold_tree_no_dot (tree, current_section, allocation_done) etree_type *tree; lang_output_section_statement_type *current_section; lang_phase_type allocation_done; { -return exp_fold_tree(tree, current_section, allocation_done, (bfd_vma) - 0, (bfd_vma *)NULL); + return exp_fold_tree (tree, current_section, allocation_done, + (bfd_vma) 0, (bfd_vma *) NULL); } etree_type * @@ -706,15 +717,15 @@ exp_binop (code, lhs, rhs) value.binary.lhs = lhs; value.binary.rhs = rhs; value.type.node_class = etree_binary; - r = exp_fold_tree_no_dot(&value, - abs_output_section, - lang_first_phase_enum ); + r = exp_fold_tree_no_dot (&value, + abs_output_section, + lang_first_phase_enum); if (r.valid_p) { - return exp_intop(r.value); + return exp_intop (r.value); } new = (etree_type *) stat_alloc (sizeof (new->binary)); - memcpy((char *)new, (char *)&value, sizeof(new->binary)); + memcpy ((char *) new, (char *) &value, sizeof (new->binary)); return new; } @@ -732,17 +743,17 @@ exp_trinop (code, cond, lhs, rhs) value.trinary.cond = cond; value.trinary.rhs = rhs; value.type.node_class = etree_trinary; - r= exp_fold_tree_no_dot(&value, (lang_output_section_statement_type - *)NULL,lang_first_phase_enum); - if (r.valid_p) { - return exp_intop(r.value); - } + r = exp_fold_tree_no_dot (&value, + (lang_output_section_statement_type *) NULL, + lang_first_phase_enum); + if (r.valid_p) + return exp_intop (r.value); + new = (etree_type *) stat_alloc (sizeof (new->trinary)); - memcpy((char *)new,(char *) &value, sizeof(new->trinary)); + memcpy ((char *) new, (char *) &value, sizeof (new->trinary)); return new; } - etree_type * exp_unop (code, child) int code; @@ -754,17 +765,16 @@ exp_unop (code, 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, - lang_first_phase_enum); - if (r.valid_p) { - return exp_intop(r.value); - } + r = exp_fold_tree_no_dot (&value, abs_output_section, + lang_first_phase_enum); + if (r.valid_p) + return exp_intop (r.value); + new = (etree_type *) stat_alloc (sizeof (new->unary)); - memcpy((char *)new, (char *)&value, sizeof(new->unary)); + memcpy ((char *) new, (char *) &value, sizeof (new->unary)); return new; } - etree_type * exp_nameop (code, name) int code; @@ -776,22 +786,18 @@ exp_nameop (code, name) value.name.name = name; value.name.type.node_class = etree_name; + r = exp_fold_tree_no_dot (&value, + (lang_output_section_statement_type *) NULL, + lang_first_phase_enum); + if (r.valid_p) + return exp_intop (r.value); - r = exp_fold_tree_no_dot(&value, - (lang_output_section_statement_type *)NULL, - lang_first_phase_enum); - if (r.valid_p) { - return exp_intop(r.value); - } new = (etree_type *) stat_alloc (sizeof (new->name)); - memcpy((char *)new, (char *)&value, sizeof(new->name)); + memcpy ((char *) new, (char *) &value, sizeof (new->name)); return new; } - - - etree_type * exp_assop (code, dst, src) int code; @@ -802,18 +808,16 @@ exp_assop (code, dst, src) value.assign.type.node_code = code; - value.assign.src = src; value.assign.dst = dst; value.assign.type.node_class = etree_assign; #if 0 - if (exp_fold_tree_no_dot(&value, &result)) { - return exp_intop(result); - } + if (exp_fold_tree_no_dot (&value, &result)) + return exp_intop (result); #endif - new = (etree_type*) stat_alloc (sizeof (new->assign)); - memcpy((char *)new, (char *)&value, sizeof(new->assign)); + new = (etree_type *) stat_alloc (sizeof (new->assign)); + memcpy ((char *) new, (char *) &value, sizeof (new->assign)); return new; } @@ -851,86 +855,96 @@ exp_assert (exp, message) return n; } -void +void exp_print_tree (tree) etree_type *tree; { - switch (tree->type.node_class) { - case etree_value: - minfo ("0x%v", tree->value.value); - return; - case etree_rel: - if (tree->rel.section->owner != NULL) - minfo ("%B:", tree->rel.section->owner); - minfo ("%s+0x%v", tree->rel.section->name, tree->rel.value); - return; - case etree_assign: -#if 0 - if (tree->assign.dst->sdefs != (asymbol *)NULL){ - fprintf(config.map_file,"%s (%x) ",tree->assign.dst->name, - tree->assign.dst->sdefs->value); - } - else { - fprintf(config.map_file,"%s (UNDEFINED)",tree->assign.dst->name); - } -#endif - fprintf(config.map_file,"%s",tree->assign.dst); - exp_print_token(tree->type.node_code); - exp_print_tree(tree->assign.src); - break; - case etree_provide: - fprintf (config.map_file, "PROVIDE (%s, ", tree->assign.dst); - exp_print_tree (tree->assign.src); - fprintf (config.map_file, ")"); - break; - case etree_binary: - fprintf(config.map_file,"("); - exp_print_tree(tree->binary.lhs); - exp_print_token(tree->type.node_code); - exp_print_tree(tree->binary.rhs); - fprintf(config.map_file,")"); - break; - case etree_trinary: - exp_print_tree(tree->trinary.cond); - fprintf(config.map_file,"?"); - exp_print_tree(tree->trinary.lhs); - fprintf(config.map_file,":"); - exp_print_tree(tree->trinary.rhs); - break; - case etree_unary: - exp_print_token(tree->unary.type.node_code); - if (tree->unary.child) + if (config.map_file == NULL) + config.map_file = stderr; + + if (tree == NULL) { - fprintf(config.map_file,"("); - exp_print_tree(tree->unary.child); - fprintf(config.map_file,")"); - } - - break; - - case etree_assert: - fprintf (config.map_file, "ASSERT ("); - exp_print_tree (tree->assert_s.child); - fprintf (config.map_file, ", %s)", tree->assert_s.message); - break; - - case etree_undef: - fprintf(config.map_file,"????????"); - break; - case etree_name: - if (tree->type.node_code == NAME) { - fprintf(config.map_file,"%s", tree->name.name); + minfo ("NULL TREE\n"); + return; } - else { - exp_print_token(tree->type.node_code); - if (tree->name.name) - fprintf(config.map_file,"(%s)", tree->name.name); + + switch (tree->type.node_class) + { + case etree_value: + minfo ("0x%v", tree->value.value); + return; + case etree_rel: + if (tree->rel.section->owner != NULL) + minfo ("%B:", tree->rel.section->owner); + minfo ("%s+0x%v", tree->rel.section->name, tree->rel.value); + return; + case etree_assign: +#if 0 + if (tree->assign.dst->sdefs != (asymbol *) NULL) + fprintf (config.map_file, "%s (%x) ", tree->assign.dst->name, + tree->assign.dst->sdefs->value); + else + fprintf (config.map_file, "%s (UNDEFINED)", tree->assign.dst->name); +#endif + fprintf (config.map_file, "%s", tree->assign.dst); + exp_print_token (tree->type.node_code); + exp_print_tree (tree->assign.src); + break; + case etree_provide: + case etree_provided: + fprintf (config.map_file, "PROVIDE (%s, ", tree->assign.dst); + exp_print_tree (tree->assign.src); + fprintf (config.map_file, ")"); + break; + case etree_binary: + fprintf (config.map_file, "("); + exp_print_tree (tree->binary.lhs); + exp_print_token (tree->type.node_code); + exp_print_tree (tree->binary.rhs); + fprintf (config.map_file, ")"); + break; + case etree_trinary: + exp_print_tree (tree->trinary.cond); + fprintf (config.map_file, "?"); + exp_print_tree (tree->trinary.lhs); + fprintf (config.map_file, ":"); + exp_print_tree (tree->trinary.rhs); + break; + case etree_unary: + exp_print_token (tree->unary.type.node_code); + if (tree->unary.child) + { + fprintf (config.map_file, "("); + exp_print_tree (tree->unary.child); + fprintf (config.map_file, ")"); + } + break; + + case etree_assert: + fprintf (config.map_file, "ASSERT ("); + exp_print_tree (tree->assert_s.child); + fprintf (config.map_file, ", %s)", tree->assert_s.message); + break; + + case etree_undef: + fprintf (config.map_file, "????????"); + break; + case etree_name: + if (tree->type.node_code == NAME) + { + fprintf (config.map_file, "%s", tree->name.name); + } + else + { + exp_print_token (tree->type.node_code); + if (tree->name.name) + fprintf (config.map_file, "(%s)", tree->name.name); + } + break; + default: + FAIL (); + break; } - break; - default: - FAIL(); - break; - } } bfd_vma @@ -953,21 +967,20 @@ exp_get_vma (tree, def, name, allocation_done) return def; } -int -exp_get_value_int (tree,def,name, allocation_done) +int +exp_get_value_int (tree, def, name, allocation_done) etree_type *tree; int def; char *name; lang_phase_type allocation_done; { - return (int)exp_get_vma(tree,(bfd_vma)def,name, allocation_done); + return (int) exp_get_vma (tree, (bfd_vma) def, name, allocation_done); } - bfd_vma exp_get_abs_int (tree, def, name, allocation_done) etree_type *tree; - int def; + int def ATTRIBUTE_UNUSED; char *name; lang_phase_type allocation_done; { @@ -975,11 +988,9 @@ exp_get_abs_int (tree, def, name, allocation_done) res = exp_fold_tree_no_dot (tree, abs_output_section, allocation_done); if (res.valid_p) - { - res.value += res.section->bfd_section->vma; - } - else { - einfo (_("%F%S non constant expression for %s\n"),name); - } + res.value += res.section->bfd_section->vma; + else + einfo (_("%F%S non constant expression for %s\n"), name); + return res.value; }