summaryrefslogtreecommitdiff
path: root/gas/ecoff.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1999-06-03 00:29:48 +0000
committerIan Lance Taylor <ian@airs.com>1999-06-03 00:29:48 +0000
commitf01bc8ec16adbd2e3472c529ef1e7ec9bd20c5d5 (patch)
treee4159decba717ad1b0b7cf95160672b8e0572b22 /gas/ecoff.c
parent10538a6f4e0d0c5b5ba02c45a5247bcfe220c5ce (diff)
downloadbinutils-redhat-f01bc8ec16adbd2e3472c529ef1e7ec9bd20c5d5.tar.gz
Add support for storing local symbols in a small structure to save
memory when assembling large files. * as.h: Don't include struc-symbol.h. (symbolS): Add typedef. * symbols.c: Include struc-symbol.h. (local_hash): New static variable. (save_symbol_name): New static function, from symbol_create. (symbol_create): Call save_symbol_name. (local_symbol_count): New static variable. (local_symbol_conversion_count): Likewise. (LOCAL_SYMBOL_CHECK): Define. (local_symbol_make): New static function. (local_symbol_convert): New static function. (colon): Handle local symbols. Create local symbol for local label name. (symbol_table_insert): Handle local symbols. (symbol_find_or_make): Create local symbol for local label name. (symbol_find_base): Check for local symbol. (symbol_append, symbol_insert): Check for local symbols. (symbol_clear_list_pointers, symbol_remove): Likewise. (verify_symbol_chain): Likewise. (copy_symbol_attributes): Likewise. (resolve_symbol_value): Handle local symbols. (resolve_local_symbol): New static function. (resolve_local_symbol_values): New function. (S_GET_VALUE, S_SET_VALUE): Handle local symbols. (S_IS_FUNCTION, S_IS_EXTERNAL, S_IS_WEAK, S_IS_COMMON): Likewise. (S_IS_DEFINED, S_IS_DEBUG, S_IS_LOCAL, S_GET_NAME): Likewise. (S_GET_SEGMENT, S_SET_SEGMENT, S_SET_EXTERNAL): Likewise. (S_CLEAR_EXTERNAL, S_SET_WEAK, S_SET_NAME): Likewise. (symbol_previous, symbol_next): New functions. (symbol_get_value_expression): Likewise. (symbol_set_value_expression): Likewise. (symbol_set_frag, symbol_get_frag): Likewise. (symbol_mark_used, symbol_clear_used, symbol_used_p): Likewise. (symbol_mark_used_in_reloc): Likewise. (symbol_clear_used_in_reloc, symbol_used_in_reloc_p): Likewise. (symbol_mark_mri_common, symbol_clear_mri_common): Likewise. (symbol_mri_common_p): Likewise. (symbol_mark_written, symbol_clear_written): Likewise. (symbol_written_p): Likewise. (symbol_mark_resolved, symbol_resolved_p): Likewise. (symbol_section_p, symbol_equated_p): Likewise. (symbol_constant_p): Likewise. (symbol_get_bfdsym, symbol_set_bfdsym): Likewise. (symbol_get_obj, symbol_set_obj): Likewise. (symbol_get_tc, symbol_set_tc): Likewise. (symbol_begin): Initialize local_hash. (print_symbol_value_1): Handle local symbols. (symbol_print_statistics): Print local symbol statistics. * symbols.h: Include "struc-symbol.h" if not BFD_ASSEMBLER. Declare new symbols.c functions. Move many declarations here from struc-symbol.h. (SYMBOLS_NEED_BACKPOINTERS): Define if needed. * struc-symbol.h (SYMBOLS_NEED_BACKPOINTERS): Don't set. (struct symbol): Move bsym to make it clearly the first field. Remove TARGET_SYMBOL_FIELDS. (symbolS): Don't typedef. (struct broken_word): Remove. (N_TYPE_seg, seg_N_TYPE): Move to symbol.h. (SEGMENT_TO_SYMBOL_TYPE, N_REGISTER): Likewise. (symbol_clear_list_pointers): Likewise. (symbol_insert, symbol_remove): Likewise. (symbol_previous, symbol_append): Likewise. (verify_symbol_chain, verify_symbol_chain_2): Likewise. (struct local_symbol): Define. (local_symbol_converted_p, local_symbol_mark_converted): Define. (local_symbol_resolved_p, local_symbol_mark_resolved): Define. (local_symbol_get_frag, local_symbol_set_frag): Define. (local_symbol_get_real_symbol): Define. (local_symbol_set_real_symbol): Define. Define. * write.c (write_object_file): Call resolve_local_symbol_values. * config/obj-ecoff.h (OBJ_SYMFIELD_TYPE): Define. (TARGET_SYMBOL_FIELDS): Don't define. * config/obj-elf.h (OBJ_SYMFIELD_TYPE): Add local field. If ECOFF_DEBUGGING, add ECOFF fields. (ELF_TARGET_SYMBOL_FIELDS, TARGET_SYMBOL_FIELDS): Don't define. * config/obj-multi.h (struct elf_obj_sy): Add local field. If ECOFF_DEBUGGING, add ECOFF fields. (ELF_TARGET_SYMBOL_FIELDS, TARGET_SYMBOL_FIELDS): Don't define. (ECOFF_DEBUG_TARGET_SYMBOL_FIELDS): Don't define. * config/tc-mcore.h: Don't include struc-symbol.h. (TARGET_SYMBOL_FIELDS): Don't define. (struct mcore_tc_sy): Define. (TC_SYMFIELD_TYPE): Define. * Many files: Use symbolS instead of struct symbol. Use new accessor functions rather than referring to symbolS fields directly. * read.c (s_mri_common): Don't add in value of line_label. * config/tc-mips.c (md_apply_fix): Correct parenthesization when checking for SEC_LINK_ONCE. * config/tc-sh.h (sh_fix_adjustable): Declare.
Diffstat (limited to 'gas/ecoff.c')
-rw-r--r--gas/ecoff.c66
1 files changed, 37 insertions, 29 deletions
diff --git a/gas/ecoff.c b/gas/ecoff.c
index d127f52f75..310d6672ef 100644
--- a/gas/ecoff.c
+++ b/gas/ecoff.c
@@ -1,5 +1,5 @@
/* ECOFF debugging support.
- Copyright (C) 1993, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
+ Copyright (C) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
Contributed by Cygnus Support.
This file was put together by Ian Lance Taylor <ian@cygnus.com>. A
good deal of it comes directly from mips-tfile.c, by Michael
@@ -1513,6 +1513,8 @@ void
ecoff_symbol_new_hook (symbolP)
symbolS *symbolP;
{
+ OBJ_SYMFIELD_TYPE *obj;
+
/* Make sure that we have a file pointer, but only if we have seen a
file. If we haven't seen a file, then this is a probably special
symbol created by md_begin which may required special handling at
@@ -1521,9 +1523,10 @@ ecoff_symbol_new_hook (symbolP)
if (cur_file_ptr == (efdr_t *) NULL
&& seen_at_least_1_file ())
add_file ((const char *) NULL, 0, 1);
- symbolP->ecoff_file = cur_file_ptr;
- symbolP->ecoff_symbol = NULL;
- symbolP->ecoff_extern_size = 0;
+ obj = symbol_get_obj (symbolP);
+ obj->ecoff_file = cur_file_ptr;
+ obj->ecoff_symbol = NULL;
+ obj->ecoff_extern_size = 0;
}
/* Add a page to a varray object. */
@@ -1643,7 +1646,7 @@ add_ecoff_symbol (str, type, storage, sym_value, addend, value, indx)
psym->name = str;
psym->as_sym = sym_value;
if (sym_value != (symbolS *) NULL)
- sym_value->ecoff_symbol = psym;
+ symbol_get_obj (sym_value)->ecoff_symbol = psym;
psym->addend = addend;
psym->file_ptr = cur_file_ptr;
psym->proc_ptr = cur_proc_ptr;
@@ -2170,7 +2173,7 @@ add_procedure (func)
/* Set the BSF_FUNCTION flag for the symbol. */
sym = symbol_find_or_make (func);
- sym->bsym->flags |= BSF_FUNCTION;
+ symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION;
/* Push the start of the function. */
new_proc_ptr->sym = add_ecoff_symbol ((const char *) NULL, st_Proc, sc_Text,
@@ -3151,7 +3154,7 @@ ecoff_directive_extern (ignore)
++input_line_pointer;
size = get_absolute_expression ();
- symbolp->ecoff_extern_size = size;
+ symbol_get_obj (symbolp)->ecoff_extern_size = size;
}
/* Parse .file directives. */
@@ -3433,7 +3436,7 @@ ecoff_directive_weakext (ignore)
ignore_rest_of_line();
return;
}
- symbolP->sy_value = exp;
+ symbol_set_value_expression (symbolP, &exp);
}
}
@@ -3616,12 +3619,12 @@ ecoff_stab (sec, what, string, type, other, desc)
ECOFF symbol. We want to compute the type of the ECOFF symbol
independently. */
if (sym != (symbolS *) NULL)
- hold = sym->ecoff_symbol;
+ hold = symbol_get_obj (sym)->ecoff_symbol;
(void) add_ecoff_symbol (string, st, sc, sym, addend, value, indx);
if (sym != (symbolS *) NULL)
- sym->ecoff_symbol = hold;
+ symbol_get_obj (sym)->ecoff_symbol = hold;
/* Restore normal file type. */
cur_file_ptr = save_file_ptr;
@@ -3658,7 +3661,7 @@ ecoff_frob_symbol (sym)
}
/* Double check weak symbols. */
- if (sym->bsym->flags & BSF_WEAK)
+ if (S_IS_WEAK (sym))
{
if (S_IS_COMMON (sym))
as_bad (_("Symbol `%s' can not be both weak and common"),
@@ -4084,7 +4087,8 @@ ecoff_build_symbols (backend, buf, bufend, offset)
|| S_IS_WEAK (as_sym)
|| ! S_IS_DEFINED (as_sym)))
{
- if ((as_sym->bsym->flags & BSF_FUNCTION) != 0)
+ if ((symbol_get_bfdsym (as_sym)->flags
+ & BSF_FUNCTION) != 0)
st = st_Proc;
else
st = st_Global;
@@ -4096,18 +4100,19 @@ ecoff_build_symbols (backend, buf, bufend, offset)
if (! S_IS_DEFINED (as_sym))
{
- if (as_sym->ecoff_extern_size == 0
- || (as_sym->ecoff_extern_size
- > bfd_get_gp_size (stdoutput)))
+ valueT s;
+
+ s = symbol_get_obj (as_sym)->ecoff_extern_size;
+ if (s == 0
+ || s > bfd_get_gp_size (stdoutput))
sc = sc_Undefined;
else
{
sc = sc_SUndefined;
- sym_ptr->ecoff_sym.asym.value =
- as_sym->ecoff_extern_size;
+ sym_ptr->ecoff_sym.asym.value = s;
}
#ifdef S_SET_SIZE
- S_SET_SIZE (as_sym, as_sym->ecoff_extern_size);
+ S_SET_SIZE (as_sym, s);
#endif
}
else if (S_IS_COMMON (as_sym))
@@ -4290,7 +4295,7 @@ ecoff_build_symbols (backend, buf, bufend, offset)
case this is an external symbol. Note that this
destroys the asym.index field. */
if (as_sym != (symbolS *) NULL
- && as_sym->ecoff_symbol == sym_ptr)
+ && symbol_get_obj (as_sym)->ecoff_symbol == sym_ptr)
{
if ((sym_ptr->ecoff_sym.asym.st == st_Proc
|| sym_ptr->ecoff_sym.asym.st == st_StaticProc)
@@ -4659,7 +4664,7 @@ ecoff_setup_ext ()
for (sym = symbol_rootP; sym != (symbolS *) NULL; sym = symbol_next (sym))
{
- if (sym->ecoff_symbol == NULL)
+ if (symbol_get_obj (sym)->ecoff_symbol == NULL)
continue;
/* If this is a local symbol, then force the fields to zero. */
@@ -4667,13 +4672,16 @@ ecoff_setup_ext ()
&& ! S_IS_WEAK (sym)
&& S_IS_DEFINED (sym))
{
- sym->ecoff_symbol->ecoff_sym.asym.value = 0;
- sym->ecoff_symbol->ecoff_sym.asym.st = (int) st_Nil;
- sym->ecoff_symbol->ecoff_sym.asym.sc = (int) sc_Nil;
- sym->ecoff_symbol->ecoff_sym.asym.index = indexNil;
+ struct localsym *lsym;
+
+ lsym = symbol_get_obj (sym)->ecoff_symbol;
+ lsym->ecoff_sym.asym.value = 0;
+ lsym->ecoff_sym.asym.st = (int) st_Nil;
+ lsym->ecoff_sym.asym.sc = (int) sc_Nil;
+ lsym->ecoff_sym.asym.index = indexNil;
}
- obj_ecoff_set_ext (sym, &sym->ecoff_symbol->ecoff_sym);
+ obj_ecoff_set_ext (sym, &symbol_get_obj (sym)->ecoff_symbol->ecoff_sym);
}
}
@@ -4723,12 +4731,12 @@ ecoff_build_debug (hdr, bufp, backend)
cur_proc_ptr = (proc_t *) NULL;
for (sym = symbol_rootP; sym != (symbolS *) NULL; sym = symbol_next (sym))
{
- if (sym->ecoff_symbol != NULL
- || sym->ecoff_file == (efdr_t *) NULL
- || (sym->bsym->flags & BSF_SECTION_SYM) != 0)
+ if (symbol_get_obj (sym)->ecoff_symbol != NULL
+ || symbol_get_obj (sym)->ecoff_file == (efdr_t *) NULL
+ || (symbol_get_bfdsym (sym)->flags & BSF_SECTION_SYM) != 0)
continue;
- cur_file_ptr = sym->ecoff_file;
+ cur_file_ptr = symbol_get_obj (sym)->ecoff_file;
add_ecoff_symbol ((const char *) NULL, st_Nil, sc_Nil, sym,
(bfd_vma) 0, S_GET_VALUE (sym), indexNil);
}