aboutsummaryrefslogtreecommitdiff
path: root/gas/symbols.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1993-07-14 22:21:25 +0000
committerIan Lance Taylor <ian@airs.com>1993-07-14 22:21:25 +0000
commit5868b1fe68831aacbf3934406182a20466aeec20 (patch)
treeb4ca8be5c6c65b1aeb7676181dd1d3f26128b06c /gas/symbols.c
parentbf5b632df7ee9b664c00a02296b9cdcbea634e55 (diff)
downloadgdb-5868b1fe68831aacbf3934406182a20466aeec20.zip
gdb-5868b1fe68831aacbf3934406182a20466aeec20.tar.gz
gdb-5868b1fe68831aacbf3934406182a20466aeec20.tar.bz2
* Removed sy_forward and replaced it with an undefined expression
as the value of a symbol. * struc-symbol.h (struct symbol): Removed sy_forward field. Added sy_resolved and sy_resolving single bit fields. * symbols.c (symbol_new): Don't initialize sy_forward field. (resolve_symbol_value): New function to adjust symbol value by fragment address, using recursion to resolve forward symbols. * symbols.h: Added prototype for new function. * read.c (pseudo_set): Set symbolP->sy_value to an undefined expression rather than setting symbolP->sy_forward. * write.c (write_object_file): Use resolve_symbol_value on symbols, keeping the common case (the old behaviour) inline. * config/obj-aout.c (obj_aout_frob_symbol): Removed sy_forward handling (subsumed by write.c change). * config/obj-coff.c, config/obj-coffbfd.c (obj_coff_val): Set sy_value rather than sy_forward. * config/obj-coffbfd.c (obj_coff_endef, yank_symbols): Check expression segment rather than sy_forward. (yank_symbols): Use resolve_symbol_value. (crawl_symbols): Removed extra pass over symbols. * config/obj-aout.c, config/obj-bout.c, config/obj-coff.c, config/obj-vms.c (obj_crawl_symbol_chain): Removed extra pass over symbols which handled sy_forward; use resolve_symbol_value instead. * config/obj-coff.h, config/obj-coffbfd.h (obj_frob_forward_symbol): Define. * config/obj-elf.c (obj_elf_stab_generic): Check expression segment rather than sy_forward. * config/obj-vms.c (VMS_Check_For_Main): Don't initialize sy_forward; do initialize sy_resolved and sy_resolving. * config/tc-hppa.h (STAB_FIXUP): Use sy_value, not sy_forward.
Diffstat (limited to 'gas/symbols.c')
-rw-r--r--gas/symbols.c50
1 files changed, 48 insertions, 2 deletions
diff --git a/gas/symbols.c b/gas/symbols.c
index 24fe3d8..05db99a 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -118,7 +118,6 @@ symbol_new (name, segment, value, frag)
symbol_clear_list_pointers(symbolP);
symbolP->sy_frag = frag;
- symbolP->sy_forward = NULL;
#ifndef BFD_ASSEMBLER
symbolP->sy_number = ~0;
symbolP->sy_name_offset = ~0;
@@ -566,6 +565,53 @@ verify_symbol_chain_2 (sym)
verify_symbol_chain (p, n);
}
+/* Resolve the value of a symbol. This is called during the final
+ pass over the symbol table to resolve any symbols with complex
+ values. */
+
+void
+resolve_symbol_value (symp)
+ symbolS *symp;
+{
+ if (symp->sy_resolved)
+ return;
+
+ if (symp->sy_resolving)
+ {
+ as_bad ("Symbol definition loop encountered at %s",
+ S_GET_NAME (symp));
+ S_SET_VALUE (symp, (valueT) 0);
+ }
+ else
+ {
+ symp->sy_resolving = 1;
+
+ if (symp->sy_value.X_seg == absolute_section)
+ S_SET_VALUE (symp, S_GET_VALUE (symp) + symp->sy_frag->fr_address);
+ else if (symp->sy_value.X_seg == undefined_section)
+ {
+ resolve_symbol_value (symp->sy_value.X_add_symbol);
+
+#ifdef obj_frob_forward_symbol
+ /* Some object formats need to forward the segment. */
+ obj_frob_forward_symbol (symp);
+#endif
+
+ S_SET_VALUE (symp,
+ (symp->sy_value.X_add_number
+ + symp->sy_frag->fr_address
+ + S_GET_VALUE (symp->sy_value.X_add_symbol)));
+ }
+ else
+ {
+ /* More cases need to be added here. */
+ abort ();
+ }
+ }
+
+ symp->sy_resolved = 1;
+}
+
#ifdef LOCAL_LABELS_DOLLAR
/* Dollar labels look like a number followed by a dollar sign. Eg, "42$".
@@ -953,7 +999,7 @@ S_GET_VALUE (s)
symbolS *s;
{
if (s->sy_value.X_seg != absolute_section)
- as_bad ("Attempt to get value of unresolved symbol");
+ as_bad ("Attempt to get value of unresolved symbol %s", S_GET_NAME (s));
return (valueT) s->sy_value.X_add_number;
}