diff options
author | Alan Modra <amodra@gmail.com> | 2001-05-22 10:23:50 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2001-05-22 10:23:50 +0000 |
commit | 6386f3a76709a4d55f17b30449280e1b3ed01ed9 (patch) | |
tree | d54b59808b66538a730f1e79a93186fdeafaf493 | |
parent | c801568a3aea2906c9134468c7389acab7f54763 (diff) | |
download | gdb-6386f3a76709a4d55f17b30449280e1b3ed01ed9.zip gdb-6386f3a76709a4d55f17b30449280e1b3ed01ed9.tar.gz gdb-6386f3a76709a4d55f17b30449280e1b3ed01ed9.tar.bz2 |
* symbols.c (resolve_symbol_value): Remove "finalize" param,
instead use finalize_syms directly. Don't treat expressions
specially with regard to finalize_syms. Update calls to self.
(resolve_local_symbol): Update call to resolve_symbol_value.
(S_GET_VALUE): Likewise. Return resolve_symbol_value if
!finalize_syms.
* symbols.h (resolve_symbol_value): Update prototype.
* config/obj-aout.c (obj_crawl_symbol_chain): Update call
to resolve_symbol_value.
* config/obj-bout.c (obj_crawl_symbol_chain): Likewise.
* config/obj-coff.c (do_relocs_for): Likewise.
(yank_symbols): Likewise.
(fixup_segment): Likewise.
* config/obj-vms.c (obj_crawl_symbol_chain): Likewise.
* config/tc-mips.c (md_convert_frag): Likewise.
* config/tc-ppc.c (ppc_frob_symbol): Likewise.
(ppc_fix_adjustable): Likewise.
* dwarf2dbg.c (dwarf2dbg_estimate_size_before_relax): Likewise.
(dwarf2dbg_convert_frag): Likewise.
* ehopt.c (eh_frame_estimate_size_before_relax): Likewise.
(eh_frame_convert_frag): Likewise.
* expr.c (make_expr_symbol): Likewise.
* write.c (adjust_reloc_syms): Likewise.
(write_object_file): Likewise.
(relax_segment): Likewise.
(fixup_segment): Likewise.
(finalize_syms): Init to zero, and update comment.
(write_object_file): Set finalize_syms to 1 rather than 2.
* doc/internals.texi (sy_value): Mention finalize_syms.
(S_GET_VALUE): Remove restriction on when S_GET_VALUE can be called.
-rw-r--r-- | gas/ChangeLog | 31 | ||||
-rw-r--r-- | gas/config/obj-aout.c | 2 | ||||
-rw-r--r-- | gas/config/obj-bout.c | 2 | ||||
-rw-r--r-- | gas/config/obj-coff.c | 8 | ||||
-rw-r--r-- | gas/config/obj-vms.c | 2 | ||||
-rw-r--r-- | gas/config/tc-mips.c | 2 | ||||
-rw-r--r-- | gas/config/tc-ppc.c | 18 | ||||
-rw-r--r-- | gas/doc/internals.texi | 11 | ||||
-rw-r--r-- | gas/dwarf2dbg.c | 4 | ||||
-rw-r--r-- | gas/ehopt.c | 4 | ||||
-rw-r--r-- | gas/expr.c | 2 | ||||
-rw-r--r-- | gas/symbols.c | 37 | ||||
-rw-r--r-- | gas/symbols.h | 4 | ||||
-rw-r--r-- | gas/write.c | 20 |
14 files changed, 84 insertions, 63 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 5938524..1102202 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,36 @@ 2001-05-22 Alan Modra <amodra@one.net.au> + * symbols.c (resolve_symbol_value): Remove "finalize" param, + instead use finalize_syms directly. Don't treat expressions + specially with regard to finalize_syms. Update calls to self. + (resolve_local_symbol): Update call to resolve_symbol_value. + (S_GET_VALUE): Likewise. Return resolve_symbol_value if + !finalize_syms. + * symbols.h (resolve_symbol_value): Update prototype. + * config/obj-aout.c (obj_crawl_symbol_chain): Update call + to resolve_symbol_value. + * config/obj-bout.c (obj_crawl_symbol_chain): Likewise. + * config/obj-coff.c (do_relocs_for): Likewise. + (yank_symbols): Likewise. + (fixup_segment): Likewise. + * config/obj-vms.c (obj_crawl_symbol_chain): Likewise. + * config/tc-mips.c (md_convert_frag): Likewise. + * config/tc-ppc.c (ppc_frob_symbol): Likewise. + (ppc_fix_adjustable): Likewise. + * dwarf2dbg.c (dwarf2dbg_estimate_size_before_relax): Likewise. + (dwarf2dbg_convert_frag): Likewise. + * ehopt.c (eh_frame_estimate_size_before_relax): Likewise. + (eh_frame_convert_frag): Likewise. + * expr.c (make_expr_symbol): Likewise. + * write.c (adjust_reloc_syms): Likewise. + (write_object_file): Likewise. + (relax_segment): Likewise. + (fixup_segment): Likewise. + (finalize_syms): Init to zero, and update comment. + (write_object_file): Set finalize_syms to 1 rather than 2. + * doc/internals.texi (sy_value): Mention finalize_syms. + (S_GET_VALUE): Remove restriction on when S_GET_VALUE can be called. + * config/tc-m68k.c (relaxable_symbol): Only treat external symbols as relaxable if embedded system, make weak syms non-relaxable. Move definition.. diff --git a/gas/config/obj-aout.c b/gas/config/obj-aout.c index 4bd323e..e5ffdf1 100644 --- a/gas/config/obj-aout.c +++ b/gas/config/obj-aout.c @@ -466,7 +466,7 @@ obj_crawl_symbol_chain (headers) S_SET_SEGMENT (symbolP, SEG_TEXT); } /* if pusing data into text */ - resolve_symbol_value (symbolP, finalize_syms); + resolve_symbol_value (symbolP); /* Skip symbols which were equated to undefined or common symbols. */ diff --git a/gas/config/obj-bout.c b/gas/config/obj-bout.c index 22ff671..f13ddaf 100644 --- a/gas/config/obj-bout.c +++ b/gas/config/obj-bout.c @@ -260,7 +260,7 @@ obj_crawl_symbol_chain (headers) S_SET_SEGMENT (symbolP, SEG_TEXT); } /* if pusing data into text */ - resolve_symbol_value (symbolP, finalize_syms); + resolve_symbol_value (symbolP); /* Skip symbols which were equated to undefined or common symbols. */ diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c index 37aa640..1961fec 100644 --- a/gas/config/obj-coff.c +++ b/gas/config/obj-coff.c @@ -1972,7 +1972,7 @@ do_relocs_for (abfd, h, file_cursor) /* Turn the segment of the symbol into an offset. */ if (symbol_ptr) { - resolve_symbol_value (symbol_ptr, finalize_syms); + resolve_symbol_value (symbol_ptr); if (! symbol_ptr->sy_resolved) { char *file; @@ -2953,7 +2953,7 @@ yank_symbols () S_SET_SEGMENT (symbolP, SEG_E0); } /* push data into text */ - resolve_symbol_value (symbolP, finalize_syms); + resolve_symbol_value (symbolP); if (S_GET_STORAGE_CLASS (symbolP) == C_NULL) { @@ -4186,7 +4186,7 @@ fixup_segment (segP, this_segment_type) /* Make sure the symbols have been resolved; this may not have happened if these are expression symbols. */ if (add_symbolP != NULL && ! add_symbolP->sy_resolved) - resolve_symbol_value (add_symbolP, finalize_syms); + resolve_symbol_value (add_symbolP); if (add_symbolP != NULL) { @@ -4216,7 +4216,7 @@ fixup_segment (segP, this_segment_type) } if (sub_symbolP != NULL && ! sub_symbolP->sy_resolved) - resolve_symbol_value (sub_symbolP, finalize_syms); + resolve_symbol_value (sub_symbolP); if (add_symbolP != NULL && add_symbolP->sy_mri_common) diff --git a/gas/config/obj-vms.c b/gas/config/obj-vms.c index 3d16875..969b96e 100644 --- a/gas/config/obj-vms.c +++ b/gas/config/obj-vms.c @@ -532,7 +532,7 @@ obj_crawl_symbol_chain (headers) symbolPP = &symbol_rootP; /* -> last symbol chain link. */ while ((symbolP = *symbolPP) != NULL) { - resolve_symbol_value (symbolP, finalize_syms); + resolve_symbol_value (symbolP); /* OK, here is how we decide which symbols go out into the brave new symtab. Symbols that do are: diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 907dda4..0e1ad87 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -11356,7 +11356,7 @@ md_convert_frag (abfd, asec, fragp) ext = false; } - resolve_symbol_value (fragp->fr_symbol, finalize_syms); + resolve_symbol_value (fragp->fr_symbol); val = S_GET_VALUE (fragp->fr_symbol); if (op->pcrel) { diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c index d1f61e7..0860645 100644 --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -4221,7 +4221,7 @@ ppc_frob_symbol (sym) ppc_last_function = sym; if (symbol_get_tc (sym)->size != (symbolS *) NULL) { - resolve_symbol_value (symbol_get_tc (sym)->size, finalize_syms); + resolve_symbol_value (symbol_get_tc (sym)->size); SA_SET_SYM_FSIZE (sym, (long) S_GET_VALUE (symbol_get_tc (sym)->size)); } @@ -4281,7 +4281,7 @@ ppc_frob_symbol (sym) - S_GET_VALUE (sym)); else { - resolve_symbol_value (symbol_get_tc (sym)->next, finalize_syms); + resolve_symbol_value (symbol_get_tc (sym)->next); a->x_csect.x_scnlen.l = (S_GET_VALUE (symbol_get_tc (sym)->next) - S_GET_VALUE (sym)); } @@ -4334,7 +4334,7 @@ ppc_frob_symbol (sym) } else { - resolve_symbol_value (next, finalize_syms); + resolve_symbol_value (next); a->x_csect.x_scnlen.l = (S_GET_VALUE (next) - S_GET_VALUE (sym)); } @@ -4365,8 +4365,7 @@ ppc_frob_symbol (sym) { while (symbol_get_tc (csect)->next != (symbolS *) NULL) { - resolve_symbol_value (symbol_get_tc (csect)->next, - finalize_syms); + resolve_symbol_value (symbol_get_tc (csect)->next); if (S_GET_VALUE (symbol_get_tc (csect)->next) > S_GET_VALUE (sym)) break; @@ -4412,7 +4411,7 @@ ppc_frob_symbol (sym) /* The value is the offset from the enclosing csect. */ block = symbol_get_tc (sym)->within; csect = symbol_get_tc (block)->within; - resolve_symbol_value (csect, finalize_syms); + resolve_symbol_value (csect); S_SET_VALUE (sym, S_GET_VALUE (sym) - S_GET_VALUE (csect)); } else if (S_GET_STORAGE_CLASS (sym) == C_BINCL @@ -4629,7 +4628,7 @@ ppc_fix_adjustable (fix) { valueT val; - resolve_symbol_value (fix->fx_addsy, finalize_syms); + resolve_symbol_value (fix->fx_addsy); val = S_GET_VALUE (fix->fx_addsy); if (ppc_toc_csect != (symbolS *) NULL && fix->fx_addsy != (symbolS *) NULL @@ -4649,7 +4648,7 @@ ppc_fix_adjustable (fix) continue; if (symbol_get_tc (sy)->class != XMC_TC) break; - resolve_symbol_value (sy, finalize_syms); + resolve_symbol_value (sy); if (val == S_GET_VALUE (sy)) { fix->fx_addsy = sy; @@ -4733,8 +4732,7 @@ ppc_fix_adjustable (fix) && S_GET_SEGMENT (fix->fx_addsy) == bss_section && ! S_IS_EXTERNAL (fix->fx_addsy)) { - resolve_symbol_value (symbol_get_frag (fix->fx_addsy)->fr_symbol, - finalize_syms); + resolve_symbol_value (symbol_get_frag (fix->fx_addsy)->fr_symbol); fix->fx_offset += (S_GET_VALUE (fix->fx_addsy) - S_GET_VALUE (symbol_get_frag (fix->fx_addsy)->fr_symbol)); diff --git a/gas/doc/internals.texi b/gas/doc/internals.texi index eebb9bb..013b19c 100644 --- a/gas/doc/internals.texi +++ b/gas/doc/internals.texi @@ -130,11 +130,12 @@ Symbol structures contain the following fields: @item sy_value This is an @code{expressionS} that describes the value of the symbol. It might refer to one or more other symbols; if so, its true value may not be known -until @code{resolve_symbol_value} is called in @code{write_object_file}. +until @code{resolve_symbol_value} is called with @var{finalize_syms} non-zero +in @code{write_object_file}. The expression is often simply a constant. Before @code{resolve_symbol_value} -is called, the value is the offset from the frag (@pxref{Frags}). Afterward, -the frag address has been added in. +is called with @var{finalize_syms} set, the value is the offset from the frag +(@pxref{Frags}). Afterward, the frag address has been added in. @item sy_resolved This field is non-zero if the symbol's value has been completely resolved. It @@ -208,9 +209,7 @@ Set the symbol's value. @item S_GET_VALUE @cindex S_GET_VALUE Get the symbol's value. This will cause @code{resolve_symbol_value} to be -called if necessary, so @code{S_GET_VALUE} should only be called when it is -safe to resolve symbols (i.e., after the entire input file has been read and -all symbols have been defined). +called if necessary. @item S_SET_SEGMENT @cindex S_SET_SEGMENT diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c index 8607e21..ed2c710 100644 --- a/gas/dwarf2dbg.c +++ b/gas/dwarf2dbg.c @@ -772,7 +772,7 @@ dwarf2dbg_estimate_size_before_relax (frag) offsetT addr_delta; int size; - addr_delta = resolve_symbol_value (frag->fr_symbol, 0); + addr_delta = resolve_symbol_value (frag->fr_symbol); size = size_inc_line_addr (frag->fr_offset, addr_delta); frag->fr_subtype = size; @@ -806,7 +806,7 @@ dwarf2dbg_convert_frag (frag) { offsetT addr_diff; - addr_diff = resolve_symbol_value (frag->fr_symbol, finalize_syms); + addr_diff = resolve_symbol_value (frag->fr_symbol); /* fr_var carries the max_chars that we created the fragment with. fr_subtype carries the current expected length. We must, of diff --git a/gas/ehopt.c b/gas/ehopt.c index c25fd51..ad6e028 100644 --- a/gas/ehopt.c +++ b/gas/ehopt.c @@ -462,7 +462,7 @@ eh_frame_estimate_size_before_relax (frag) int ca = frag->fr_subtype >> 3; int ret; - diff = resolve_symbol_value (frag->fr_symbol, 0); + diff = resolve_symbol_value (frag->fr_symbol); if (ca > 0 && diff % ca == 0 && diff / ca < 0x40) ret = 0; @@ -508,7 +508,7 @@ eh_frame_convert_frag (frag) loc4_frag = (fragS *) frag->fr_opcode; loc4_fix = (int) frag->fr_offset; - diff = resolve_symbol_value (frag->fr_symbol, finalize_syms); + diff = resolve_symbol_value (frag->fr_symbol); switch (frag->fr_subtype & 7) { @@ -105,7 +105,7 @@ make_expr_symbol (expressionP) symbol_set_value_expression (symbolP, expressionP); if (expressionP->X_op == O_constant) - resolve_symbol_value (symbolP, finalize_syms); + resolve_symbol_value (symbolP); n = (struct expr_symbol_line *) xmalloc (sizeof *n); n->sym = symbolP; diff --git a/gas/symbols.c b/gas/symbols.c index 98623eb..3640723 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -831,9 +831,8 @@ verify_symbol_chain_2 (sym) values. */ valueT -resolve_symbol_value (symp, finalize) +resolve_symbol_value (symp) symbolS *symp; - int finalize; { int resolved; valueT final_val; @@ -850,7 +849,7 @@ resolve_symbol_value (symp, finalize) final_val = (local_symbol_get_frag (locsym)->fr_address + locsym->lsy_offset) / bfd_octets_per_byte (stdoutput); - if (finalize) + if (finalize_syms) { locsym->lsy_offset = final_val; local_symbol_mark_resolved (locsym); @@ -870,14 +869,10 @@ resolve_symbol_value (symp, finalize) resolved = 0; final_seg = S_GET_SEGMENT (symp); - /* Expressions aren't really symbols, so don't finalize their values - until relaxation is complete. */ - if (final_seg == expr_section && finalize != 2) - finalize = 0; if (symp->sy_resolving) { - if (finalize) + if (finalize_syms) as_bad (_("Symbol definition loop encountered at %s"), S_GET_NAME (symp)); final_val = 0; @@ -917,7 +912,7 @@ resolve_symbol_value (symp, finalize) case O_symbol: case O_symbol_rva: - left = resolve_symbol_value (add_symbol, finalize); + left = resolve_symbol_value (add_symbol); do_symbol: if (symp->sy_mri_common) @@ -929,7 +924,7 @@ resolve_symbol_value (symp, finalize) break; } - if (finalize && final_val == 0) + if (finalize_syms && final_val == 0) { if (LOCAL_SYMBOL_CHECK (add_symbol)) add_symbol = local_symbol_convert ((struct local_symbol *) @@ -945,7 +940,7 @@ resolve_symbol_value (symp, finalize) is equated. */ if (! S_IS_DEFINED (add_symbol) || S_IS_COMMON (add_symbol)) { - if (finalize) + if (finalize_syms) { S_SET_SEGMENT (symp, S_GET_SEGMENT (add_symbol)); symp->sy_value.X_op = O_symbol; @@ -969,7 +964,7 @@ resolve_symbol_value (symp, finalize) case O_uminus: case O_bit_not: case O_logical_not: - left = resolve_symbol_value (add_symbol, finalize); + left = resolve_symbol_value (add_symbol); if (op == O_uminus) left = -left; @@ -1004,8 +999,8 @@ resolve_symbol_value (symp, finalize) case O_gt: case O_logical_and: case O_logical_or: - left = resolve_symbol_value (add_symbol, finalize); - right = resolve_symbol_value (op_symbol, finalize); + left = resolve_symbol_value (add_symbol); + right = resolve_symbol_value (op_symbol); seg_left = S_GET_SEGMENT (add_symbol); seg_right = S_GET_SEGMENT (op_symbol); @@ -1047,7 +1042,7 @@ resolve_symbol_value (symp, finalize) && (op != O_subtract || seg_left != seg_right || seg_left == undefined_section) - && finalize) + && finalize_syms) { char *file; unsigned int line; @@ -1089,7 +1084,7 @@ resolve_symbol_value (symp, finalize) { /* If seg_right is not absolute_section, then we've already issued a warning about using a bad symbol. */ - if (seg_right == absolute_section && finalize) + if (seg_right == absolute_section && finalize_syms) { char *file; unsigned int line; @@ -1149,7 +1144,7 @@ resolve_symbol_value (symp, finalize) symp->sy_resolving = 0; } - if (finalize) + if (finalize_syms) { S_SET_VALUE (symp, final_val); @@ -1163,7 +1158,7 @@ resolve_symbol_value (symp, finalize) exit_dont_set_value: /* Don't worry if we can't resolve an expr_section symbol. */ - if (finalize) + if (finalize_syms) { if (resolved) symp->sy_resolved = 1; @@ -1190,7 +1185,7 @@ resolve_local_symbol (key, value) PTR value; { if (value != NULL) - resolve_symbol_value (value, finalize_syms); + resolve_symbol_value (value); } #endif @@ -1583,8 +1578,8 @@ S_GET_VALUE (s) if (!s->sy_resolved && s->sy_value.X_op != O_constant) { - valueT val = resolve_symbol_value (s, finalize_syms); - if (finalize_syms != 2 && S_GET_SEGMENT (s) == expr_section) + valueT val = resolve_symbol_value (s); + if (!finalize_syms) return val; } if (s->sy_value.X_op != O_constant) diff --git a/gas/symbols.h b/gas/symbols.h index e481d54..e798905 100644 --- a/gas/symbols.h +++ b/gas/symbols.h @@ -1,5 +1,5 @@ /* symbols.h - - Copyright 1987, 1990, 1992, 1993, 1994, 1995, 1997, 1999, 2000 + Copyright 1987, 1990, 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -61,7 +61,7 @@ void local_colon PARAMS ((int n)); void symbol_begin PARAMS ((void)); void symbol_print_statistics PARAMS ((FILE *)); void symbol_table_insert PARAMS ((symbolS * symbolP)); -valueT resolve_symbol_value PARAMS ((symbolS *, int)); +valueT resolve_symbol_value PARAMS ((symbolS *)); void resolve_local_symbol_values PARAMS ((void)); void print_symbol_value PARAMS ((symbolS *)); diff --git a/gas/write.c b/gas/write.c index 151f1cf..7e9317f 100644 --- a/gas/write.c +++ b/gas/write.c @@ -61,10 +61,8 @@ extern CONST int md_short_jump_size; extern CONST int md_long_jump_size; #endif -/* Used to control final evaluation of expressions that are more - complex than symbol + constant. 1 means set final value for simple - expressions, 2 means set final value for more complex expressions. */ -int finalize_syms = 1; +/* Used to control final evaluation of expressions. */ +int finalize_syms = 0; int symbol_table_frozen; void print_fixup PARAMS ((fixS *)); @@ -760,10 +758,10 @@ adjust_reloc_syms (abfd, sec, xxx) symbols, though, since they are not in the regular symbol table. */ if (sym != NULL) - resolve_symbol_value (sym, finalize_syms); + resolve_symbol_value (sym); if (fixp->fx_subsy != NULL) - resolve_symbol_value (fixp->fx_subsy, finalize_syms); + resolve_symbol_value (fixp->fx_subsy); /* If this symbol is equated to an undefined symbol, convert the fixup to being against that symbol. */ @@ -1582,7 +1580,7 @@ write_object_file () #endif /* BFD_ASSEMBLER */ /* Relaxation has completed. Freeze all syms. */ - finalize_syms = 2; + finalize_syms = 1; #if defined (BFD_ASSEMBLER) && defined (OBJ_COFF) && defined (TE_GO32) /* Now that the segments have their final sizes, run through the @@ -1902,7 +1900,7 @@ write_object_file () symbolS *symp; for (symp = symbol_rootP; symp; symp = symbol_next (symp)) - resolve_symbol_value (symp, finalize_syms); + resolve_symbol_value (symp); } resolve_local_symbol_values (); @@ -1950,7 +1948,7 @@ write_object_file () /* Do it again, because adjust_reloc_syms might introduce more symbols. They'll probably only be section symbols, but they'll still need to have the values computed. */ - resolve_symbol_value (symp, finalize_syms); + resolve_symbol_value (symp); /* Skip symbols which were equated to undefined or common symbols. */ @@ -2488,7 +2486,7 @@ relax_segment (segment_frag_root, segment) valueT value; int size; - value = resolve_symbol_value (fragP->fr_symbol, 0); + value = resolve_symbol_value (fragP->fr_symbol); size = sizeof_leb128 (value, fragP->fr_subtype); growth = size - fragP->fr_offset; fragP->fr_offset = size; @@ -2611,7 +2609,7 @@ fixup_segment (fixP, this_segment_type) if (sub_symbolP) { - resolve_symbol_value (sub_symbolP, finalize_syms); + resolve_symbol_value (sub_symbolP); if (add_symbolP == NULL || add_symbol_segment == absolute_section) { if (add_symbolP != NULL) |