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.
+1999-06-03 Ian Lance Taylor <ian@zembu.com>
+
+ 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.
+
+ * app.c (input_buffer): New static variable.
+ (app_push): Save saved_input in allocated buffer.
+ (app_pop): Restored saved_input.
+ (do_scrub_chars): Change get parameter to take char * and int as
+ arguments. Change GET macro to pass input_buffer to get
+ function. Don't save input into allocated buffer.
+ * as.h (do_scrub_chars): Update declaration.
+ * input-file.c (input_file_get): Change to take char * and int.
+ Read data into passed in buffer. Remove static buffer.
+ * read.c (scrub_from_string): Change to take char * and int. Copy
+ data into passed in buffer.
+
+ * hash.h: Neaten. Declare hash_traverse.
+ * hash.c: Complete rewrite based on BFD hashing code.
+ * gasp.c (chunksize): New variable.
+ * macro.c (macro_expand_body): Call hash_jam with NULL rather than
+ hash_delete.
+
1999-05-28 Nick Clifton <nickc@cygnus.com>
* config/tc-arm.c (md_apply_fix3): Add pipeline offset into reloc
/* cond.c - conditional assembly pseudo-ops, and .include
- Copyright (C) 1990, 91, 92, 93, 95, 96, 97, 1998
+ Copyright (C) 1990, 91, 92, 93, 95, 96, 97, 98, 1999
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
int arg;
{
register char *name; /* points to name of symbol */
- register struct symbol *symbolP; /* Points to symbol */
+ register symbolS *symbolP; /* Points to symbol */
struct conditional_frame cframe;
SKIP_WHITESPACE (); /* Leading whitespace is part of operand. */
/* a.out object file format
- Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 1996
+ Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
the GNU General Public License for more details.
-You should have received a copy of the GNU General Public
-License along with GAS; see the file COPYING. If not, write
-to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+You should have received a copy of the GNU General Public License
+along with GAS; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
#include "as.h"
#ifdef BFD_ASSEMBLER
asection *sec;
int desc, type, other;
- flags = sym->bsym->flags;
+ flags = symbol_get_bfdsym (sym)->flags;
desc = S_GET_DESC (sym);
type = S_GET_TYPE (sym);
other = S_GET_OTHER (sym);
- sec = sym->bsym->section;
+ sec = S_GET_SEGMENT (sym);
/* Only frob simple symbols this way right now. */
if (! (type & ~ (N_TYPE | N_EXT)))
{
if (type == (N_UNDF | N_EXT)
&& sec == &bfd_abs_section)
- sym->bsym->section = sec = bfd_und_section_ptr;
+ {
+ sec = bfd_und_section_ptr;
+ S_SET_SEGMENT (sym, sec);
+ }
if ((type & N_TYPE) != N_INDR
&& (type & N_TYPE) != N_SETA
case N_SETB:
/* Set the debugging flag for constructor symbols so that
BFD leaves them alone. */
- sym->bsym->flags |= BSF_DEBUGGING;
+ symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
/* You can't put a common symbol in a set. The way a set
element works is that the symbol has a definition and a
break;
case N_INDR:
/* Put indirect symbols in the indirect section. */
- sym->bsym->section = bfd_ind_section_ptr;
- sym->bsym->flags |= BSF_INDIRECT;
+ S_SET_SEGMENT (sym, bfd_ind_section_ptr);
+ symbol_get_bfdsym (sym)->flags |= BSF_INDIRECT;
if (type & N_EXT)
{
- sym->bsym->flags |= BSF_EXPORT;
- sym->bsym->flags &=~ BSF_LOCAL;
+ symbol_get_bfdsym (sym)->flags |= BSF_EXPORT;
+ symbol_get_bfdsym (sym)->flags &=~ BSF_LOCAL;
}
break;
case N_WARNING:
/* Mark warning symbols. */
- sym->bsym->flags |= BSF_WARNING;
+ symbol_get_bfdsym (sym)->flags |= BSF_WARNING;
break;
}
}
else
{
- sym->bsym->flags |= BSF_DEBUGGING;
+ symbol_get_bfdsym (sym)->flags |= BSF_DEBUGGING;
}
S_SET_TYPE (sym, type);
/* 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"),
/* obj-aout.h, a.out object file format for gas, the assembler.
- Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 1998
+ Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 98, 1999
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
#ifdef BFD_ASSEMBLER
-#define S_SET_OTHER(S,V) (aout_symbol((S)->bsym)->other = (V))
-#define S_SET_TYPE(S,T) (aout_symbol((S)->bsym)->type = (T))
-#define S_SET_DESC(S,D) (aout_symbol((S)->bsym)->desc = (D))
-#define S_GET_OTHER(S) (aout_symbol((S)->bsym)->other)
-#define S_GET_TYPE(S) (aout_symbol((S)->bsym)->type)
-#define S_GET_DESC(S) (aout_symbol((S)->bsym)->desc)
+#define S_SET_OTHER(S,V) \
+ (aout_symbol (symbol_get_bfdsym (S))->other = (V))
+#define S_SET_TYPE(S,T) \
+ (aout_symbol (symbol_get_bfdsym (S))->type = (T))
+#define S_SET_DESC(S,D) \
+ (aout_symbol (symbol_get_bfdsym (S))->desc = (D))
+#define S_GET_OTHER(S) \
+ (aout_symbol (symbol_get_bfdsym (S))->other)
+#define S_GET_TYPE(S) \
+ (aout_symbol (symbol_get_bfdsym (S))->type)
+#define S_GET_DESC(S) \
+ (aout_symbol (symbol_get_bfdsym (S))->desc)
asection *text_section, *data_section, *bss_section;
#define obj_frob_symbol(S,PUNT) obj_aout_frob_symbol (S, &PUNT)
#define obj_frob_file() obj_aout_frob_file ()
-extern void obj_aout_frob_symbol PARAMS ((struct symbol *, int *));
+extern void obj_aout_frob_symbol PARAMS ((symbolS *, int *));
extern void obj_aout_frob_file PARAMS ((void));
#define obj_sec_sym_ok_for_reloc(SEC) (1)
/* coff object file format
- Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 1998
+ Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
Free Software Foundation, Inc.
This file is part of GAS.
{
combined_entry_type *entry, *p;
- entry = &coffsymbol (sym->bsym)->native[1];
- p = coffsymbol (val->bsym)->native;
+ entry = &coffsymbol (symbol_get_bfdsym (sym))->native[1];
+ p = coffsymbol (symbol_get_bfdsym (val))->native;
entry->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p = p;
entry->fix_end = 1;
}
{
combined_entry_type *entry, *p;
- entry = &coffsymbol (sym->bsym)->native[1];
- p = coffsymbol (val->bsym)->native;
+ entry = &coffsymbol (symbol_get_bfdsym (sym))->native[1];
+ p = coffsymbol (symbol_get_bfdsym (val))->native;
entry->u.auxent.x_sym.x_tagndx.p = p;
entry->fix_tag = 1;
}
S_GET_DATA_TYPE (sym)
symbolS *sym;
{
- return coffsymbol (sym->bsym)->native->u.syment.n_type;
+ return coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_type;
}
int
symbolS *sym;
int val;
{
- coffsymbol (sym->bsym)->native->u.syment.n_type = val;
+ coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_type = val;
return val;
}
S_GET_STORAGE_CLASS (sym)
symbolS *sym;
{
- return coffsymbol (sym->bsym)->native->u.syment.n_sclass;
+ return coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_sclass;
}
int
symbolS *sym;
int val;
{
- coffsymbol (sym->bsym)->native->u.syment.n_sclass = val;
+ coffsymbol (symbol_get_bfdsym (sym))->native->u.syment.n_sclass = val;
return val;
}
S_SET_STORAGE_CLASS (symbolP, C_FILE);
S_SET_NUMBER_AUXILIARY (symbolP, 1);
- symbolP->bsym->flags = BSF_DEBUGGING;
+ symbol_get_bfdsym (symbolP)->flags = BSF_DEBUGGING;
#ifndef NO_LISTING
{
char * s = (char *) xmalloc (sz);
memset (s, 0, sz);
- coffsymbol (symbolP->bsym)->native = (combined_entry_type *) s;
+ coffsymbol (symbol_get_bfdsym (symbolP))->native = (combined_entry_type *) s;
S_SET_DATA_TYPE (symbolP, T_NULL);
S_SET_STORAGE_CLASS (symbolP, 0);
{
if (line_nos)
{
- coffsymbol (current_lineno_sym->bsym)->lineno = (alent *) line_nos;
+ coffsymbol (symbol_get_bfdsym (current_lineno_sym))->lineno =
+ (alent *) line_nos;
coff_n_line_nos++;
line_nos = 0;
}
/* Initialize the new symbol */
def_symbol_in_progress = symbol_make (symbol_name_copy);
- def_symbol_in_progress->sy_frag = &zero_address_frag;
+ symbol_set_frag (def_symbol_in_progress, &zero_address_frag);
S_SET_VALUE (def_symbol_in_progress, 0);
if (S_IS_STRING (def_symbol_in_progress))
CONST char *name;
S_SET_SEGMENT (def_symbol_in_progress, text_section);
- name = bfd_asymbol_name (def_symbol_in_progress->bsym);
+ name = S_GET_NAME (def_symbol_in_progress);
if (name[1] == 'b' && name[2] == 'f')
{
if (! in_function ())
#endif
if (!strcmp (symbol_name, "."))
{
- def_symbol_in_progress->sy_frag = frag_now;
+ symbol_set_frag (def_symbol_in_progress, frag_now);
S_SET_VALUE (def_symbol_in_progress, (valueT) frag_now_fix ());
/* If the .val is != from the .def (e.g. statics) */
}
else if (strcmp (S_GET_NAME (def_symbol_in_progress), symbol_name))
{
- def_symbol_in_progress->sy_value.X_op = O_symbol;
- def_symbol_in_progress->sy_value.X_add_symbol =
- symbol_find_or_make (symbol_name);
- def_symbol_in_progress->sy_value.X_op_symbol = NULL;
- def_symbol_in_progress->sy_value.X_add_number = 0;
+ expressionS exp;
+
+ exp.X_op = O_symbol;
+ exp.X_add_symbol = symbol_find_or_make (symbol_name);
+ exp.X_op_symbol = NULL;
+ exp.X_add_number = 0;
+ symbol_set_value_expression (def_symbol_in_progress, &exp);
/* If the segment is undefined when the forward reference is
resolved, then copy the segment id from the forward
coff_last_function = symp;
if (S_GET_NUMBER_AUXILIARY (symp) < 1)
S_SET_NUMBER_AUXILIARY (symp, 1);
- auxp = &coffsymbol (symp->bsym)->native[1].u.auxent;
+ auxp =
+ &coffsymbol (symbol_get_bfdsym (symp))->native[1].u.auxent;
memset (auxp->x_sym.x_fcnary.x_ary.x_dimen, 0,
sizeof (auxp->x_sym.x_fcnary.x_ary.x_dimen));
}
*punt = 1;
if (SF_GET_FUNCTION (symp))
- symp->bsym->flags |= BSF_FUNCTION;
+ symbol_get_bfdsym (symp)->flags |= BSF_FUNCTION;
/* more ... */
}
/* This is pretty horrible, but we have to set *punt correctly in
order to call SA_SET_SYM_ENDNDX correctly. */
if (! symp->sy_used_in_reloc
- && ((symp->bsym->flags & BSF_SECTION_SYM) != 0
+ && ((symbol_get_bfdsym (symp)->flags & BSF_SECTION_SYM) != 0
|| (! S_IS_EXTERNAL (symp)
&& ! symp->sy_tc.output
&& S_GET_STORAGE_CLASS (symp) != C_FILE)))
if (set_end != (symbolS *) NULL
&& ! *punt
- && ((symp->bsym->flags & BSF_NOT_AT_END) != 0
+ && ((symbol_get_bfdsym (symp)->flags & BSF_NOT_AT_END) != 0
|| (S_IS_DEFINED (symp)
&& ! S_IS_COMMON (symp)
&& (! S_IS_EXTERNAL (symp) || SF_GET_FUNCTION (symp)))))
coff_last_bf = symp;
}
- if (coffsymbol (symp->bsym)->lineno)
+ if (coffsymbol (symbol_get_bfdsym (symp))->lineno)
{
int i;
struct line_no *lptr;
alent *l;
- lptr = (struct line_no *) coffsymbol (symp->bsym)->lineno;
+ lptr = (struct line_no *) coffsymbol (symbol_get_bfdsym (symp))->lineno;
for (i = 0; lptr; lptr = lptr->next)
i++;
- lptr = (struct line_no *) coffsymbol (symp->bsym)->lineno;
+ lptr = (struct line_no *) coffsymbol (symbol_get_bfdsym (symp))->lineno;
/* We need i entries for line numbers, plus 1 for the first
entry which BFD will override, plus 1 for the last zero
entry (a marker for BFD). */
l = (alent *) xmalloc ((i + 2) * sizeof (alent));
- coffsymbol (symp->bsym)->lineno = l;
+ coffsymbol (symbol_get_bfdsym (symp))->lineno = l;
l[i + 1].line_number = 0;
l[i + 1].u.sym = NULL;
for (; i > 0; i--)
#define OBJ_COFF_MAX_AUXENTRIES 1
#endif /* OBJ_COFF_MAX_AUXENTRIES */
-extern void coff_obj_symbol_new_hook PARAMS ((struct symbol *));
+extern void coff_obj_symbol_new_hook PARAMS ((symbolS *));
#define obj_symbol_new_hook coff_obj_symbol_new_hook
extern void coff_obj_read_begin_hook PARAMS ((void));
/* Alter the field names, for now, until we've fixed up the other
references to use the new name. */
#ifdef TC_I960
-#define TC_SYMFIELD_TYPE struct symbol *
+#define TC_SYMFIELD_TYPE symbolS *
#define sy_tc bal
#endif
#define OBJ_SYMFIELD_TYPE unsigned long
#define sy_obj sy_flags
-#define SYM_AUXENT(S) (&coffsymbol ((S)->bsym)->native[1].u.auxent)
-#define SYM_AUXINFO(S) (&coffsymbol ((S)->bsym)->native[1])
+#define SYM_AUXENT(S) \
+ (&coffsymbol (symbol_get_bfdsym (S))->native[1].u.auxent)
+#define SYM_AUXINFO(S) \
+ (&coffsymbol (symbol_get_bfdsym (S))->native[1])
#define DO_NOT_STRIP 0
extern void obj_coff_section PARAMS ((int));
/* The number of auxiliary entries */
-#define S_GET_NUMBER_AUXILIARY(s) (coffsymbol((s)->bsym)->native->u.syment.n_numaux)
+#define S_GET_NUMBER_AUXILIARY(s) \
+ (coffsymbol (symbol_get_bfdsym (s))->native->u.syment.n_numaux)
/* The number of auxiliary entries */
#define S_SET_NUMBER_AUXILIARY(s,v) (S_GET_NUMBER_AUXILIARY (s) = (v))
/* True if a symbol name is in the string table, i.e. its length is > 8. */
#define S_IS_STRING(s) (strlen(S_GET_NAME(s)) > 8 ? 1 : 0)
-extern int S_SET_DATA_TYPE PARAMS ((struct symbol *, int));
-extern int S_SET_STORAGE_CLASS PARAMS ((struct symbol *, int));
-extern int S_GET_STORAGE_CLASS PARAMS ((struct symbol *));
-extern void SA_SET_SYM_ENDNDX PARAMS ((struct symbol *, struct symbol *));
+extern int S_SET_DATA_TYPE PARAMS ((symbolS *, int));
+extern int S_SET_STORAGE_CLASS PARAMS ((symbolS *, int));
+extern int S_GET_STORAGE_CLASS PARAMS ((symbolS *));
+extern void SA_SET_SYM_ENDNDX PARAMS ((symbolS *, symbolS *));
/* Auxiliary entry macros. SA_ stands for symbol auxiliary */
/* Omit the tv related fields */
/* All other bits are unused. */
/* Accessors */
-#define SF_GET(s) ((s)->sy_flags)
-#define SF_GET_DEBUG(s) ((s)->bsym->flags & BSF_DEBUGGING)
-#define SF_SET_DEBUG(s) ((s)->bsym->flags |= BSF_DEBUGGING)
+#define SF_GET(s) (*symbol_get_obj (s))
+#define SF_GET_DEBUG(s) (symbol_get_bfdsym (s)->flags & BSF_DEBUGGING)
+#define SF_SET_DEBUG(s) (symbol_get_bfdsym (s)->flags |= BSF_DEBUGGING)
#define SF_GET_NORMAL_FIELD(s) (SF_GET (s) & SF_NORMAL_MASK)
#define SF_GET_DEBUG_FIELD(s) (SF_GET (s) & SF_DEBUG_MASK)
#define SF_GET_FILE(s) (SF_GET (s) & SF_FILE)
extern int coff_n_line_nos;
#define obj_emit_lineno(WHERE,LINE,FILE_START) abort ()
-extern void coff_add_linesym PARAMS ((struct symbol *));
+extern void coff_add_linesym PARAMS ((symbolS *));
void c_dot_file_symbol PARAMS ((char *filename));
#define obj_app_file c_dot_file_symbol
-extern void coff_frob_symbol PARAMS ((struct symbol *, int *));
+extern void coff_frob_symbol PARAMS ((symbolS *, int *));
extern void coff_adjust_symtab PARAMS ((void));
extern void coff_frob_section PARAMS ((segT));
extern void coff_adjust_section_syms PARAMS ((bfd *, asection *, PTR));
#define obj_frob_section(S) coff_frob_section (S)
#define obj_frob_file_after_relocs() coff_frob_file_after_relocs ()
-extern struct symbol *coff_last_function;
+extern symbolS *coff_last_function;
/* Forward the segment of a forwarded symbol, handle assignments that
just copy symbol values, etc. */
#define obj_app_file c_dot_file_symbol
extern void obj_extra_stuff PARAMS ((object_headers * headers));
-extern segT s_get_segment PARAMS ((struct symbol * ptr));
+extern segT s_get_segment PARAMS ((symbolS *ptr));
extern void c_section_header PARAMS ((struct internal_scnhdr * header,
char *name,
long alignment));
#ifndef tc_coff_symbol_emit_hook
-void tc_coff_symbol_emit_hook PARAMS ((struct symbol *));
+void tc_coff_symbol_emit_hook PARAMS ((symbolS *));
#endif
/* sanity check */
symbols is undefined (this last is needed to distinguish a .extern
symbols from a .comm symbol). */
-#define TARGET_SYMBOL_FIELDS \
- struct efdr *ecoff_file; \
- struct localsym *ecoff_symbol; \
+struct ecoff_sy_obj
+{
+ struct efdr *ecoff_file;
+ struct localsym *ecoff_symbol;
valueT ecoff_extern_size;
+};
+
+#define OBJ_SYMFIELD_TYPE struct ecoff_sy_obj
/* Modify the ECOFF symbol. */
#define obj_frob_symbol(symp, punt) ecoff_frob_symbol (symp)
#define obj_sec_sym_ok_for_reloc(SEC) 1
#define obj_ecoff_set_ext ecoff_set_ext
-extern void obj_ecoff_set_ext PARAMS ((struct symbol *, EXTR *));
+extern void obj_ecoff_set_ext PARAMS ((symbolS *, EXTR *));
/* ELF object file format
- Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999
+ Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
symbolS *sym;
sym = symbol_new (s, absolute_section, (valueT) 0, (struct frag *) 0);
- sym->sy_frag = &zero_address_frag;
- sym->bsym->flags |= BSF_FILE;
+ symbol_set_frag (sym, &zero_address_frag);
+ symbol_get_bfdsym (sym)->flags |= BSF_FILE;
if (symbol_rootP != sym)
{
as_warn (_("Common alignment negative; 0 assumed"));
}
}
- if (symbolP->local)
+ if (symbol_get_obj (symbolP)->local)
{
segT old_sec;
int old_subsec;
if (align)
frag_align (align, 0, 0);
if (S_GET_SEGMENT (symbolP) == bss_section)
- symbolP->sy_frag->fr_symbol = 0;
- symbolP->sy_frag = frag_now;
+ symbol_get_frag (symbolP)->fr_symbol = 0;
+ symbol_set_frag (symbolP, frag_now);
pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP,
(offsetT) size, (char *) 0);
*pfrag = 0;
goto allocate_common;
}
- symbolP->bsym->flags |= BSF_OBJECT;
+ symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT;
demand_empty_rest_of_line ();
return;
*input_line_pointer = c;
SKIP_WHITESPACE ();
S_CLEAR_EXTERNAL (symbolP);
- symbolP->local = 1;
+ symbol_get_obj (symbolP)->local = 1;
if (c == ',')
{
input_line_pointer++;
*input_line_pointer = c;
SKIP_WHITESPACE ();
S_SET_WEAK (symbolP);
- symbolP->local = 1;
+ symbol_get_obj (symbolP)->local = 1;
if (c == ',')
{
input_line_pointer++;
/* Add a symbol for this section to the symbol table. */
secsym = symbol_find (string);
if (secsym != NULL)
- secsym->bsym = sec->symbol;
+ symbol_set_bfdsym (secsym, sec->symbol);
else
symbol_table_insert (section_symbol (sec));
*input_line_pointer = c;
- if (sym->sy_obj.versioned_name != NULL)
+ if (symbol_get_obj (sym)->versioned_name != NULL)
{
as_bad (_("multiple .symver directives for symbol `%s'"),
S_GET_NAME (sym));
*input_line_pointer++ = c;
}
- sym->sy_obj.versioned_name = xstrdup (name);
+ symbol_get_obj (sym)->versioned_name = xstrdup (name);
*input_line_pointer = c;
- if (strchr (sym->sy_obj.versioned_name, ELF_VER_CHR) == NULL)
+ if (strchr (symbol_get_obj (sym)->versioned_name, ELF_VER_CHR) == NULL)
{
as_bad (_("missing version name in `%s' for symbol `%s'"),
- sym->sy_obj.versioned_name, S_GET_NAME (sym));
+ symbol_get_obj (sym)->versioned_name, S_GET_NAME (sym));
ignore_rest_of_line ();
return;
}
the same child symbol. Also, we can currently only do this if the
child symbol is already exists and is placed in a fragment. */
- if (csym == NULL || csym->sy_frag == NULL)
+ if (csym == NULL || symbol_get_frag (csym) == NULL)
{
as_bad ("expected `%s' to have already been set for .vtable_inherit",
cname);
if (bad)
return;
- assert (csym->sy_value.X_op == O_constant);
- fix_new (csym->sy_frag, csym->sy_value.X_add_number, 0, psym, 0, 0,
+ assert (symbol_get_value_expression (csym)->X_op == O_constant);
+ fix_new (symbol_get_frag (csym),
+ symbol_get_value_expression (csym)->X_add_number, 0, psym, 0, 0,
BFD_RELOC_VTABLE_INHERIT);
}
obj_symbol_new_hook (symbolP)
symbolS *symbolP;
{
- symbolP->sy_obj.size = NULL;
- symbolP->sy_obj.versioned_name = NULL;
+ struct elf_obj_sy *sy_obj;
+
+ sy_obj = symbol_get_obj (symbolP);
+ sy_obj->size = NULL;
+ sy_obj->versioned_name = NULL;
#ifdef NEED_ECOFF_DEBUG
if (ECOFF_DEBUGGING)
S_SET_SIZE (sym, exp.X_add_number);
else
{
- sym->sy_obj.size = (expressionS *) xmalloc (sizeof (expressionS));
- *sym->sy_obj.size = exp;
+ symbol_get_obj (sym)->size =
+ (expressionS *) xmalloc (sizeof (expressionS));
+ *symbol_get_obj (sym)->size = exp;
}
demand_empty_rest_of_line ();
}
*input_line_pointer = c;
- sym->bsym->flags |= type;
+ symbol_get_bfdsym (sym)->flags |= type;
demand_empty_rest_of_line ();
}
symbolS *sym;
struct ecoff_extr *ext;
{
- sym->bsym->udata.p = (PTR) ext;
+ symbol_get_bfdsym (sym)->udata.p = (PTR) ext;
}
/* This function is called by bfd_ecoff_debug_externals. It is
symbolS *symp;
int *puntp;
{
+ struct elf_obj_sy *sy_obj;
+
#ifdef NEED_ECOFF_DEBUG
if (ECOFF_DEBUGGING)
ecoff_frob_symbol (symp);
#endif
- if (symp->sy_obj.size != NULL)
+ sy_obj = symbol_get_obj (symp);
+
+ if (sy_obj->size != NULL)
{
- switch (symp->sy_obj.size->X_op)
+ switch (sy_obj->size->X_op)
{
case O_subtract:
S_SET_SIZE (symp,
- (S_GET_VALUE (symp->sy_obj.size->X_add_symbol)
- + symp->sy_obj.size->X_add_number
- - S_GET_VALUE (symp->sy_obj.size->X_op_symbol)));
+ (S_GET_VALUE (sy_obj->size->X_add_symbol)
+ + sy_obj->size->X_add_number
+ - S_GET_VALUE (sy_obj->size->X_op_symbol)));
break;
case O_constant:
S_SET_SIZE (symp,
- (S_GET_VALUE (symp->sy_obj.size->X_add_symbol)
- + symp->sy_obj.size->X_add_number));
+ (S_GET_VALUE (sy_obj->size->X_add_symbol)
+ + sy_obj->size->X_add_number));
break;
default:
as_bad (_(".size expression too complicated to fix up"));
break;
}
- free (symp->sy_obj.size);
- symp->sy_obj.size = NULL;
+ free (sy_obj->size);
+ sy_obj->size = NULL;
}
- if (symp->sy_obj.versioned_name != NULL)
+ if (sy_obj->versioned_name != NULL)
{
/* This symbol was given a new name with the .symver directive.
/* Verify that the name isn't using the @@ syntax--this is
reserved for definitions of the default version to link
against. */
- p = strchr (symp->sy_obj.versioned_name, ELF_VER_CHR);
+ p = strchr (sy_obj->versioned_name, ELF_VER_CHR);
know (p != NULL);
if (p[1] == ELF_VER_CHR)
{
as_bad (_("invalid attempt to declare external version name as default in symbol `%s'"),
- symp->sy_obj.versioned_name);
+ sy_obj->versioned_name);
*puntp = true;
}
- S_SET_NAME (symp, symp->sy_obj.versioned_name);
+ S_SET_NAME (symp, sy_obj->versioned_name);
}
else
{
where the loop will still see it. It would probably be
better to do this in obj_frob_file_before_adjust. */
- symp2 = symbol_find_or_make (symp->sy_obj.versioned_name);
+ symp2 = symbol_find_or_make (sy_obj->versioned_name);
/* Now we act as though we saw symp2 = sym. */
/* Subtracting out the frag address here is a hack because
we are in the middle of the final loop. */
- S_SET_VALUE (symp2, S_GET_VALUE (symp) - symp->sy_frag->fr_address);
+ S_SET_VALUE (symp2,
+ (S_GET_VALUE (symp)
+ - symbol_get_frag (symp)->fr_address));
- symp2->sy_frag = symp->sy_frag;
+ symbol_set_frag (symp2, symbol_get_frag (symp));
/* This will copy over the size information. */
copy_symbol_attributes (symp2, symp);
}
/* Double check weak symbols. */
- if (symp->bsym->flags & BSF_WEAK)
+ if (S_IS_WEAK (symp))
{
if (S_IS_COMMON (symp))
as_bad (_("Symbol `%s' can not be both weak and common"),
.global directives to mark functions. */
if (S_IS_COMMON (symp))
- symp->bsym->flags |= BSF_OBJECT;
+ symbol_get_bfdsym (symp)->flags |= BSF_OBJECT;
if (strstr (TARGET_OS, "irix") != NULL
- && (! S_IS_DEFINED (symp) && ((symp->bsym->flags & BSF_FUNCTION) == 0)))
- symp->bsym->flags |= BSF_OBJECT;
+ && ! S_IS_DEFINED (symp)
+ && (symbol_get_bfdsym (symp)->flags & BSF_FUNCTION) == 0)
+ symbol_get_bfdsym (symp)->flags |= BSF_OBJECT;
#endif
#ifdef TC_PPC
/* Frob the PowerPC, so that the symbol always has object type
if it is not some other type. VxWorks needs this. */
- if ((symp->bsym->flags & (BSF_FUNCTION | BSF_FILE | BSF_SECTION_SYM)) == 0
+ if ((symbol_get_bfdsym (symp)->flags
+ & (BSF_FUNCTION | BSF_FILE | BSF_SECTION_SYM)) == 0
&& S_IS_DEFINED (symp))
- symp->bsym->flags |= BSF_OBJECT;
+ symbol_get_bfdsym (symp)->flags |= BSF_OBJECT;
#endif
}
/* ELF object file format.
- Copyright (C) 1992, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999
+ Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
#define BYTES_IN_WORD 4 /* for now */
#include "bfd/elf-bfd.h"
+#include "targ-cpu.h"
+
+#ifdef TC_ALPHA
+#define ECOFF_DEBUGGING alpha_flag_mdebug
+extern int alpha_flag_mdebug;
+#endif
+
+/* For now, always set ECOFF_DEBUGGING for a MIPS target. */
+#ifdef TC_MIPS
+#ifdef MIPS_STABS_ELF
+#define ECOFF_DEBUGGING 0
+#else
+#define ECOFF_DEBUGGING 1
+#endif /* MIPS_STABS_ELF */
+#endif /* TC_MIPS */
+
/* Additional information we keep for each symbol. */
/* FIXME: For some reason, this structure is needed both here and in
#ifndef OBJ_SYMFIELD_TYPE
struct elf_obj_sy
{
+ /* Whether the symbol has been marked as local. */
+ int local;
+
/* Use this to keep track of .size expressions that involve
differences that we can't compute yet. */
expressionS *size;
/* The name specified by the .symver directive. */
char *versioned_name;
+
+#ifdef ECOFF_DEBUGGING
+ /* If we are generating ECOFF debugging information, we need some
+ additional fields for each symbol. */
+ struct efdr *ecoff_file;
+ struct localsym *ecoff_symbol;
+ valueT ecoff_extern_size;
+#endif
};
#endif
#define OBJ_SYMFIELD_TYPE struct elf_obj_sy
-/* Symbol fields used by the ELF back end. */
-#define ELF_TARGET_SYMBOL_FIELDS int local:1;
-
-/* Don't change this; change ELF_TARGET_SYMBOL_FIELDS instead. */
-#define TARGET_SYMBOL_FIELDS ELF_TARGET_SYMBOL_FIELDS
-
-#include "targ-cpu.h"
-
#ifndef FALSE
#define FALSE 0
#define TRUE !FALSE
/* should be conditional on address size! */
#define elf_symbol(asymbol) ((elf_symbol_type *)(&(asymbol)->the_bfd))
-#define S_GET_SIZE(S) (elf_symbol ((S)->bsym)->internal_elf_sym.st_size)
+#define S_GET_SIZE(S) \
+ (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size)
#define S_SET_SIZE(S,V) \
- (elf_symbol((S)->bsym)->internal_elf_sym.st_size = (V))
+ (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size = (V))
-#define S_GET_ALIGN(S) (elf_symbol ((S)->bsym)->internal_elf_sym.st_value)
+#define S_GET_ALIGN(S) \
+ (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value)
#define S_SET_ALIGN(S,V) \
- (elf_symbol ((S)->bsym)->internal_elf_sym.st_value = (V))
+ (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value = (V))
-#define S_GET_OTHER(S) (elf_symbol ((S)->bsym)->internal_elf_sym.st_other)
+#define S_GET_OTHER(S) \
+ (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_other)
#define S_SET_OTHER(S,V) \
- (elf_symbol ((S)->bsym)->internal_elf_sym.st_other = (V))
+ (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_other = (V))
extern asection *gdb_section;
#define OBJ_COPY_SYMBOL_ATTRIBUTES(DEST,SRC) \
do \
{ \
- if ((SRC)->sy_obj.size) \
+ struct elf_obj_sy *srcelf = symbol_get_obj (SRC); \
+ struct elf_obj_sy *destelf = symbol_get_obj (DEST); \
+ if (srcelf->size) \
{ \
- if ((DEST)->sy_obj.size == NULL) \
- (DEST)->sy_obj.size = \
+ if (destelf->size == NULL) \
+ destelf->size = \
(expressionS *) xmalloc (sizeof (expressionS)); \
- *(DEST)->sy_obj.size = *(SRC)->sy_obj.size; \
+ *destelf->size = *srcelf->size; \
} \
else \
{ \
- if ((DEST)->sy_obj.size != NULL) \
- free ((DEST)->sy_obj.size); \
- (DEST)->sy_obj.size = NULL; \
+ if (destelf->size != NULL) \
+ free (destelf->size); \
+ destelf->size = NULL; \
} \
S_SET_SIZE ((DEST), S_GET_SIZE (SRC)); \
S_SET_OTHER ((DEST), S_GET_OTHER (SRC)); \
extern void obj_elf_init_stab_section PARAMS ((segT));
#define INIT_STAB_SECTION(seg) obj_elf_init_stab_section (seg)
-#ifdef TC_ALPHA
-#define ECOFF_DEBUGGING alpha_flag_mdebug
-extern int alpha_flag_mdebug;
-#endif
-
-/* For now, always set ECOFF_DEBUGGING for a MIPS target. */
-#ifdef TC_MIPS
-#ifdef MIPS_STABS_ELF
-#define ECOFF_DEBUGGING 0
-#else
-#define ECOFF_DEBUGGING 1
-#endif /* MIPS_STABS_ELF */
-#endif /* TC_MIPS */
-
#ifdef ECOFF_DEBUGGING
-/* If we are generating ECOFF debugging information, we need some
- additional fields for each symbol. */
-#undef TARGET_SYMBOL_FIELDS
-#define TARGET_SYMBOL_FIELDS \
- ELF_TARGET_SYMBOL_FIELDS \
- struct efdr *ecoff_file; \
- struct localsym *ecoff_symbol; \
- valueT ecoff_extern_size;
-
/* We smuggle stabs in ECOFF rather than using a separate section.
The Irix linker can not handle a separate stabs section. */
ecoff_stab ((seg), (what), (string), (type), (other), (desc))
#endif /* ECOFF_DEBUGGING */
-extern void elf_frob_symbol PARAMS ((struct symbol *, int *));
+extern void elf_frob_symbol PARAMS ((symbolS *, int *));
#ifndef obj_frob_symbol
#define obj_frob_symbol(symp, punt) elf_frob_symbol (symp, &punt)
#endif
#ifdef ANSI_PROTOTYPES
struct ecoff_extr;
#endif
-extern void elf_ecoff_set_ext PARAMS ((struct symbol *, struct ecoff_extr *));
+extern void elf_ecoff_set_ext PARAMS ((symbolS *, struct ecoff_extr *));
#endif
#endif /* _OBJ_ELF_H */
/* FIXME: What's the story here? Why do we have to define
OBJ_SYMFIELD_TYPE both here and in obj-elf.h? */
+
#ifdef OBJ_MAYBE_ELF
struct elf_obj_sy
{
+ int local;
expressionS *size;
char *versioned_name;
+#ifdef ECOFF_DEBUGGING
+ /* If we are generating ECOFF debugging information, we need some
+ additional fields for each symbol. */
+ struct efdr *ecoff_file;
+ struct localsym *ecoff_symbol;
+ valueT ecoff_extern_size;
+#endif
};
#define OBJ_SYMFIELD_TYPE struct elf_obj_sy
-#define ELF_TARGET_SYMBOL_FIELDS int local:1;
-#else
-#define ELF_TARGET_SYMBOL_FIELDS
#endif
-
-#ifdef ECOFF_DEBUGGING
-struct efdr;
-struct localsym;
-#define ECOFF_DEBUG_TARGET_SYMBOL_FIELDS struct efdr *ecoff_file; struct localsym *ecoff_symbol; valueT ecoff_extern_size;
-#else
-#define ECOFF_DEBUG_TARGET_SYMBOL_FIELDS
-#endif
-
-#define TARGET_SYMBOL_FIELDS \
- ELF_TARGET_SYMBOL_FIELDS \
- ECOFF_DEBUG_TARGET_SYMBOL_FIELDS
/* VMS object file format
- Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 1997
+ Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 97, 1999
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
/* Force structure tags into scope so that their use in prototypes
will never be their first occurance. */
struct fix;
-struct symbol;
struct frag;
/* obj-vms routines visible to the rest of gas. */
extern void tc_aout_fix_to_chars PARAMS ((char *,struct fix *,relax_addressT));
-extern int vms_resolve_symbol_redef PARAMS ((struct symbol *));
+extern int vms_resolve_symbol_redef PARAMS ((symbolS *));
#define RESOLVE_SYMBOL_REDEFINITION(X) vms_resolve_symbol_redef(X)
/* Compiler-generated label "__vax_g_doubles" is used to augment .stabs. */
-extern void vms_check_for_special_label PARAMS ((struct symbol *));
+extern void vms_check_for_special_label PARAMS ((symbolS *));
#define obj_frob_label(X) vms_check_for_special_label(X)
extern void vms_check_for_main PARAMS ((void));
Therefore they must be completely resolved as constants. */
if (fixP->fx_addsy != 0
- && fixP->fx_addsy->bsym->section != absolute_section)
+ && S_GET_SEGMENT (fixP->fx_addsy) != absolute_section)
as_bad_where (fixP->fx_file, fixP->fx_line,
_("non-absolute expression in constant field"));
arelent *reloc;
reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym;
+ reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
/* Make sure none of our internal relocations make it this far.
*/
if ((S_IS_EXTERN (fixp->fx_addsy) || S_IS_WEAK (fixp->fx_addsy))
&& !S_IS_COMMON(fixp->fx_addsy))
- reloc->addend -= fixp->fx_addsy->bsym->value;
+ reloc->addend -= symbol_get_bfdsym (fixp->fx_addsy)->value;
#endif
}
as_warn (_("nested .ent directives"));
sym = symbol_find_or_make (name);
- sym->bsym->flags |= BSF_FUNCTION;
+ symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION;
alpha_cur_ent_sym = sym;
/* The .ent directive is sometimes followed by a number. Not sure
/* Create an expression to calculate the size of the function. */
if (sym)
{
- sym->sy_obj.size = (expressionS *) xmalloc (sizeof (expressionS));
- sym->sy_obj.size->X_op = O_subtract;
- sym->sy_obj.size->X_add_symbol
+ symbol_get_obj (sym)->size =
+ (expressionS *) xmalloc (sizeof (expressionS));
+ symbol_get_obj (sym)->size->X_op = O_subtract;
+ symbol_get_obj (sym)->size->X_add_symbol
= symbol_new ("L0\001", now_seg, frag_now_fix (), frag_now);
- sym->sy_obj.size->X_op_symbol = sym;
- sym->sy_obj.size->X_add_number = 0;
+ symbol_get_obj (sym)->size->X_op_symbol = sym;
+ symbol_get_obj (sym)->size->X_add_number = 0;
}
alpha_cur_ent_sym = NULL;
if (label != NULL)
{
assert (S_GET_SEGMENT (label) == now_seg);
- label->sy_frag = frag_now;
+ symbol_set_frag (label, frag_now);
S_SET_VALUE (label, (valueT) frag_now_fix ());
}
extern void alpha_frob_ecoff_data PARAMS ((void));
#define tc_frob_label(sym) alpha_define_label (sym)
-extern void alpha_define_label PARAMS ((struct symbol *));
+extern void alpha_define_label PARAMS ((symbolS *));
#define md_cons_align(nbytes) alpha_cons_align (nbytes)
extern void alpha_cons_align PARAMS ((int));
/* tc-arc.h - Macros and type defines for the ARC.
- Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1994, 1995, 1997, 1999 Free Software Foundation, Inc.
Contributed by Doug Evans (dje@cygnus.com).
This file is part of GAS, the GNU Assembler.
#define TC_SYMFIELD_TYPE struct arc_tc_sy
/* Finish up the symbol. */
-extern int arc_frob_symbol PARAMS ((struct symbol *));
+extern int arc_frob_symbol PARAMS ((symbolS *));
#define tc_frob_symbol(sym, punt) punt = arc_frob_symbol (sym)
#endif
/* This file is tc-arm.h
- Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999
+ Free Software Foundation, Inc.
Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
Modified by David Taylor (dtaylor@armltd.co.uk)
extern void arm_start_line_hook PARAMS ((void));
#define tc_frob_label(S) arm_frob_label (S)
- extern void arm_frob_label PARAMS ((struct symbol *));
+ extern void arm_frob_label PARAMS ((symbolS *));
/* We also need to mark assembler created symbols: */
#define tc_frob_fake_label(S) arm_frob_label (S)
/* tc-d10v.c -- Assembler code for the Mitsubishi D10V
- Copyright (C) 1996, 1997, 1998 Free Software Foundation.
+ Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation.
This file is part of GAS, the GNU Assembler.
{
expressionP->X_op = O_register;
/* temporarily store a pointer to the string here */
- expressionP->X_op_symbol = (struct symbol *)input_line_pointer;
+ expressionP->X_op_symbol = (symbolS *)input_line_pointer;
expressionP->X_add_number = reg_number;
input_line_pointer = p;
return 1;
/* tc-d30v.c -- Assembler code for the Mitsubishi D30V
- Copyright (C) 1997, 1998 Free Software Foundation.
+ Copyright (C) 1997, 1998, 1999 Free Software Foundation.
This file is part of GAS, the GNU Assembler.
{
expressionP->X_op = O_register;
/* temporarily store a pointer to the string here */
- expressionP->X_op_symbol = (struct symbol *)input_line_pointer;
+ expressionP->X_op_symbol = (symbolS *)input_line_pointer;
expressionP->X_add_number = reg_number;
input_line_pointer = p;
return 1;
/* tc-310v.h -- Header file for tc-d30v.c.
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
Written by Martin Hunt, Cygnus Support.
This file is part of GAS, the GNU Assembler.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ along with GAS; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
#define TC_D30V
#define TC_START_LABEL(ch, ptr) (ch == ':' && d30v_cleanup (false))
#define md_start_line_hook() d30v_start_line (false)
-void d30v_frob_label PARAMS ((struct symbol *));
+void d30v_frob_label PARAMS ((symbolS *));
#define tc_frob_label(sym) d30v_frob_label(sym)
void d30v_cons_align PARAMS ((int));
/* tc-hppa.c -- Assemble for the PA
- Copyright (C) 1989, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1989, 93, 94, 95, 96, 97, 98, 1999
+ Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
label. */
typedef struct label_symbol_struct
{
- struct symbol *lss_label;
+ symbolS *lss_label;
sd_chain_struct *lss_space;
struct label_symbol_struct *lss_next;
}
&& GOT_symbol == i.imms[n]->X_add_symbol
&& (i.imms[n]->X_op == O_symbol
|| (i.imms[n]->X_op == O_add
- && (i.imms[n]->X_op_symbol->sy_value.X_op
+ && ((symbol_get_value_expression
+ (i.imms[n]->X_op_symbol)->X_op)
== O_subtract))))
{
r_type = BFD_RELOC_386_GOTPC;
{
if (S_IS_LOCAL(exp->X_add_symbol)
&& S_GET_SEGMENT (exp->X_add_symbol) != undefined_section)
- section_symbol(exp->X_add_symbol->bsym->section);
+ section_symbol (S_GET_SEGMENT (exp->X_add_symbol));
assert (exp->X_op == O_symbol);
exp->X_op = O_subtract;
exp->X_op_symbol = GOT_symbol;
/* Address we want to reach in file space. */
target_address = S_GET_VALUE (fragP->fr_symbol) + fragP->fr_offset;
#ifdef BFD_ASSEMBLER /* not needed otherwise? */
- target_address += fragP->fr_symbol->sy_frag->fr_address;
+ target_address += symbol_get_frag (fragP->fr_symbol)->fr_address;
#endif
/* Address opcode resides at in file space. */
#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
if (OUTPUT_FLAVOR == bfd_target_elf_flavour
&& (S_GET_SEGMENT (fixP->fx_addsy) == seg
- || (fixP->fx_addsy->bsym->flags & BSF_SECTION_SYM) != 0)
+ || symbol_section_p (fixP->fx_addsy))
&& ! S_IS_EXTERNAL (fixP->fx_addsy)
&& ! S_IS_WEAK (fixP->fx_addsy)
&& S_IS_DEFINED (fixP->fx_addsy)
code = BFD_RELOC_386_GOTPC;
rel = (arelent *) xmalloc (sizeof (arelent));
- rel->sym_ptr_ptr = &fixp->fx_addsy->bsym;
+ rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
/* HACK: Since i386 ELF uses Rel instead of Rela, encode the
assert (!fixP->fx_pcrel == !reloc->howto->pc_relative);
- reloc->sym_ptr_ptr = &fixP->fx_addsy->bsym;
+ reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
reloc->addend = fixP->fx_addnumber;
#ifdef OBJ_COFF
/* We store the bal information in the sy_tc field. */
-#define TC_SYMFIELD_TYPE struct symbol *
+#define TC_SYMFIELD_TYPE symbolS *
#define TC_ADJUST_RELOC_COUNT(FIXP,COUNT) \
{ fixS *tcfixp = (FIXP); \
}
#endif
-extern int i960_validate_fix PARAMS ((struct fix *, segT, struct symbol **));
+extern int i960_validate_fix PARAMS ((struct fix *, segT, symbolS **));
#define TC_VALIDATE_FIX(FIXP,SEGTYPE,LABEL) \
if (i960_validate_fix (FIXP, SEGTYPE, &add_symbolP) != 0) goto LABEL
extern void reloc_callj ();
-extern void tc_set_bal_of_call PARAMS ((struct symbol *, struct symbol *));
+extern void tc_set_bal_of_call PARAMS ((symbolS *, symbolS *));
-extern struct symbol *tc_get_bal_of_call PARAMS ((struct symbol *));
+extern struct symbol *tc_get_bal_of_call PARAMS ((symbolS *));
extern void i960_handle_align ();
#define HANDLE_ALIGN(FRAG) i960_handle_align (FRAG)
#undef MAP
reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym;
+ reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
#ifndef OBJ_ELF
if (fixp->fx_pcrel)
disp = (disp + fragP->fr_offset) - object_address;
#ifdef BFD_ASSEMBLER
- disp += fragP->fr_symbol->sy_frag->fr_address;
+ disp += symbol_get_frag (fragP->fr_symbol)->fr_address;
#endif
switch (fragP->fr_subtype)
word mode. */
if (fragP->fr_symbol && S_GET_VALUE (fragP->fr_symbol) == 0)
{
+ fragS *stop;
fragS *l;
- for (l = fragP->fr_next;
- l != fragP->fr_symbol->sy_frag;
- l = l->fr_next)
+ stop = symbol_get_frag (fragP->fr_symbol);
+ for (l = fragP->fr_next; l != stop; l = l->fr_next)
if (l->fr_fix + l->fr_var != 0)
break;
- if (l == fragP->fr_symbol->sy_frag)
+ if (l == stop)
{
fragP->fr_subtype = TAB (TABTYPE (fragP->fr_subtype), SHORT);
fragP->fr_var += 2;
S_SET_SEGMENT (line_label, reg_section);
S_SET_VALUE (line_label, ~mask);
- line_label->sy_frag = &zero_address_frag;
+ symbol_set_frag (line_label, &zero_address_frag);
if (flag_mri)
mri_comment_end (stop, stopc);
/* This file is tc-m68k.h
- Copyright (C) 1987, 89, 90, 91, 92, 93, 94, 95, 96, 97, 1998
+ Copyright (C) 1987, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
#define TC_M68K 1
#ifdef ANSI_PROTOTYPES
-struct symbol;
struct fix;
#endif
extern int m68k_conditional_pseudoop PARAMS ((pseudo_typeS *));
#define tc_conditional_pseudoop(pop) m68k_conditional_pseudoop (pop)
-extern void m68k_frob_label PARAMS ((struct symbol *));
+extern void m68k_frob_label PARAMS ((symbolS *));
#define tc_frob_label(sym) m68k_frob_label (sym)
extern void m68k_flush_pending_output PARAMS ((void));
#define md_flush_pending_output() m68k_flush_pending_output ()
-extern void m68k_frob_symbol PARAMS ((struct symbol *));
+extern void m68k_frob_symbol PARAMS ((symbolS *));
#ifdef BFD_ASSEMBLER
{
int i;
struct literal * p;
- struct symbol * brarsym;
+ symbolS * brarsym;
if (poolsize == 0)
return;
#define TARGET_FORMAT (target_big_endian ? "pe-mcore-big" : "pe-mcore-little")
-#define TARGET_SYMBOL_FIELDS int sy_flags ;
+struct mcore_tc_sy
+{
+ int sy_flags;
+};
+
+#define TC_SYMFIELD_TYPE struct mcore_tc_sy
#endif /* OBJ_COFF */
# error No target format specified.
#endif
-#include "struc-symbol.h" /* For definition of symbolS */
#include "write.h" /* For definition of fixS */
extern void md_begin PARAMS ((void));
/* tc-mips.c -- assemble code for a MIPS chip.
- Copyright (C) 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
Contributed by the OSF and Ralph Campbell.
Written by Keith Knowles and Ralph Campbell, working independently.
Modified for ECOFF and R4000 support by Ian Lance Taylor of Cygnus
#undef S_GET_SIZE
#undef S_SET_ALIGN
#undef S_SET_SIZE
-#undef TARGET_SYMBOL_FIELDS
#undef obj_frob_file
#undef obj_frob_file_after_relocs
#undef obj_frob_symbol
if (OUTPUT_FLAVOR == bfd_target_elf_flavour)
S_SET_OTHER (l->label, STO_MIPS16);
#endif
- if ((l->label->sy_value.X_add_number & 1) == 0)
- ++l->label->sy_value.X_add_number;
+ if ((S_GET_VALUE (l->label) & 1) == 0)
+ S_SET_VALUE (l->label, S_GET_VALUE (l->label) + 1);
}
}
}
for (l = insn_labels; l != NULL; l = l->next)
{
assert (S_GET_SEGMENT (l->label) == now_seg);
- l->label->sy_frag = frag_now;
+ symbol_set_frag (l->label, frag_now);
S_SET_VALUE (l->label, (valueT) frag_now_fix ());
/* mips16 text labels are stored as odd. */
if (mips_opts.mips16)
- ++l->label->sy_value.X_add_number;
+ S_SET_VALUE (l->label, S_GET_VALUE (l->label) + 1);
}
#ifndef NO_ECOFF_DEBUGGING
for (l = insn_labels; l != NULL; l = l->next)
{
assert (S_GET_SEGMENT (l->label) == now_seg);
- l->label->sy_frag = frag_now;
+ symbol_set_frag (l->label, frag_now);
S_SET_VALUE (l->label, (valueT) frag_now_fix ());
/* mips16 text labels are stored as odd. */
if (mips_opts.mips16)
- ++l->label->sy_value.X_add_number;
+ S_SET_VALUE (l->label, S_GET_VALUE (l->label) + 1);
}
}
}
if (mips_pic == EMBEDDED_PIC
&& offset_expr.X_op == O_subtract
&& now_seg == text_section
- && (offset_expr.X_op_symbol->sy_value.X_op == O_constant
+ && (symbol_constant_p (offset_expr.X_op_symbol)
? S_GET_SEGMENT (offset_expr.X_op_symbol) == text_section
- : (offset_expr.X_op_symbol->sy_value.X_op == O_symbol
- && (S_GET_SEGMENT (offset_expr.X_op_symbol
- ->sy_value.X_add_symbol)
+ : (symbol_equated_p (offset_expr.X_op_symbol)
+ && (S_GET_SEGMENT
+ (symbol_get_value_expression (offset_expr.X_op_symbol)
+ ->X_add_symbol)
== text_section)))
&& breg == 0
&& offset_expr.X_add_number == 0)
&& ep->X_op == O_symbol
&& strcmp (S_GET_NAME (ep->X_add_symbol), FAKE_LABEL_NAME) == 0
&& S_GET_SEGMENT (ep->X_add_symbol) == now_seg
- && ep->X_add_symbol->sy_frag == frag_now
- && ep->X_add_symbol->sy_value.X_op == O_constant
- && ep->X_add_symbol->sy_value.X_add_number == frag_now_fix ())
- ++ep->X_add_symbol->sy_value.X_add_number;
+ && symbol_get_frag (ep->X_add_symbol) == frag_now
+ && symbol_constant_p (ep->X_add_symbol)
+ && S_GET_VALUE (ep->X_add_symbol) == frag_now_fix ())
+ S_SET_VALUE (ep->X_add_symbol, S_GET_VALUE (ep->X_add_symbol) + 1);
}
/* Turn a string in input_line_pointer into a floating point constant
if (fixP->fx_addsy != NULL && OUTPUT_FLAVOR == bfd_target_elf_flavour)
if (S_GET_OTHER (fixP->fx_addsy) == STO_MIPS16
|| S_IS_WEAK (fixP->fx_addsy)
- || (fixP->fx_addsy->sy_used_in_reloc
- && (bfd_get_section_flags (stdoutput,
- S_GET_SEGMENT (fixP->fx_addsy))
- & SEC_LINK_ONCE != 0)
- || !strncmp (segment_name (S_GET_SEGMENT (fixP->fx_addsy)),
- ".gnu.linkonce",
- sizeof (".gnu.linkonce") - 1)))
+ || (symbol_used_in_reloc_p (fixP->fx_addsy)
+ && (((bfd_get_section_flags (stdoutput,
+ S_GET_SEGMENT (fixP->fx_addsy))
+ & SEC_LINK_ONCE) != 0)
+ || !strncmp (segment_name (S_GET_SEGMENT (fixP->fx_addsy)),
+ ".gnu.linkonce",
+ sizeof (".gnu.linkonce") - 1))))
{
value -= S_GET_VALUE (fixP->fx_addsy);
case BFD_RELOC_PCREL_HI16_S:
/* The addend for this is tricky if it is internal, so we just
do everything here rather than in bfd_install_relocation. */
- if ((fixP->fx_addsy->bsym->flags & BSF_SECTION_SYM) == 0)
+ if ((symbol_get_bfdsym (fixP->fx_addsy)->flags & BSF_SECTION_SYM) == 0)
{
/* For an external symbol adjust by the address to make it
pcrel_offset. We use the address of the RELLO reloc
case BFD_RELOC_PCREL_LO16:
/* The addend for this is tricky if it is internal, so we just
do everything here rather than in bfd_install_relocation. */
- if ((fixP->fx_addsy->bsym->flags & BSF_SECTION_SYM) == 0)
+ if ((symbol_get_bfdsym (fixP->fx_addsy)->flags & BSF_SECTION_SYM) == 0)
value += fixP->fx_frag->fr_address + fixP->fx_where;
buf = (unsigned char *) fixP->fx_frag->fr_literal + fixP->fx_where;
if (target_big_endian)
if (label != NULL)
{
assert (S_GET_SEGMENT (label) == now_seg);
- label->sy_frag = frag_now;
+ symbol_set_frag (label, frag_now);
S_SET_VALUE (label, (valueT) frag_now_fix ());
}
}
mips_emit_delays (false);
if (auto_align)
- if (type == 'd')
- mips_align (3, 0, label);
- else
- mips_align (2, 0, label);
+ {
+ if (type == 'd')
+ mips_align (3, 0, label);
+ else
+ mips_align (2, 0, label);
+ }
mips_clear_insn_labels ();
flag = BSF_FUNCTION;
}
- symbolP->bsym->flags |= flag;
+ symbol_get_bfdsym (symbolP)->flags |= flag;
S_SET_EXTERNAL (symbolP);
demand_empty_rest_of_line ();
ex.X_add_number = 0;
/* In ELF, this symbol is implicitly an STT_OBJECT symbol. */
- ex.X_add_symbol->bsym->flags |= BSF_OBJECT;
+ symbol_get_bfdsym (ex.X_add_symbol)->flags |= BSF_OBJECT;
macro_build_lui ((char *) NULL, &icnt, &ex, GP);
macro_build ((char *) NULL, &icnt, &ex, "addiu", "t,r,j", GP, GP,
ignore_rest_of_line();
return;
}
- symbolP->sy_value = exp;
+ symbol_set_value_expression (symbolP, &exp);
}
demand_empty_rest_of_line ();
else if ((! S_IS_DEFINED (sym) || S_IS_COMMON (sym))
&& (0
#ifndef NO_ECOFF_DEBUGGING
- || (sym->ecoff_extern_size != 0
- && sym->ecoff_extern_size <= g_switch_value)
+ || (symbol_get_obj (sym)->ecoff_extern_size != 0
+ && (symbol_get_obj (sym)->ecoff_extern_size
+ <= g_switch_value))
#endif
/* We must defer this decision until after the whole
file has been read, since there might be a .extern
after the first use of this symbol. */
|| (before_relaxing
#ifndef NO_ECOFF_DEBUGGING
- && sym->ecoff_extern_size == 0
+ && symbol_get_obj (sym)->ecoff_extern_size == 0
#endif
&& S_GET_VALUE (sym) == 0)
|| (S_GET_VALUE (sym) != 0
maxtiny = (1 << (op->nbits - 1)) - 1;
}
- /* We can't call S_GET_VALUE here, because we don't want to lock in
- a particular frag address. */
- if (fragp->fr_symbol->sy_value.X_op == O_constant)
+ /* We can't always call S_GET_VALUE here, because we don't want to
+ lock in a particular frag address. */
+ if (symbol_constant_p (fragp->fr_symbol))
{
- val = (fragp->fr_symbol->sy_value.X_add_number
- + fragp->fr_symbol->sy_frag->fr_address);
+ val = (S_GET_VALUE (fragp->fr_symbol)
+ + symbol_get_frag (fragp->fr_symbol)->fr_address);
symsec = S_GET_SEGMENT (fragp->fr_symbol);
}
- else if (fragp->fr_symbol->sy_value.X_op == O_symbol
- && (fragp->fr_symbol->sy_value.X_add_symbol->sy_value.X_op
- == O_constant))
+ else if (symbol_equated_p (fragp->fr_symbol)
+ && (symbol_constant_p
+ (symbol_get_value_expression (fragp->fr_symbol)->X_add_symbol)))
{
- val = (fragp->fr_symbol->sy_value.X_add_symbol->sy_value.X_add_number
- + fragp->fr_symbol->sy_value.X_add_symbol->sy_frag->fr_address
- + fragp->fr_symbol->sy_value.X_add_number
- + fragp->fr_symbol->sy_frag->fr_address);
- symsec = S_GET_SEGMENT (fragp->fr_symbol->sy_value.X_add_symbol);
+ symbolS *eqsym;
+
+ eqsym = symbol_get_value_expression (fragp->fr_symbol)->X_add_symbol;
+ val = (S_GET_VALUE (eqsym)
+ + symbol_get_frag (eqsym)->fr_address
+ + symbol_get_value_expression (fragp->fr_symbol)->X_add_number
+ + symbol_get_frag (fragp->fr_symbol)->fr_address);
+ symsec = S_GET_SEGMENT (eqsym);
}
else
return 1;
in STRETCH in order to get a better estimate of the address.
This particularly matters because of the shift bits. */
if (stretch != 0
- && fragp->fr_symbol->sy_frag->fr_address >= fragp->fr_address)
+ && (symbol_get_frag (fragp->fr_symbol)->fr_address
+ >= fragp->fr_address))
{
fragS *f;
a maximum number of bytes to skip when doing an
alignment. */
for (f = fragp;
- f != NULL && f != fragp->fr_symbol->sy_frag;
+ f != NULL && f != symbol_get_frag (fragp->fr_symbol);
f = f->fr_next)
{
if (f->fr_type == rs_align || f->fr_type == rs_align_code)
sym = fragp->fr_symbol;
/* Handle the case of a symbol equated to another symbol. */
- while (sym->sy_value.X_op == O_symbol
+ while (symbol_equated_p (sym)
&& (! S_IS_DEFINED (sym) || S_IS_COMMON (sym)))
{
symbolS *n;
/* It's possible to get a loop here in a badly written
program. */
- n = sym->sy_value.X_add_symbol;
+ n = symbol_get_value_expression (sym)->X_add_symbol;
if (n == sym)
break;
sym = n;
reloc = retval[0] = (arelent *) xmalloc (sizeof (arelent));
retval[1] = NULL;
- reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym;
+ reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
if (mips_pic == EMBEDDED_PIC
else if (fixp->fx_r_type == BFD_RELOC_PCREL_LO16)
{
/* We use a special addend for an internal RELLO reloc. */
- if (fixp->fx_addsy->bsym->flags & BSF_SECTION_SYM)
+ if (symbol_section_p (fixp->fx_addsy))
reloc->addend = reloc->address - S_GET_VALUE (fixp->fx_subsy);
else
reloc->addend = fixp->fx_addnumber + reloc->address;
/* We use a special addend for an internal RELHI reloc. The
reloc is relative to the RELLO; adjust the addend
accordingly. */
- if (fixp->fx_addsy->bsym->flags & BSF_SECTION_SYM)
+ if (symbol_section_p (fixp->fx_addsy))
reloc->addend = (fixp->fx_next->fx_frag->fr_address
+ fixp->fx_next->fx_where
- S_GET_VALUE (fixp->fx_subsy));
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc2 = retval[1] = (arelent *) xmalloc (sizeof (arelent));
retval[2] = NULL;
- reloc2->sym_ptr_ptr = &fixp->fx_addsy->bsym;
+ reloc2->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ *reloc2->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc2->address = (reloc->address
+ (RELAX_RELOC2 (fixp->fx_frag->fr_subtype)
- RELAX_RELOC1 (fixp->fx_frag->fr_subtype)));
\f
typedef struct proc
{
- struct symbol *isym;
+ symbolS *isym;
unsigned long reg_mask;
unsigned long reg_offset;
unsigned long fpreg_mask;
cur_proc_ptr->isym = symbolP;
- symbolP->bsym->flags |= BSF_FUNCTION;
+ symbol_get_bfdsym (symbolP)->flags |= BSF_FUNCTION;
numprocs++;
}
/* tc-mips.h -- header file for tc-mips.c.
- Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1993, 94, 95, 96, 97, 1999 Free Software Foundation, Inc.
Contributed by the OSF and Ralph Campbell.
Written by Keith Knowles and Ralph Campbell, working independently.
Modified for ECOFF support by Ian Lance Taylor of Cygnus Support.
extern int mips_parse_long_option PARAMS ((const char *));
#define tc_frob_label(sym) mips_define_label (sym)
-extern void mips_define_label PARAMS ((struct symbol *));
+extern void mips_define_label PARAMS ((symbolS *));
#define tc_frob_file_before_adjust() mips_frob_file_before_adjust ()
extern void mips_frob_file_before_adjust PARAMS ((void));
/* tc-ns32k.h -- Opcode table for National Semi 32k processor
- Copyright (C) 1987, 92, 93, 94, 95, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1987, 92, 93, 94, 95, 97, 1999 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
extern void fix_new_ns32k PARAMS ((fragS *frag,
int where,
int size,
- struct symbol *add_symbol,
+ symbolS *add_symbol,
long offset,
int pcrel,
int im_disp,
/* tc-ppc.c -- Assemble for the PowerPC or POWER (RS/6000)
- Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1994, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of GAS, the GNU Assembler.
if (align2)
frag_align (align2, 0, 0);
if (S_GET_SEGMENT (symbolP) == bss_section)
- symbolP->sy_frag->fr_symbol = 0;
- symbolP->sy_frag = frag_now;
+ symbol_get_frag (symbolP)->fr_symbol = 0;
+ symbol_set_frag (symbolP, frag_now);
pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, size,
(char *) 0);
*pfrag = 0;
{
/* `*valuep' may contain the value of the symbol on which the reloc
will be based; we have to remove it. */
- if (fixp->fx_addsy->sy_used_in_reloc
+ if (symbol_used_in_reloc_p (fixp->fx_addsy)
&& S_GET_SEGMENT (fixp->fx_addsy) != absolute_section
&& S_GET_SEGMENT (fixp->fx_addsy) != undefined_section
&& ! bfd_is_com_section (S_GET_SEGMENT (fixp->fx_addsy)))
if (fixp->fx_pcrel)
abort ();
md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where,
- value + 0x8000 >> 16, 2);
+ (value + 0x8000) >> 16, 2);
break;
/* Because SDA21 modifies the register field, the size is set to 4
reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym;
+ reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
if (reloc->howto == (reloc_howto_type *) NULL)
/* tc-ppc.h -- Header file for tc-ppc.c.
- Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1994, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of GAS, the GNU Assembler.
struct ppc_tc_sy
{
/* We keep a few linked lists of symbols. */
- struct symbol *next;
+ symbolS *next;
/* Non-zero if the symbol should be output. The RS/6000 assembler
only outputs symbols that are external or are mentioned in a
.globl or .lglobl statement. */
int align;
/* For a function symbol, a symbol whose value is the size. The
field is NULL if there is no size. */
- struct symbol *size;
+ symbolS *size;
/* For a csect symbol, the last symbol which has been defined in
this csect, or NULL if none have been defined so far. For a .bs
symbol, the referenced csect symbol. */
- struct symbol *within;
+ symbolS *within;
};
#define TC_SYMFIELD_TYPE struct ppc_tc_sy
/* Get the symbol class from the name. */
#define tc_symbol_new_hook(sym) ppc_symbol_new_hook (sym)
-extern void ppc_symbol_new_hook PARAMS ((struct symbol *));
+extern void ppc_symbol_new_hook PARAMS ((symbolS *));
/* Set the symbol class of a label based on the csect. */
#define tc_frob_label(sym) ppc_frob_label (sym)
-extern void ppc_frob_label PARAMS ((struct symbol *));
+extern void ppc_frob_label PARAMS ((symbolS *));
/* TOC relocs requires special handling. */
#define tc_fix_adjustable(fixp) ppc_fix_adjustable (fixp)
/* Finish up the symbol. */
#define tc_frob_symbol(sym, punt) punt = ppc_frob_symbol (sym)
-extern int ppc_frob_symbol PARAMS ((struct symbol *));
+extern int ppc_frob_symbol PARAMS ((symbolS *));
/* Finish up the entire symtab. */
#define tc_adjust_symtab() ppc_adjust_symtab ()
#define TC_FORCE_RELOCATION_SECTION(FIXP,SEC) \
(TC_FORCE_RELOCATION (FIXP) \
- || ((FIXP)->fx_addsy && !(FIXP)->fx_subsy && (FIXP)->fx_addsy->bsym \
- && (FIXP)->fx_addsy->bsym->section != SEC))
+ || ((FIXP)->fx_addsy && !(FIXP)->fx_subsy \
+ && S_GET_SEGMENT ((FIXP)->fx_addsy) != SEC))
/* Support for SHF_EXCLUDE and SHT_ORDERED */
extern int ppc_section_letter PARAMS ((int, char **));
/* tc-sh.c -- Assemble code for the Hitachi Super-H
- Copyright (C) 1993, 94, 95, 96, 97, 1998 Free Software Foundation.
+ Copyright (C) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation.
This file is part of GAS, the GNU Assembler.
We have already adjusted the value of sym to include the
fragment address, so we undo that adjustment here. */
subseg_change (sec, 0);
- fix_new (sym->sy_frag, S_GET_VALUE (sym) - sym->sy_frag->fr_address,
+ fix_new (symbol_get_frag (sym),
+ S_GET_VALUE (sym) - symbol_get_frag (sym)->fr_address,
4, &abs_symbol, info.count, 0, BFD_RELOC_SH_COUNT);
}
}
case BFD_RELOC_VTABLE_INHERIT:
case BFD_RELOC_VTABLE_ENTRY:
fixP->fx_done = 0;
+#ifdef BFD_ASSEMBLER
+ return 0;
+#else
return;
+#endif
default:
abort ();
bfd_reloc_code_real_type r_type;
rel = (arelent *) xmalloc (sizeof (arelent));
- rel->sym_ptr_ptr = &fixp->fx_addsy->bsym;
+ rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
r_type = fixp->fx_r_type;
/* This file is tc-sh.h
- Copyright (C) 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
#ifdef OBJ_ELF
#define obj_fix_adjustable(fixP) sh_fix_adjustable(fixP)
+struct fix;
+extern boolean sh_fix_adjustable PARAMS ((struct fix *));
#endif
#define IGNORE_NONSTANDARD_ESCAPES
/* tc-sparc.c -- Assemble for the SPARC
- Copyright (C) 1989, 90-96, 97, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1989, 90-96, 97, 98, 1999 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
don't want to include the value of an externally visible symbol. */
if (fixP->fx_addsy != NULL)
{
- if (fixP->fx_addsy->sy_used_in_reloc
+ if (symbol_used_in_reloc_p (fixP->fx_addsy)
&& (S_IS_EXTERNAL (fixP->fx_addsy)
|| S_IS_WEAK (fixP->fx_addsy)
|| (sparc_pic_code && ! fixP->fx_pcrel)
&& fixP->fx_r_type != BFD_RELOC_32_PCREL_S2
&& fixP->fx_addsy != NULL
&& ! S_IS_COMMON (fixP->fx_addsy)
- && (fixP->fx_addsy->bsym->flags & BSF_SECTION_SYM) == 0)
+ && symbol_section_p (fixP->fx_addsy))
fixP->fx_addnumber -= 2 * S_GET_VALUE (fixP->fx_addsy);
/* When generating PIC code, we need to fiddle to get
being done! */
if (! sparc_pic_code
|| fixP->fx_addsy == NULL
- || (fixP->fx_addsy->bsym->flags & BSF_SECTION_SYM) != 0)
+ || symbol_section_p (fixP->fx_addsy))
++val;
insn |= val & 0x3fffffff;
break;
reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = &fixp->fx_addsy->bsym;
+ reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
switch (fixp->fx_r_type)
|| code == BFD_RELOC_SPARC_PC10
|| code == BFD_RELOC_SPARC_PC22)
reloc->addend = fixp->fx_addnumber;
- else if ((fixp->fx_addsy->bsym->flags & BSF_SECTION_SYM) != 0)
+ else if (symbol_section_p (fixp->fx_addsy))
reloc->addend = (section->vma
+ fixp->fx_addnumber
+ md_pcrel_from (fixp));
ret = fixP->fx_where + fixP->fx_frag->fr_address;
if (! sparc_pic_code
|| fixP->fx_addsy == NULL
- || (fixP->fx_addsy->bsym->flags & BSF_SECTION_SYM) != 0)
+ || symbol_section_p (fixP->fx_addsy))
ret += fixP->fx_size;
return ret;
}
/* detach from old frag */
if (S_GET_SEGMENT(symbolP) == bss_section)
- symbolP->sy_frag->fr_symbol = NULL;
+ symbol_get_frag (symbolP)->fr_symbol = NULL;
- symbolP->sy_frag = frag_now;
+ symbol_set_frag (symbolP, frag_now);
pfrag = frag_var (rs_org, 1, 1, (relax_substateT)0, symbolP,
(offsetT) size, (char *)0);
*pfrag = 0;
}
#ifdef OBJ_ELF
- if (symbolP->local)
+ if (symbol_get_obj (symbolP)->local)
{
segT old_sec;
int old_subsec;
if (align)
frag_align (align, 0, 0);
if (S_GET_SEGMENT (symbolP) == bss_section)
- symbolP->sy_frag->fr_symbol = 0;
- symbolP->sy_frag = frag_now;
+ symbol_get_frag (symbolP)->fr_symbol = 0;
+ symbol_set_frag (symbolP, frag_now);
p = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP,
(offsetT) size, (char *) 0);
*p = 0;
}
#ifdef BFD_ASSEMBLER
- symbolP->bsym->flags |= BSF_OBJECT;
+ symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT;
#endif
demand_empty_rest_of_line ();
segT to_seg; /* Target segment of the address. */
register valueT this_add_number;
- register struct symbol *this_add_symbol; /* +ve (minuend) symbol. */
+ register symbolS *this_add_symbol; /* +ve (minuend) symbol. */
/* tahoe_opcodeT opcode_as_number; fixme: remove this line *//* The opcode as a number. */
char *opcodeP; /* Where it is in a frag. */
/* tc-vax.c - vax-specific -
- Copyright (C) 1987, 91, 92, 93, 94, 95, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1987, 91, 92, 93, 94, 95, 98, 1999
+ Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
segT to_seg;
valueT this_add_number;
/* Positive (minuend) symbol. */
- struct symbol *this_add_symbol;
+ symbolS *this_add_symbol;
/* As a number. */
long opcode_as_number;
/* Least significant byte 1st. */
void
tc_coff_symbol_emit_hook (x)
- struct symbol *x;
+ symbolS *x;
{
}
/* tc-z8k.c -- Assemble code for the Zilog Z800n
- Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation.
+ Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation.
This file is part of GAS, the GNU Assembler.
void
tc_coff_symbol_emit_hook (s)
- struct symbol *s;
+ symbolS *s;
{
}
/* 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
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
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;
}
\f
/* Add a page to a varray object. */
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;
/* 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,
++input_line_pointer;
size = get_absolute_expression ();
- symbolp->ecoff_extern_size = size;
+ symbol_get_obj (symbolp)->ecoff_extern_size = size;
}
\f
/* Parse .file directives. */
ignore_rest_of_line();
return;
}
- symbolP->sy_value = exp;
+ symbol_set_value_expression (symbolP, &exp);
}
}
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;
}
/* 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"),
|| 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;
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))
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)
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. */
&& ! 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);
}
}
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);
}
/* ecoff.h -- header file for ECOFF debugging support
- Copyright (C) 1993, 94, 95, 96, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
Contributed by Cygnus Support.
Put together by Ian Lance Taylor <ian@cygnus.com>.
/* This function should be called when a new symbol is created, by
obj_symbol_new_hook. */
-extern void ecoff_symbol_new_hook PARAMS ((struct symbol *));
+extern void ecoff_symbol_new_hook PARAMS ((symbolS *));
/* This function should be called by the obj_frob_symbol hook. */
-extern void ecoff_frob_symbol PARAMS ((struct symbol *));
+extern void ecoff_frob_symbol PARAMS ((symbolS *));
/* Build the ECOFF debugging information. This should be called by
obj_frob_file. This fills in the counts in *HDR; the offsets are
/* This routine is called from the ECOFF code to set the external
information for a symbol. */
#ifndef obj_ecoff_set_ext
-extern void obj_ecoff_set_ext PARAMS ((struct symbol *, EXTR *));
+extern void obj_ecoff_set_ext PARAMS ((symbolS *, EXTR *));
#endif
/* This routine is used to patch up a line number directive when
extern int ecoff_no_current_file PARAMS ((void));
/* This function returns the symbol associated with the current proc. */
-extern struct symbol *ecoff_get_cur_proc_sym PARAMS ((void));
+extern symbolS *ecoff_get_cur_proc_sym PARAMS ((void));
#endif /* ECOFF_DEBUGGING */
/* expr.c -operands, expressions-
- Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 1998
+ Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
? absolute_section
: expr_section),
0, &zero_address_frag);
- symbolP->sy_value = *expressionP;
+ symbol_set_value_expression (symbolP, expressionP);
if (expressionP->X_op == O_constant)
resolve_symbol_value (symbolP, 1);
/* The PA port needs this information. */
if (expressionP->X_add_symbol)
- expressionP->X_add_symbol->sy_used = 1;
+ symbol_mark_used (expressionP->X_add_symbol);
switch (expressionP->X_op)
{
break;
case O_subtract:
if (expressionP->X_op_symbol == expressionP->X_add_symbol
- || ((expressionP->X_op_symbol->sy_frag
- == expressionP->X_add_symbol->sy_frag)
+ || ((symbol_get_frag (expressionP->X_op_symbol)
+ == symbol_get_frag (expressionP->X_add_symbol))
&& SEG_NORMAL (S_GET_SEGMENT (expressionP->X_add_symbol))
&& (S_GET_VALUE (expressionP->X_op_symbol)
== S_GET_VALUE (expressionP->X_add_symbol))))
else if (op_left == O_subtract
&& right.X_op == O_symbol
&& resultP->X_op == O_symbol
- && (right.X_add_symbol->sy_frag
- == resultP->X_add_symbol->sy_frag)
+ && (symbol_get_frag (right.X_add_symbol)
+ == symbol_get_frag (resultP->X_add_symbol))
&& SEG_NORMAL (S_GET_SEGMENT (right.X_add_symbol)))
{
/* The PA port needs this information. */
if (resultP->X_add_symbol)
- resultP->X_add_symbol->sy_used = 1;
+ symbol_mark_used (resultP->X_add_symbol);
return resultP->X_op == O_constant ? absolute_section : retval;
}
/* expr.h -> header file for expr.c
- Copyright (C) 1987, 92-97, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1987, 92-98, 1999 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
typedef struct expressionS
{
/* The main symbol. */
- struct symbol *X_add_symbol;
+ symbolS *X_add_symbol;
/* The second symbol, if needed. */
- struct symbol *X_op_symbol;
+ symbolS *X_op_symbol;
/* A number to add. */
offsetT X_add_number;
/* The type of the expression. We can't assume that an arbitrary
extern void expr_set_precedence PARAMS ((void));
extern segT expr PARAMS ((int rank, expressionS * resultP));
extern unsigned int get_single_number PARAMS ((void));
-extern struct symbol *make_expr_symbol PARAMS ((expressionS * expressionP));
+extern symbolS *make_expr_symbol PARAMS ((expressionS * expressionP));
extern int expr_symbol_where
- PARAMS ((struct symbol *, char **, unsigned int *));
+ PARAMS ((symbolS *, char **, unsigned int *));
-extern struct symbol * expr_build_uconstant PARAMS ((offsetT));
-extern struct symbol * expr_build_unary PARAMS ((operatorT, struct symbol *));
-extern struct symbol * expr_build_binary
- PARAMS ((operatorT, struct symbol *, struct symbol *));
-extern struct symbol * expr_build_dot PARAMS ((void));
+extern symbolS *expr_build_uconstant PARAMS ((offsetT));
+extern symbolS *expr_build_unary PARAMS ((operatorT, symbolS *));
+extern symbolS *expr_build_binary PARAMS ((operatorT, symbolS *, symbolS *));
+extern symbolS *expr_build_dot PARAMS ((void));
/* end of expr.h */
/* frags.h - Header file for the frag concept.
- Copyright (C) 1987, 92, 93, 94, 95, 97, 1998
+ Copyright (C) 1987, 92, 93, 94, 95, 97, 98, 1999
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
/* (Variable) number of chars after above. May be 0. */
offsetT fr_var;
/* For variable-length tail. */
- struct symbol *fr_symbol;
+ symbolS *fr_symbol;
/* For variable-length tail. */
offsetT fr_offset;
/* Points to opcode low addr byte, for relaxation. */
{
#ifdef BFD_ASSEMBLER
/* Don't report section symbols. They are not interesting. */
- if (ptr->bsym->flags & BSF_SECTION_SYM)
+ if (symbol_section_p (ptr))
continue;
#endif
if (S_GET_NAME (ptr))
got_some = 1;
}
- if (ptr->sy_frag && ptr->sy_frag->line)
+ if (symbol_get_frag (ptr) && symbol_get_frag (ptr)->line)
{
fprintf (list_file, "%20s:%-5d %s:%s %s\n",
- ptr->sy_frag->line->file->filename,
- ptr->sy_frag->line->line,
+ symbol_get_frag (ptr)->line->file->filename,
+ symbol_get_frag (ptr)->line->line,
segment_name (S_GET_SEGMENT (ptr)),
buf, S_GET_NAME (ptr));
}
/* Generic stabs parsing for gas.
- Copyright (C) 1989, 90, 91, 93, 94, 95, 96, 97, 1998
+ Copyright (C) 1989, 90, 91, 93, 94, 95, 96, 97, 98, 1999
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
if (what == 's' || what == 'n')
{
/* Pick up the value from the input line. */
- symbol->sy_frag = &zero_address_frag;
+ symbol_set_frag (symbol, &zero_address_frag);
pseudo_set (symbol);
}
else
{
/* .stabd sets the name to NULL. Why? */
S_SET_NAME (symbol, NULL);
- symbol->sy_frag = frag_now;
+ symbol_set_frag (symbol, frag_now);
S_SET_VALUE (symbol, (valueT) frag_now_fix ());
}
/* struct_symbol.h - Internal symbol structure
- Copyright (C) 1987, 92, 93, 94, 95, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1987, 92, 93, 94, 95, 98, 1999 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
#ifndef __struc_symbol_h__
#define __struc_symbol_h__
-#ifdef BFD_ASSEMBLER
-/* The BFD code wants to walk the list in both directions. */
-#undef SYMBOLS_NEED_BACKPOINTERS
-#define SYMBOLS_NEED_BACKPOINTERS
-#endif
+/* The information we keep for a symbol. Note that the symbol table
+ holds pointers both to this and to local_symbol structures. See
+ below. */
-/* our version of an nlist node */
struct symbol
{
-#ifndef BFD_ASSEMBLER
+#ifdef BFD_ASSEMBLER
+ /* BFD symbol */
+ asymbol *bsym;
+#else
/* The (4-origin) position of sy_name in the symbol table of the object
file. This will be 0 for (nameless) .stabd symbols.
/* The 24 bit symbol number. Symbol numbers start at 0 and are unsigned. */
long sy_number;
-#else
- /* BFD symbol */
- asymbol *bsym;
#endif
/* The value of the symbol. */
#ifdef TC_SYMFIELD_TYPE
TC_SYMFIELD_TYPE sy_tc;
#endif
-
-#ifdef TARGET_SYMBOL_FIELDS
- TARGET_SYMBOL_FIELDS
-#endif
};
-typedef struct symbol symbolS;
+/* A pointer in the symbol may point to either a complete symbol
+ (struct symbol above) or to a local symbol (struct local_symbol
+ defined here). The symbol code can detect the case by examining
+ the first field. It is always NULL for a local symbol.
-#ifndef WORKING_DOT_WORD
-struct broken_word
- {
- /* Linked list -- one of these structures per ".word x-y+C"
- expression. */
- struct broken_word *next_broken_word;
- /* Segment and subsegment for broken word. */
- segT seg;
- subsegT subseg;
- /* Which frag is this broken word in? */
- fragS *frag;
- /* Where in the frag is it? */
- char *word_goes_here;
- /* Where to add the break. */
- fragS *dispfrag; /* where to add the break */
- /* Operands of expression. */
- symbolS *add;
- symbolS *sub;
- offsetT addnum;
-
- int added; /* nasty thing happend yet? */
- /* 1: added and has a long-jump */
- /* 2: added but uses someone elses long-jump */
-
- /* Pointer to broken_word with a similar long-jump. */
- struct broken_word *use_jump;
- };
-extern struct broken_word *broken_words;
-#endif /* ndef WORKING_DOT_WORD */
-
-/*
- * Current means for getting from symbols to segments and vice verse.
- * This will change for infinite-segments support (e.g. COFF).
- */
-extern const segT N_TYPE_seg[]; /* subseg.c */
-
-#define SEGMENT_TO_SYMBOL_TYPE(seg) ( seg_N_TYPE [(int) (seg)] )
-extern const short seg_N_TYPE[];/* subseg.c */
-
-#define N_REGISTER 30 /* Fake N_TYPE value for SEG_REGISTER */
-
-void symbol_clear_list_pointers PARAMS ((symbolS * symbolP));
-
-#ifdef SYMBOLS_NEED_BACKPOINTERS
-
-void symbol_insert PARAMS ((symbolS * addme, symbolS * target,
- symbolS ** rootP, symbolS ** lastP));
-void symbol_remove PARAMS ((symbolS * symbolP, symbolS ** rootP,
- symbolS ** lastP));
-
-#define symbol_previous(s) ((s)->sy_previous)
+ We do this because we ordinarily only need a small amount of
+ information for a local symbol. The symbol table takes up a lot of
+ space, and storing less information for a local symbol can make a
+ big difference in assembler memory usage when assembling a large
+ file. */
-#endif /* SYMBOLS_NEED_BACKPOINTERS */
-
-void verify_symbol_chain PARAMS ((symbolS * rootP, symbolS * lastP));
-void verify_symbol_chain_2 PARAMS ((symbolS * symP));
+struct local_symbol
+{
+ /* This pointer is always NULL to indicate that this is a local
+ symbol. */
+ asymbol *lsy_marker;
+
+ /* The symbol section. This also serves as a flag. If this is
+ reg_section, then this symbol has been converted into a regular
+ symbol, and sy_sym points to it. */
+ segT lsy_section;
+
+ /* The symbol name. */
+ const char *lsy_name;
+
+ /* The symbol frag or the real symbol, depending upon the value in
+ sy_section. If the symbol has been fully resolved, lsy_frag is
+ set to NULL. */
+ union
+ {
+ fragS *lsy_frag;
+ symbolS *lsy_sym;
+ } u;
-void symbol_append PARAMS ((symbolS * addme, symbolS * target,
- symbolS ** rootP, symbolS ** lastP));
+ /* The offset within the frag. */
+ valueT lsy_offset;
+};
-#define symbol_next(s) ((s)->sy_next)
+#define local_symbol_converted_p(l) ((l)->lsy_section == reg_section)
+#define local_symbol_mark_converted(l) ((l)->lsy_section = reg_section)
+#define local_symbol_resolved_p(l) ((l)->u.lsy_frag == NULL)
+#define local_symbol_mark_resolved(l) ((l)->u.lsy_frag = NULL)
+#define local_symbol_get_frag(l) ((l)->u.lsy_frag)
+#define local_symbol_set_frag(l, f) ((l)->u.lsy_frag = (f))
+#define local_symbol_get_real_symbol(l) ((l)->u.lsy_sym)
+#define local_symbol_set_real_symbol(l, s) ((l)->u.lsy_sym = (s))
#endif /* __struc_symbol_h__ */
/* subsegs.c - subsegments -
- Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 1997
+ Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
if (S_GET_SEGMENT (s) == undefined_section)
{
S_SET_SEGMENT (s, sec);
- s->sy_frag = &zero_address_frag;
+ symbol_set_frag (s, &zero_address_frag);
}
}
}
/* Use the BFD section symbol, if possible. */
if (obj_sec_sym_ok_for_reloc (sec))
- s->bsym = sec->symbol;
+ symbol_set_bfdsym (s, sec->symbol);
seginfo->sym = s;
return s;
/* symbols.c -symbol table-
- Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 1998
+ Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
#include "obstack.h" /* For "symbols.h" */
#include "subsegs.h"
+#include "struc-symbol.h"
+
/* This is non-zero if symbols are case sensitive, which is the
default. */
int symbols_case_sensitive = 1;
/* symbol-name => struct symbol pointer */
static struct hash_control *sy_hash;
+/* Table of local symbols. */
+static struct hash_control *local_hash;
+
/* Below are commented in "symbols.h". */
symbolS *symbol_rootP;
symbolS *symbol_lastP;
return symbolP;
}
-symbolS *
-symbol_create (name, segment, valu, frag)
- const char *name; /* It is copied, the caller can destroy/modify */
- segT segment; /* Segment identifier (SEG_<something>) */
- valueT valu; /* Symbol value */
- fragS *frag; /* Associated fragment */
+/* Save a symbol name on a permanent obstack, and convert it according
+ to the object file format. */
+
+static char *
+save_symbol_name (name)
+ const char *name;
{
unsigned int name_length;
- char *preserved_copy_of_name;
- symbolS *symbolP;
+ char *ret;
name_length = strlen (name) + 1; /* +1 for \0 */
obstack_grow (¬es, name, name_length);
- preserved_copy_of_name = obstack_finish (¬es);
+ ret = obstack_finish (¬es);
+
#ifdef STRIP_UNDERSCORE
- if (preserved_copy_of_name[0] == '_')
- preserved_copy_of_name++;
+ if (ret[0] == '_')
+ ++ret;
#endif
#ifdef tc_canonicalize_symbol_name
- preserved_copy_of_name =
- tc_canonicalize_symbol_name (preserved_copy_of_name);
+ ret = tc_canonicalize_symbol_name (ret);
#endif
if (! symbols_case_sensitive)
{
unsigned char *s;
- for (s = (unsigned char *) preserved_copy_of_name; *s != '\0'; s++)
+ for (s = (unsigned char *) ret; *s != '\0'; s++)
if (islower (*s))
*s = toupper (*s);
}
+ return ret;
+}
+
+symbolS *
+symbol_create (name, segment, valu, frag)
+ const char *name; /* It is copied, the caller can destroy/modify */
+ segT segment; /* Segment identifier (SEG_<something>) */
+ valueT valu; /* Symbol value */
+ fragS *frag; /* Associated fragment */
+{
+ char *preserved_copy_of_name;
+ symbolS *symbolP;
+
+ preserved_copy_of_name = save_symbol_name (name);
+
symbolP = (symbolS *) obstack_alloc (¬es, sizeof (symbolS));
/* symbol must be born in some fixed state. This seems as good as any. */
return symbolP;
}
\f
+#ifdef BFD_ASSEMBLER
+
+/* Local symbol support. If we can get away with it, we keep only a
+ small amount of information for local symbols. */
+
+static struct local_symbol *local_symbol_make PARAMS ((const char *, segT,
+ valueT, fragS *));
+static symbolS *local_symbol_convert PARAMS ((struct local_symbol *));
+
+/* Used for statistics. */
+
+static unsigned long local_symbol_count;
+static unsigned long local_symbol_conversion_count;
+
+/* This macro is called with a symbol argument passed by reference.
+ It returns whether this is a local symbol. If necessary, it
+ changes its argument to the real symbol. */
+
+#define LOCAL_SYMBOL_CHECK(s) \
+ (s->bsym == NULL \
+ ? (local_symbol_converted_p ((struct local_symbol *) s) \
+ ? (s = local_symbol_get_real_symbol ((struct local_symbol *) s), \
+ 0) \
+ : 1) \
+ : 0)
+
+/* Create a local symbol and insert it into the local hash table. */
+
+static struct local_symbol *
+local_symbol_make (name, section, offset, frag)
+ const char *name;
+ segT section;
+ valueT offset;
+ fragS *frag;
+{
+ char *name_copy;
+ struct local_symbol *ret;
+
+ ++local_symbol_count;
+
+ name_copy = save_symbol_name (name);
+
+ ret = (struct local_symbol *) obstack_alloc (¬es, sizeof *ret);
+ ret->lsy_marker = NULL;
+ ret->lsy_name = name_copy;
+ ret->lsy_section = section;
+ local_symbol_set_frag (ret, frag);
+ ret->lsy_offset = offset;
+
+ hash_jam (local_hash, name_copy, (PTR) ret);
+
+ return ret;
+}
+
+/* Convert a local symbol into a real symbol. Note that we do not
+ reclaim the space used by the local symbol. */
+
+static symbolS *
+local_symbol_convert (locsym)
+ struct local_symbol *locsym;
+{
+ symbolS *ret;
+
+ assert (locsym->lsy_marker == NULL);
+ if (local_symbol_converted_p (locsym))
+ return local_symbol_get_real_symbol (locsym);
+
+ ++local_symbol_conversion_count;
+
+ ret = symbol_new (locsym->lsy_name, locsym->lsy_section, locsym->lsy_offset,
+ local_symbol_get_frag (locsym));
+
+ if (local_symbol_resolved_p (locsym))
+ ret->sy_resolved = 1;
+
+ /* Local symbols are always either defined or used. */
+ ret->sy_used = 1;
+
+ symbol_table_insert (ret);
+
+ local_symbol_mark_converted (locsym);
+ local_symbol_set_real_symbol (locsym, ret);
+
+ hash_jam (local_hash, locsym->lsy_name, NULL);
+
+ return ret;
+}
+
+#else /* ! BFD_ASSEMBLER */
+
+#define LOCAL_SYMBOL_CHECK(s) 0
+#define local_symbol_convert(s) ((symbolS *) s)
+
+#endif /* ! BFD_ASSEMBLER */
+\f
/*
* colon()
/*
* Now check for undefined symbols
*/
- if (!S_IS_DEFINED (symbolP) || S_IS_COMMON (symbolP))
+ if (LOCAL_SYMBOL_CHECK (symbolP))
+ {
+ struct local_symbol *locsym = (struct local_symbol *) symbolP;
+
+ if (locsym->lsy_section != undefined_section
+ && (local_symbol_get_frag (locsym) != frag_now
+ || locsym->lsy_section != now_seg
+ || locsym->lsy_offset != frag_now_fix ()))
+ {
+ as_bad (_("Symbol %s already defined."), sym_name);
+ return symbolP;
+ }
+
+ locsym->lsy_section = now_seg;
+ local_symbol_set_frag (locsym, frag_now);
+ locsym->lsy_offset = frag_now_fix ();
+ }
+ else if (!S_IS_DEFINED (symbolP) || S_IS_COMMON (symbolP))
{
if (S_GET_VALUE (symbolP) == 0)
{
} /* if this symbol is not yet defined */
}
+#ifdef BFD_ASSEMBLER
+ else if (! flag_keep_locals && bfd_is_local_label_name (stdoutput, sym_name))
+ {
+ symbolP = (symbolS *) local_symbol_make (sym_name, now_seg,
+ (valueT) frag_now_fix (),
+ frag_now);
+ }
+#endif /* BFD_ASSEMBLER */
else
{
symbolP = symbol_new (sym_name, now_seg, (valueT) frag_now_fix (),
{
/* This symbol is actually being defined within an MRI common
section. This requires special handling. */
+ if (LOCAL_SYMBOL_CHECK (symbolP))
+ symbolP = local_symbol_convert ((struct local_symbol *) symbolP);
symbolP->sy_value.X_op = O_symbol;
symbolP->sy_value.X_add_symbol = mri_common_symbol;
symbolP->sy_value.X_add_number = S_GET_VALUE (mri_common_symbol);
know (symbolP);
know (S_GET_NAME (symbolP));
+ if (LOCAL_SYMBOL_CHECK (symbolP))
+ {
+ error_string = hash_jam (local_hash, S_GET_NAME (symbolP),
+ (PTR) symbolP);
+ if (error_string != NULL)
+ as_fatal (_("Inserting \"%s\" into symbol table failed: %s"),
+ S_GET_NAME (symbolP), error_string);
+ return;
+ }
+
if ((error_string = hash_jam (sy_hash, S_GET_NAME (symbolP), (PTR) symbolP)))
{
as_fatal (_("Inserting \"%s\" into symbol table failed: %s"),
if (symbolP == NULL)
{
+#ifdef BFD_ASSEMBLER
+ if (! flag_keep_locals && bfd_is_local_label_name (stdoutput, name))
+ {
+ symbolP = md_undefined_symbol ((char *) name);
+ if (symbolP != NULL)
+ return symbolP;
+
+ symbolP = (symbolS *) local_symbol_make (name, undefined_section,
+ (valueT) 0,
+ &zero_address_frag);
+ return symbolP;
+ }
+#endif
+
symbolP = symbol_make (name);
symbol_table_insert (symbolP);
CONST char *name;
int strip_underscore;
{
+ struct local_symbol *locsym;
+
if (strip_underscore && *name == '_')
name++;
*copy = '\0';
}
+ locsym = (struct local_symbol *) hash_find (local_hash, name);
+ if (locsym != NULL)
+ return (symbolS *) locsym;
+
return ((symbolS *) hash_find (sy_hash, name));
}
symbolS **rootPP;
symbolS **lastPP;
{
+ if (LOCAL_SYMBOL_CHECK (addme))
+ abort ();
+ if (target != NULL && LOCAL_SYMBOL_CHECK (target))
+ abort ();
+
if (target == NULL)
{
know (*rootPP == NULL);
symbol_clear_list_pointers (symbolP)
symbolS *symbolP;
{
+ if (LOCAL_SYMBOL_CHECK (symbolP))
+ abort ();
symbolP->sy_next = NULL;
#ifdef SYMBOLS_NEED_BACKPOINTERS
symbolP->sy_previous = NULL;
symbolS **rootPP;
symbolS **lastPP;
{
+ if (LOCAL_SYMBOL_CHECK (symbolP))
+ abort ();
+
if (symbolP == *rootPP)
{
*rootPP = symbolP->sy_next;
symbolS **rootPP;
symbolS **lastPP;
{
+ if (LOCAL_SYMBOL_CHECK (addme))
+ abort ();
+ if (LOCAL_SYMBOL_CHECK (target))
+ abort ();
+
if (target->sy_previous != NULL)
{
target->sy_previous->sy_next = addme;
for (; symbol_next (symbolP) != NULL; symbolP = symbol_next (symbolP))
{
+#ifdef BFD_ASSEMBLER
+ assert (symbolP->bsym != NULL);
+#endif
#ifdef SYMBOLS_NEED_BACKPOINTERS
assert (symbolP->sy_next->sy_previous == symbolP);
#else
valueT final_val;
segT final_seg;
+ if (LOCAL_SYMBOL_CHECK (symp))
+ {
+ struct local_symbol *locsym = (struct local_symbol *) symp;
+
+ if (local_symbol_resolved_p (locsym))
+ return locsym->lsy_offset;
+
+ final_val = (local_symbol_get_frag (locsym)->fr_address
+ + locsym->lsy_offset);
+
+ if (finalize)
+ {
+ locsym->lsy_offset = final_val;
+ local_symbol_mark_resolved (locsym);
+ }
+
+ return final_val;
+ }
+
if (symp->sy_resolved)
{
if (symp->sy_value.X_op == O_constant)
/* This is a symbol inside an MRI common section. The
relocation routines are going to handle it specially.
Don't change the value. */
- resolved = add_symbol->sy_resolved;
+ resolved = symbol_resolved_p (add_symbol);
break;
}
if (finalize && final_val == 0)
- copy_symbol_attributes (symp, add_symbol);
+ {
+ if (LOCAL_SYMBOL_CHECK (add_symbol))
+ add_symbol = local_symbol_convert ((struct local_symbol *)
+ add_symbol);
+ copy_symbol_attributes (symp, add_symbol);
+ }
/* If we have equated this symbol to an undefined symbol, we
keep X_op set to O_symbol, and we don't change
symp->sy_value.X_add_number = final_val;
}
final_val = 0;
- resolved = add_symbol->sy_resolved;
+ resolved = symbol_resolved_p (add_symbol);
goto exit_dont_set_value;
}
else
final_seg = S_GET_SEGMENT (add_symbol);
}
- resolved = add_symbol->sy_resolved;
+ resolved = symbol_resolved_p (add_symbol);
break;
case O_uminus:
if (final_seg == expr_section || final_seg == undefined_section)
final_seg = absolute_section;
- resolved = add_symbol->sy_resolved;
+ resolved = symbol_resolved_p (add_symbol);
break;
case O_multiply:
final_val += symp->sy_frag->fr_address + left;
if (final_seg == expr_section || final_seg == undefined_section)
final_seg = absolute_section;
- resolved = (add_symbol->sy_resolved && op_symbol->sy_resolved);
+ resolved = (symbol_resolved_p (add_symbol)
+ && symbol_resolved_p (op_symbol));
break;
case O_register:
return final_val;
}
+#ifdef BFD_ASSEMBLER
+
+static void resolve_local_symbol PARAMS ((const char *, PTR));
+
+/* A static function passed to hash_traverse. */
+
+static void
+resolve_local_symbol (key, value)
+ const char *key;
+ PTR value;
+{
+ if (value != NULL)
+ resolve_symbol_value (value, 1);
+}
+
+#endif
+
+/* Resolve all local symbols. */
+
+void
+resolve_local_symbol_values ()
+{
+#ifdef BFD_ASSEMBLER
+ hash_traverse (local_hash, resolve_local_symbol);
+#endif
+}
+
/* Dollar labels look like a number followed by a dollar sign. Eg, "42$".
They are *really* local. That is, they go out of scope whenever we see a
label that isn't local. Also, like fb labels, there can be multiple
S_GET_VALUE (s)
symbolS *s;
{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return ((struct local_symbol *) s)->lsy_offset;
+
if (!s->sy_resolved && s->sy_value.X_op != O_constant)
resolve_symbol_value (s, 1);
if (s->sy_value.X_op != O_constant)
symbolS *s;
valueT val;
{
+ if (LOCAL_SYMBOL_CHECK (s))
+ {
+ ((struct local_symbol *) s)->lsy_offset = val;
+ return;
+ }
+
s->sy_value.X_op = O_constant;
s->sy_value.X_add_number = (offsetT) val;
s->sy_value.X_unsigned = 0;
copy_symbol_attributes (dest, src)
symbolS *dest, *src;
{
+ if (LOCAL_SYMBOL_CHECK (dest))
+ abort ();
+ if (LOCAL_SYMBOL_CHECK (src))
+ abort ();
+
#ifdef BFD_ASSEMBLER
/* In an expression, transfer the settings of these flags.
The user can override later, of course. */
S_IS_FUNCTION (s)
symbolS *s;
{
- flagword flags = s->bsym->flags;
+ flagword flags;
+
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 0;
+
+ flags = s->bsym->flags;
return (flags & BSF_FUNCTION) != 0;
}
S_IS_EXTERNAL (s)
symbolS *s;
{
- flagword flags = s->bsym->flags;
+ flagword flags;
+
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 0;
+
+ flags = s->bsym->flags;
/* sanity check */
if ((flags & BSF_LOCAL) && (flags & BSF_GLOBAL))
S_IS_WEAK (s)
symbolS *s;
{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 0;
return (s->bsym->flags & BSF_WEAK) != 0;
}
S_IS_COMMON (s)
symbolS *s;
{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 0;
return bfd_is_com_section (s->bsym->section);
}
S_IS_DEFINED (s)
symbolS *s;
{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return ((struct local_symbol *) s)->lsy_section != undefined_section;
return s->bsym->section != undefined_section;
}
S_IS_DEBUG (s)
symbolS *s;
{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 0;
if (s->bsym->flags & BSF_DEBUGGING)
return 1;
return 0;
S_IS_LOCAL (s)
symbolS *s;
{
- flagword flags = s->bsym->flags;
+ flagword flags;
const char *name;
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 1;
+
+ flags = s->bsym->flags;
+
/* sanity check */
if ((flags & BSF_LOCAL) && (flags & BSF_GLOBAL))
abort ();
S_GET_NAME (s)
symbolS *s;
{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return ((struct local_symbol *) s)->lsy_name;
return s->bsym->name;
}
S_GET_SEGMENT (s)
symbolS *s;
{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return ((struct local_symbol *) s)->lsy_section;
return s->bsym->section;
}
faults assigning back to const global symbols such as *ABS*, but it
shouldn't happen anyway. */
+ if (LOCAL_SYMBOL_CHECK (s))
+ {
+ if (seg == reg_section)
+ s = local_symbol_convert ((struct local_symbol *) s);
+ else
+ {
+ ((struct local_symbol *) s)->lsy_section = seg;
+ return;
+ }
+ }
+
if (s->bsym->flags & BSF_SECTION_SYM)
{
if (s->bsym->section != seg)
S_SET_EXTERNAL (s)
symbolS *s;
{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
if ((s->bsym->flags & BSF_WEAK) != 0)
{
/* Let .weak override .global. */
S_CLEAR_EXTERNAL (s)
symbolS *s;
{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return;
if ((s->bsym->flags & BSF_WEAK) != 0)
{
/* Let .weak override. */
S_SET_WEAK (s)
symbolS *s;
{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
s->bsym->flags |= BSF_WEAK;
s->bsym->flags &= ~(BSF_GLOBAL|BSF_LOCAL);
}
symbolS *s;
char *name;
{
+ if (LOCAL_SYMBOL_CHECK (s))
+ {
+ ((struct local_symbol *) s)->lsy_name = name;
+ return;
+ }
s->bsym->name = name;
}
#endif /* BFD_ASSEMBLER */
+#ifdef SYMBOLS_NEED_BACKPOINTERS
+
+/* Return the previous symbol in a chain. */
+
+symbolS *
+symbol_previous (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ abort ();
+ return s->sy_previous;
+}
+
+#endif /* SYMBOLS_NEED_BACKPOINTERS */
+
+/* Return the next symbol in a chain. */
+
+symbolS *
+symbol_next (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ abort ();
+ return s->sy_next;
+}
+
+/* Return a pointer to the value of a symbol as an expression. */
+
+expressionS *
+symbol_get_value_expression (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
+ return &s->sy_value;
+}
+
+/* Set the value of a symbol to an expression. */
+
+void
+symbol_set_value_expression (s, exp)
+ symbolS *s;
+ const expressionS *exp;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
+ s->sy_value = *exp;
+}
+
+/* Set the frag of a symbol. */
+
+void
+symbol_set_frag (s, f)
+ symbolS *s;
+ fragS *f;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ {
+ local_symbol_set_frag ((struct local_symbol *) s, f);
+ return;
+ }
+ s->sy_frag = f;
+}
+
+/* Return the frag of a symbol. */
+
+fragS *
+symbol_get_frag (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return local_symbol_get_frag ((struct local_symbol *) s);
+ return s->sy_frag;
+}
+
+/* Mark a symbol as having been used. */
+
+void
+symbol_mark_used (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return;
+ s->sy_used = 1;
+}
+
+/* Clear the mark of whether a symbol has been used. */
+
+void
+symbol_clear_used (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
+ s->sy_used = 0;
+}
+
+/* Return whether a symbol has been used. */
+
+int
+symbol_used_p (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 1;
+ return s->sy_used;
+}
+
+/* Mark a symbol as having been used in a reloc. */
+
+void
+symbol_mark_used_in_reloc (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
+ s->sy_used_in_reloc = 1;
+}
+
+/* Clear the mark of whether a symbol has been used in a reloc. */
+
+void
+symbol_clear_used_in_reloc (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return;
+ s->sy_used_in_reloc = 0;
+}
+
+/* Return whether a symbol has been used in a reloc. */
+
+int
+symbol_used_in_reloc_p (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 0;
+ return s->sy_used_in_reloc;
+}
+
+/* Mark a symbol as an MRI common symbol. */
+
+void
+symbol_mark_mri_common (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
+ s->sy_mri_common = 1;
+}
+
+/* Clear the mark of whether a symbol is an MRI common symbol. */
+
+void
+symbol_clear_mri_common (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return;
+ s->sy_mri_common = 0;
+}
+
+/* Return whether a symbol is an MRI common symbol. */
+
+int
+symbol_mri_common_p (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 0;
+ return s->sy_mri_common;
+}
+
+/* Mark a symbol as having been written. */
+
+void
+symbol_mark_written (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return;
+ s->written = 1;
+}
+
+/* Clear the mark of whether a symbol has been written. */
+
+void
+symbol_clear_written (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return;
+ s->written = 0;
+}
+
+/* Return whether a symbol has been written. */
+
+int
+symbol_written_p (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 0;
+ return s->written;
+}
+
+/* Mark a symbol has having been resolved. */
+
+void
+symbol_mark_resolved (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ {
+ local_symbol_mark_resolved ((struct local_symbol *) s);
+ return;
+ }
+ s->sy_resolved = 1;
+}
+
+/* Return whether a symbol has been resolved. */
+
+int
+symbol_resolved_p (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return local_symbol_resolved_p ((struct local_symbol *) s);
+ return s->sy_resolved;
+}
+
+/* Return whether a symbol is a section symbol. */
+
+int
+symbol_section_p (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 0;
+#ifdef BFD_ASSEMBLER
+ return (s->bsym->flags & BSF_SECTION_SYM) != 0;
+#else
+ /* FIXME */
+ return 0;
+#endif
+}
+
+/* Return whether a symbol is equated to another symbol. */
+
+int
+symbol_equated_p (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 0;
+ return s->sy_value.X_op == O_symbol;
+}
+
+/* Return whether a symbol has a constant value. */
+
+int
+symbol_constant_p (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ return 1;
+ return s->sy_value.X_op == O_constant;
+}
+
+#ifdef BFD_ASSEMBLER
+
+/* Return the BFD symbol for a symbol. */
+
+asymbol *
+symbol_get_bfdsym (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
+ return s->bsym;
+}
+
+/* Set the BFD symbol for a symbol. */
+
+void
+symbol_set_bfdsym (s, bsym)
+ symbolS *s;
+ asymbol *bsym;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
+ s->bsym = bsym;
+}
+
+#endif /* BFD_ASSEMBLER */
+
+#ifdef OBJ_SYMFIELD_TYPE
+
+/* Get a pointer to the object format information for a symbol. */
+
+OBJ_SYMFIELD_TYPE *
+symbol_get_obj (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
+ return &s->sy_obj;
+}
+
+/* Set the object format information for a symbol. */
+
+void
+symbol_set_obj (s, o)
+ symbolS *s;
+ OBJ_SYMFIELD_TYPE *o;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
+ s->sy_obj = *o;
+}
+
+#endif /* OBJ_SYMFIELD_TYPE */
+
+#ifdef TC_SYMFIELD_TYPE
+
+/* Get a pointer to the processor information for a symbol. */
+
+TC_SYMFIELD_TYPE *
+symbol_get_tc (s)
+ symbolS *s;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
+ return &s->sy_tc;
+}
+
+/* Set the processor information for a symbol. */
+
+void
+symbol_set_obj (s, o)
+ symbolS *s;
+ TC_SYMFIELD_TYPE *o;
+{
+ if (LOCAL_SYMBOL_CHECK (s))
+ s = local_symbol_convert ((struct local_symbol *) s);
+ s->sy_tc = *o;
+}
+
+#endif /* TC_SYMFIELD_TYPE */
+
void
symbol_begin ()
{
symbol_lastP = NULL;
symbol_rootP = NULL; /* In case we have 0 symbols (!!) */
sy_hash = hash_new ();
+#ifdef BFD_ASSEMBLER
+ local_hash = hash_new ();
+#endif
memset ((char *) (&abs_symbol), '\0', sizeof (abs_symbol));
#ifdef BFD_ASSEMBLER
fb_label_init ();
}
+
\f
int indent_level;
if (!name || !name[0])
name = "(unnamed)";
fprintf (file, "sym %lx %s", (unsigned long) sym, name);
- if (sym->sy_frag != &zero_address_frag)
- fprintf (file, " frag %lx", (long) sym->sy_frag);
- if (sym->written)
- fprintf (file, " written");
- if (sym->sy_resolved)
- fprintf (file, " resolved");
- else if (sym->sy_resolving)
- fprintf (file, " resolving");
- if (sym->sy_used_in_reloc)
- fprintf (file, " used-in-reloc");
- if (sym->sy_used)
- fprintf (file, " used");
- if (S_IS_LOCAL (sym))
- fprintf (file, " local");
- if (S_IS_EXTERN (sym))
- fprintf (file, " extern");
- if (S_IS_DEBUG (sym))
- fprintf (file, " debug");
- if (S_IS_DEFINED (sym))
- fprintf (file, " defined");
+
+ if (LOCAL_SYMBOL_CHECK (sym))
+ {
+ struct local_symbol *locsym = (struct local_symbol *) sym;
+ if (local_symbol_get_frag (locsym) != &zero_address_frag
+ && local_symbol_get_frag (locsym) != NULL)
+ fprintf (file, " frag %lx", (long) local_symbol_get_frag (locsym));
+ if (local_symbol_resolved_p (locsym))
+ fprintf (file, " resolved");
+ fprintf (file, " local");
+ }
+ else
+ {
+ if (sym->sy_frag != &zero_address_frag)
+ fprintf (file, " frag %lx", (long) sym->sy_frag);
+ if (sym->written)
+ fprintf (file, " written");
+ if (sym->sy_resolved)
+ fprintf (file, " resolved");
+ else if (sym->sy_resolving)
+ fprintf (file, " resolving");
+ if (sym->sy_used_in_reloc)
+ fprintf (file, " used-in-reloc");
+ if (sym->sy_used)
+ fprintf (file, " used");
+ if (S_IS_LOCAL (sym))
+ fprintf (file, " local");
+ if (S_IS_EXTERN (sym))
+ fprintf (file, " extern");
+ if (S_IS_DEBUG (sym))
+ fprintf (file, " debug");
+ if (S_IS_DEFINED (sym))
+ fprintf (file, " defined");
+ }
fprintf (file, " %s", segment_name (S_GET_SEGMENT (sym)));
- if (sym->sy_resolved)
+ if (symbol_resolved_p (sym))
{
segT s = S_GET_SEGMENT (sym);
{
indent_level++;
fprintf (file, "\n%*s<", indent_level * 4, "");
- print_expr_1 (file, &sym->sy_value);
+ if (LOCAL_SYMBOL_CHECK (sym))
+ fprintf (file, "constant %lx",
+ (long) ((struct local_symbol *) sym)->lsy_offset);
+ else
+ print_expr_1 (file, &sym->sy_value);
fprintf (file, ">");
indent_level--;
}
FILE *file;
{
hash_print_statistics (file, "symbol table", sy_hash);
+#ifdef BFD_ASSEMBLER
+ hash_print_statistics (file, "mini local symbol table", local_hash);
+ fprintf (file, "%lu mini local symbols created, %lu converted\n",
+ local_symbol_count, local_symbol_conversion_count);
+#endif
}
/* end of symbols.c */
/* symbols.h -
- Copyright (C) 1987, 90, 92, 93, 94, 95, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1987, 90, 92, 93, 94, 95, 97, 1999
+ Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
+#ifdef BFD_ASSEMBLER
+/* The BFD code wants to walk the list in both directions. */
+#undef SYMBOLS_NEED_BACKPOINTERS
+#define SYMBOLS_NEED_BACKPOINTERS
+#endif
+
+#ifndef BFD_ASSEMBLER
+/* The non-BFD code expects to be able to manipulate the symbol fields
+ directly. */
+#include "struc-symbol.h"
+#endif
+
extern struct obstack notes; /* eg FixS live here. */
extern struct obstack cond_obstack; /* this is where we track .ifdef/.endif
void symbol_print_statistics PARAMS ((FILE *));
void symbol_table_insert PARAMS ((symbolS * symbolP));
valueT resolve_symbol_value PARAMS ((symbolS *, int));
+void resolve_local_symbol_values PARAMS ((void));
void print_symbol_value PARAMS ((symbolS *));
void print_expr PARAMS ((expressionS *));
extern void S_SET_WEAK PARAMS ((symbolS *));
#endif
+#ifndef WORKING_DOT_WORD
+struct broken_word
+ {
+ /* Linked list -- one of these structures per ".word x-y+C"
+ expression. */
+ struct broken_word *next_broken_word;
+ /* Segment and subsegment for broken word. */
+ segT seg;
+ subsegT subseg;
+ /* Which frag is this broken word in? */
+ fragS *frag;
+ /* Where in the frag is it? */
+ char *word_goes_here;
+ /* Where to add the break. */
+ fragS *dispfrag; /* where to add the break */
+ /* Operands of expression. */
+ symbolS *add;
+ symbolS *sub;
+ offsetT addnum;
+
+ int added; /* nasty thing happend yet? */
+ /* 1: added and has a long-jump */
+ /* 2: added but uses someone elses long-jump */
+
+ /* Pointer to broken_word with a similar long-jump. */
+ struct broken_word *use_jump;
+ };
+extern struct broken_word *broken_words;
+#endif /* ndef WORKING_DOT_WORD */
+
+/*
+ * Current means for getting from symbols to segments and vice verse.
+ * This will change for infinite-segments support (e.g. COFF).
+ */
+extern const segT N_TYPE_seg[]; /* subseg.c */
+
+#define SEGMENT_TO_SYMBOL_TYPE(seg) ( seg_N_TYPE [(int) (seg)] )
+extern const short seg_N_TYPE[];/* subseg.c */
+
+#define N_REGISTER 30 /* Fake N_TYPE value for SEG_REGISTER */
+
+void symbol_clear_list_pointers PARAMS ((symbolS * symbolP));
+
+#ifdef SYMBOLS_NEED_BACKPOINTERS
+
+void symbol_insert PARAMS ((symbolS * addme, symbolS * target,
+ symbolS ** rootP, symbolS ** lastP));
+void symbol_remove PARAMS ((symbolS * symbolP, symbolS ** rootP,
+ symbolS ** lastP));
+
+extern symbolS *symbol_previous PARAMS ((symbolS *));
+
+#endif /* SYMBOLS_NEED_BACKPOINTERS */
+
+void verify_symbol_chain PARAMS ((symbolS * rootP, symbolS * lastP));
+void verify_symbol_chain_2 PARAMS ((symbolS * symP));
+
+void symbol_append PARAMS ((symbolS * addme, symbolS * target,
+ symbolS ** rootP, symbolS ** lastP));
+
+extern symbolS *symbol_next PARAMS ((symbolS *));
+
+extern expressionS *symbol_get_value_expression PARAMS ((symbolS *));
+extern void symbol_set_value_expression PARAMS ((symbolS *,
+ const expressionS *));
+extern void symbol_set_frag PARAMS ((symbolS *, fragS *));
+extern fragS *symbol_get_frag PARAMS ((symbolS *));
+extern void symbol_mark_used PARAMS ((symbolS *));
+extern void symbol_clear_used PARAMS ((symbolS *));
+extern int symbol_used_p PARAMS ((symbolS *));
+extern void symbol_mark_used_in_reloc PARAMS ((symbolS *));
+extern void symbol_clear_used_in_reloc PARAMS ((symbolS *));
+extern int symbol_used_in_reloc_p PARAMS ((symbolS *));
+extern void symbol_mark_mri_common PARAMS ((symbolS *));
+extern void symbol_clear_mri_common PARAMS ((symbolS *));
+extern int symbol_mri_common_p PARAMS ((symbolS *));
+extern void symbol_mark_written PARAMS ((symbolS *));
+extern void symbol_clear_written PARAMS ((symbolS *));
+extern int symbol_written_p PARAMS ((symbolS *));
+extern void symbol_mark_resolved PARAMS ((symbolS *));
+extern int symbol_resolved_p PARAMS ((symbolS *));
+extern int symbol_section_p PARAMS ((symbolS *));
+extern int symbol_equated_p PARAMS ((symbolS *));
+extern int symbol_constant_p PARAMS ((symbolS *));
+
+#ifdef BFD_ASSEMBLER
+extern asymbol *symbol_get_bfdsym PARAMS ((symbolS *));
+extern void symbol_set_bfdsym PARAMS ((symbolS *, asymbol *));
+#endif
+
+#ifdef OBJ_SYMFIELD_TYPE
+OBJ_SYMFIELD_TYPE *symbol_get_obj PARAMS ((symbolS *));
+void symbol_set_obj PARAMS ((symbolS *, OBJ_SYMFIELD_TYPE *));
+#endif
+
+#ifdef TC_SYMFIELD_TYPE
+TC_SYMFIELD_TYPE *symbol_get_tc PARAMS ((symbolS *));
+void symbol_set_tc PARAMS ((symbolS *, TC_SYMFIELD_TYPE *));
+#endif
+
/* end of symbols.h */
/* write.c - emit .o file
- Copyright (C) 1986, 87, 90, 91, 92, 93, 94, 95, 96, 97, 1998
+ Copyright (C) 1986, 87, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
point. It is possible to see unresolved expression
symbols, though, since they are not in the regular symbol
table. */
- if (sym != NULL && ! sym->sy_resolved)
+ if (sym != NULL)
resolve_symbol_value (sym, 1);
- if (fixp->fx_subsy != NULL && ! fixp->fx_subsy->sy_resolved)
+ if (fixp->fx_subsy != NULL)
resolve_symbol_value (fixp->fx_subsy, 1);
/* If this symbol is equated to an undefined symbol, convert
the fixup to being against that symbol. */
- if (sym != NULL && sym->sy_value.X_op == O_symbol
+ if (sym != NULL && symbol_equated_p (sym)
&& (! S_IS_DEFINED (sym) || S_IS_COMMON (sym)))
{
- fixp->fx_offset += sym->sy_value.X_add_number;
- sym = sym->sy_value.X_add_symbol;
+ fixp->fx_offset += symbol_get_value_expression (sym)->X_add_number;
+ sym = symbol_get_value_expression (sym)->X_add_symbol;
fixp->fx_addsy = sym;
}
- if (sym != NULL && sym->sy_mri_common)
+ if (sym != NULL && symbol_mri_common_p (sym))
{
/* These symbols are handled specially in fixup_segment. */
goto done;
relocation unless TC_FORCE_RELOCATION returns 1. */
if (TC_FORCE_RELOCATION (fixp))
{
- fixp->fx_addsy->sy_used_in_reloc = 1;
+ symbol_mark_used_in_reloc (fixp->fx_addsy);
#ifdef UNDEFINED_DIFFERENCE_OK
if (fixp->fx_subsy != NULL)
- fixp->fx_subsy->sy_used_in_reloc = 1;
+ symbol_mark_used_in_reloc (fixp->fx_subsy);
#endif
}
goto done;
if (bfd_is_und_section (symsec)
|| bfd_is_com_section (symsec))
{
- fixp->fx_addsy->sy_used_in_reloc = 1;
+ symbol_mark_used_in_reloc (fixp->fx_addsy);
#ifdef UNDEFINED_DIFFERENCE_OK
/* We have the difference of an undefined symbol and some
other symbol. Make sure to mark the other symbol as used
in a relocation so that it will always be output. */
if (fixp->fx_subsy)
- fixp->fx_subsy->sy_used_in_reloc = 1;
+ symbol_mark_used_in_reloc (fixp->fx_subsy);
#endif
goto done;
}
if (linkonce)
{
- fixp->fx_addsy->sy_used_in_reloc = 1;
+ symbol_mark_used_in_reloc (fixp->fx_addsy);
#ifdef UNDEFINED_DIFFERENCE_OK
if (fixp->fx_subsy != NULL)
- fixp->fx_subsy->sy_used_in_reloc = 1;
+ symbol_mark_used_in_reloc (fixp->fx_subsy);
#endif
goto done;
}
/* Since we're reducing to section symbols, don't attempt to reduce
anything that's already using one. */
- if (sym->bsym->flags & BSF_SECTION_SYM)
+ if (symbol_section_p (sym))
{
- fixp->fx_addsy->sy_used_in_reloc = 1;
+ symbol_mark_used_in_reloc (fixp->fx_addsy);
goto done;
}
the wrong area of memory. */
if (S_IS_WEAK (sym))
{
- fixp->fx_addsy->sy_used_in_reloc = 1;
+ symbol_mark_used_in_reloc (fixp->fx_addsy);
goto done;
}
#endif
#ifdef obj_fix_adjustable
if (! obj_fix_adjustable (fixp))
{
- fixp->fx_addsy->sy_used_in_reloc = 1;
+ symbol_mark_used_in_reloc (fixp->fx_addsy);
goto done;
}
#endif
#ifdef tc_fix_adjustable
if (! tc_fix_adjustable (fixp))
{
- fixp->fx_addsy->sy_used_in_reloc = 1;
+ symbol_mark_used_in_reloc (fixp->fx_addsy);
goto done;
}
#endif
the section when it calls resolve_symbol_value. */
fixp->fx_offset += S_GET_VALUE (sym);
fixp->fx_addsy = section_symbol (S_GET_SEGMENT (sym));
- fixp->fx_addsy->sy_used_in_reloc = 1;
+ symbol_mark_used_in_reloc (fixp->fx_addsy);
done:
;
symbol, then use generate the reloc against the latter symbol
rather than the former. */
sym = fixp->fx_addsy;
- while (sym->sy_value.X_op == O_symbol
+ while (symbol_equated_p (sym)
&& (! S_IS_DEFINED (sym) || S_IS_COMMON (sym)))
{
symbolS *n;
/* We must avoid looping, as that can occur with a badly
written program. */
- n = sym->sy_value.X_add_symbol;
+ n = symbol_get_value_expression (sym)->X_add_symbol;
if (n == sym)
break;
- fixp->fx_offset += sym->sy_value.X_add_number;
+ fixp->fx_offset += symbol_get_value_expression (sym)->X_add_number;
sym = n;
}
fixp->fx_addsy = sym;
symbol, then use generate the reloc against the latter symbol
rather than the former. */
sym = fixp->fx_addsy;
- while (sym->sy_value.X_op == O_symbol
+ while (symbol_equated_p (sym)
&& (! S_IS_DEFINED (sym) || S_IS_COMMON (sym)))
- sym = sym->sy_value.X_add_symbol;
+ sym = symbol_get_value_expression (sym)->X_add_symbol;
fixp->fx_addsy = sym;
reloc = tc_gen_reloc (sec, fixp);
symp = symbol_rootP;
for (i = 0; i < nsyms; i++, symp = symbol_next (symp))
{
- asympp[i] = symp->bsym;
- symp->written = 1;
+ asympp[i] = symbol_get_bfdsym (symp);
+ symbol_mark_written (symp);
}
}
else
/* This is the offset from ??? to table_ptr+0 */
to_addr = table_addr - S_GET_VALUE (lie->sub);
#ifdef BFD_ASSEMBLER
- to_addr -= lie->sub->sy_frag->fr_address;
+ to_addr -= symbol_get_frag (lie->sub)->fr_address;
#endif
md_number_to_chars (lie->word_goes_here, to_addr, 2);
for (untruth = lie->next_broken_word; untruth && untruth->dispfrag == fragP; untruth = untruth->next_broken_word)
from_addr = table_addr;
to_addr = S_GET_VALUE (lie->add) + lie->addnum;
#ifdef BFD_ASSEMBLER
- to_addr += lie->add->sy_frag->fr_address;
+ to_addr += symbol_get_frag (lie->add)->fr_address;
#endif
md_create_long_jump (table_ptr, from_addr, to_addr, lie->dispfrag, lie->add);
table_ptr += md_long_jump_size;
symbolS *symp;
for (symp = symbol_rootP; symp; symp = symbol_next (symp))
- if (!symp->sy_resolved)
- resolve_symbol_value (symp, 1);
+ resolve_symbol_value (symp, 1);
}
+ resolve_local_symbol_values ();
PROGRESS (1);
int punt = 0;
const char *name;
- if (symp->sy_mri_common)
+ if (symbol_mri_common_p (symp))
{
if (S_IS_EXTERNAL (symp))
as_bad (_("%s: global symbols not supported in common sections"),
/* 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. */
- if (! symp->sy_resolved)
- {
- if (symp->sy_value.X_op == O_constant)
- {
- /* This is the normal case; skip the call. */
- S_SET_VALUE (symp,
- (S_GET_VALUE (symp)
- + symp->sy_frag->fr_address));
- symp->sy_resolved = 1;
- }
- else
- resolve_symbol_value (symp, 1);
- }
+ resolve_symbol_value (symp, 1);
/* Skip symbols which were equated to undefined or common
symbols. */
- if (symp->sy_value.X_op == O_symbol
+ if (symbol_equated_p (symp)
&& (! S_IS_DEFINED (symp) || S_IS_COMMON (symp)))
{
symbol_remove (symp, &symbol_rootP, &symbol_lastP);
printf ("symbol `%s'\n\t@%x: value=%d flags=%x seg=%s\n",
S_GET_NAME (symp), symp,
S_GET_VALUE (symp),
- symp->bsym->flags,
- segment_name (symp->bsym->section));
+ symbol_get_bfdsym (symp)->flags,
+ segment_name (S_GET_SEGMENT (symp)));
#endif
#ifdef obj_frob_symbol
obj_frob_symbol (symp, punt);
#endif
#ifdef tc_frob_symbol
- if (! punt || symp->sy_used_in_reloc)
+ if (! punt || symbol_used_in_reloc_p (symp))
tc_frob_symbol (symp, punt);
#endif
and symbols that the frob_symbol macros told us to punt,
but we keep such symbols if they are used in relocs. */
if ((! EMIT_SECTION_SYMBOLS
- && (symp->bsym->flags & BSF_SECTION_SYM) != 0)
+ && symbol_section_p (symp))
/* Note that S_IS_EXTERN and S_IS_LOCAL are not always
opposites. Sometimes the former checks flags and the
latter examines the name... */
|| (!S_IS_EXTERN (symp)
&& (S_IS_LOCAL (symp) || punt)
- && ! symp->sy_used_in_reloc))
+ && ! symbol_used_in_reloc_p (symp)))
{
symbol_remove (symp, &symbol_rootP, &symbol_lastP);
/* After symbol_remove, symbol_next(symp) still returns
}
/* Make sure we really got a value for the symbol. */
- if (! symp->sy_resolved)
+ if (! symbol_resolved_p (symp))
{
as_bad (_("can't resolve value for symbol \"%s\""),
S_GET_NAME (symp));
- symp->sy_resolved = 1;
+ symbol_mark_resolved (symp);
}
/* Set the value into the BFD symbol. Up til now the value
has only been kept in the gas symbolS struct. */
- symp->bsym->value = S_GET_VALUE (symp);
+ symbol_get_bfdsym (symp)->value = S_GET_VALUE (symp);
}
}
#endif
know (!(S_GET_SEGMENT (symbolP) == absolute_section)
|| symbolP->sy_frag == &zero_address_frag);
- target +=
- S_GET_VALUE (symbolP)
- + symbolP->sy_frag->fr_address;
+ target += S_GET_VALUE (symbolP) + symbol_get_frag (symbolP)->fr_address;
/* If frag has yet to be reached on this pass,
assume it will move by STRETCH just as we did.
There should be a faster way to do this. */
- if (symbolP->sy_frag->fr_address >= was_address
- && is_dnrange (fragP, symbolP->sy_frag))
+ if (symbol_get_frag (symbolP)->fr_address >= was_address
+ && is_dnrange (fragP, symbol_get_frag (symbolP)))
{
target += stretch;
}
if (lie->added)
continue;
- offset = (lie->add->sy_frag->fr_address
+ offset = (symbol_get_frag (lie->add)->fr_address
+ S_GET_VALUE (lie->add)
+ lie->addnum
- - (lie->sub->sy_frag->fr_address
+ - (symbol_get_frag (lie->sub)->fr_address
+ S_GET_VALUE (lie->sub)));
if (offset <= -32768 || offset >= 32767)
{
for (untruth = lie->next_broken_word;
untruth && untruth->dispfrag == lie->dispfrag;
untruth = untruth->next_broken_word)
- if ((untruth->add->sy_frag == lie->add->sy_frag)
- && S_GET_VALUE (untruth->add) == S_GET_VALUE (lie->add))
+ if ((symbol_get_frag (untruth->add)
+ == symbol_get_frag (lie->add))
+ && (S_GET_VALUE (untruth->add)
+ == S_GET_VALUE (lie->add)))
{
untruth->added = 2;
untruth->use_jump = lie;
know (!(S_GET_SEGMENT (symbolP) == SEG_ABSOLUTE)
|| (symbolP->sy_frag == &zero_address_frag));
#endif
- target += S_GET_VALUE (symbolP)
- + symbolP->sy_frag->fr_address;
+ target += (S_GET_VALUE (symbolP)
+ + symbol_get_frag (symbolP)->fr_address);
} /* if we have a symbol */
know (fragP->fr_next);
if (symbolP)
{
growth = S_GET_VALUE (symbolP);
- if (symbolP->sy_frag != &zero_address_frag
+ if (symbol_get_frag (symbolP) != &zero_address_frag
|| S_IS_COMMON (symbolP)
|| ! S_IS_DEFINED (symbolP))
as_bad_where (fragP->fr_file, fragP->fr_line,
plt = fixP->fx_plt;
if (add_symbolP != NULL
- && add_symbolP->sy_mri_common)
+ && symbol_mri_common_p (add_symbolP))
{
know (add_symbolP->sy_value.X_op == O_symbol);
add_number += S_GET_VALUE (add_symbolP);
fixP->fx_offset = add_number;
- add_symbolP = fixP->fx_addsy = add_symbolP->sy_value.X_add_symbol;
+ add_symbolP = fixP->fx_addsy =
+ symbol_get_value_expression (add_symbolP)->X_add_symbol;
}
if (add_symbolP)
#else
fixP->fx_addsy = section_symbol (absolute_section);
#endif
- fixP->fx_addsy->sy_used_in_reloc = 1;
+ symbol_mark_used_in_reloc (fixP->fx_addsy);
++seg_reloc_count;
}
}