diff options
author | Ian Lance Taylor <ian@airs.com> | 1999-06-03 00:29:48 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1999-06-03 00:29:48 +0000 |
commit | 49309057b4c45a2586735182830793c77633f51d (patch) | |
tree | 1aaca2ad34e77400fd91047b31afce59afa71426 /gas | |
parent | 2b47531bf9ef778773831ecb1b43186e95ffe8d7 (diff) | |
download | fsf-binutils-gdb-49309057b4c45a2586735182830793c77633f51d.zip fsf-binutils-gdb-49309057b4c45a2586735182830793c77633f51d.tar.gz fsf-binutils-gdb-49309057b4c45a2586735182830793c77633f51d.tar.bz2 |
Add support for storing local symbols in a small structure to save
memory when assembling large files.
* as.h: Don't include struc-symbol.h.
(symbolS): Add typedef.
* symbols.c: Include struc-symbol.h.
(local_hash): New static variable.
(save_symbol_name): New static function, from symbol_create.
(symbol_create): Call save_symbol_name.
(local_symbol_count): New static variable.
(local_symbol_conversion_count): Likewise.
(LOCAL_SYMBOL_CHECK): Define.
(local_symbol_make): New static function.
(local_symbol_convert): New static function.
(colon): Handle local symbols. Create local symbol for local
label name.
(symbol_table_insert): Handle local symbols.
(symbol_find_or_make): Create local symbol for local label name.
(symbol_find_base): Check for local symbol.
(symbol_append, symbol_insert): Check for local symbols.
(symbol_clear_list_pointers, symbol_remove): Likewise.
(verify_symbol_chain): Likewise.
(copy_symbol_attributes): Likewise.
(resolve_symbol_value): Handle local symbols.
(resolve_local_symbol): New static function.
(resolve_local_symbol_values): New function.
(S_GET_VALUE, S_SET_VALUE): Handle local symbols.
(S_IS_FUNCTION, S_IS_EXTERNAL, S_IS_WEAK, S_IS_COMMON): Likewise.
(S_IS_DEFINED, S_IS_DEBUG, S_IS_LOCAL, S_GET_NAME): Likewise.
(S_GET_SEGMENT, S_SET_SEGMENT, S_SET_EXTERNAL): Likewise.
(S_CLEAR_EXTERNAL, S_SET_WEAK, S_SET_NAME): Likewise.
(symbol_previous, symbol_next): New functions.
(symbol_get_value_expression): Likewise.
(symbol_set_value_expression): Likewise.
(symbol_set_frag, symbol_get_frag): Likewise.
(symbol_mark_used, symbol_clear_used, symbol_used_p): Likewise.
(symbol_mark_used_in_reloc): Likewise.
(symbol_clear_used_in_reloc, symbol_used_in_reloc_p): Likewise.
(symbol_mark_mri_common, symbol_clear_mri_common): Likewise.
(symbol_mri_common_p): Likewise.
(symbol_mark_written, symbol_clear_written): Likewise.
(symbol_written_p): Likewise.
(symbol_mark_resolved, symbol_resolved_p): Likewise.
(symbol_section_p, symbol_equated_p): Likewise.
(symbol_constant_p): Likewise.
(symbol_get_bfdsym, symbol_set_bfdsym): Likewise.
(symbol_get_obj, symbol_set_obj): Likewise.
(symbol_get_tc, symbol_set_tc): Likewise.
(symbol_begin): Initialize local_hash.
(print_symbol_value_1): Handle local symbols.
(symbol_print_statistics): Print local symbol statistics.
* symbols.h: Include "struc-symbol.h" if not BFD_ASSEMBLER.
Declare new symbols.c functions. Move many declarations here from
struc-symbol.h.
(SYMBOLS_NEED_BACKPOINTERS): Define if needed.
* struc-symbol.h (SYMBOLS_NEED_BACKPOINTERS): Don't set.
(struct symbol): Move bsym to make it clearly the first field.
Remove TARGET_SYMBOL_FIELDS.
(symbolS): Don't typedef.
(struct broken_word): Remove.
(N_TYPE_seg, seg_N_TYPE): Move to symbol.h.
(SEGMENT_TO_SYMBOL_TYPE, N_REGISTER): Likewise.
(symbol_clear_list_pointers): Likewise.
(symbol_insert, symbol_remove): Likewise.
(symbol_previous, symbol_append): Likewise.
(verify_symbol_chain, verify_symbol_chain_2): Likewise.
(struct local_symbol): Define.
(local_symbol_converted_p, local_symbol_mark_converted): Define.
(local_symbol_resolved_p, local_symbol_mark_resolved): Define.
(local_symbol_get_frag, local_symbol_set_frag): Define.
(local_symbol_get_real_symbol): Define.
(local_symbol_set_real_symbol): Define.
Define.
* write.c (write_object_file): Call resolve_local_symbol_values.
* config/obj-ecoff.h (OBJ_SYMFIELD_TYPE): Define.
(TARGET_SYMBOL_FIELDS): Don't define.
* config/obj-elf.h (OBJ_SYMFIELD_TYPE): Add local field. If
ECOFF_DEBUGGING, add ECOFF fields.
(ELF_TARGET_SYMBOL_FIELDS, TARGET_SYMBOL_FIELDS): Don't define.
* config/obj-multi.h (struct elf_obj_sy): Add local field. If
ECOFF_DEBUGGING, add ECOFF fields.
(ELF_TARGET_SYMBOL_FIELDS, TARGET_SYMBOL_FIELDS): Don't define.
(ECOFF_DEBUG_TARGET_SYMBOL_FIELDS): Don't define.
* config/tc-mcore.h: Don't include struc-symbol.h.
(TARGET_SYMBOL_FIELDS): Don't define.
(struct mcore_tc_sy): Define.
(TC_SYMFIELD_TYPE): Define.
* Many files: Use symbolS instead of struct symbol. Use new
accessor functions rather than referring to symbolS fields
directly.
* read.c (s_mri_common): Don't add in value of line_label.
* config/tc-mips.c (md_apply_fix): Correct parenthesization when
checking for SEC_LINK_ONCE.
* config/tc-sh.h (sh_fix_adjustable): Declare.
Diffstat (limited to 'gas')
50 files changed, 1536 insertions, 589 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index f698fd0..4cf898a 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,120 @@ +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 @@ -1,5 +1,5 @@ /* 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. @@ -64,7 +64,7 @@ s_ifdef (arg) 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. */ diff --git a/gas/config/obj-aout.c b/gas/config/obj-aout.c index b519347..5465ef4 100644 --- a/gas/config/obj-aout.c +++ b/gas/config/obj-aout.c @@ -1,5 +1,5 @@ /* 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. @@ -14,9 +14,10 @@ WITHOUT ANY WARRANTY; without even the implied warranty of 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 @@ -108,18 +109,21 @@ obj_aout_frob_symbol (sym, punt) 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 @@ -141,7 +145,7 @@ obj_aout_frob_symbol (sym, punt) 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 @@ -164,29 +168,29 @@ obj_aout_frob_symbol (sym, punt) 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"), diff --git a/gas/config/obj-aout.h b/gas/config/obj-aout.h index 339070e..2cf33fd 100644 --- a/gas/config/obj-aout.h +++ b/gas/config/obj-aout.h @@ -1,5 +1,5 @@ /* 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. @@ -60,18 +60,24 @@ typedef struct nlist obj_symbol_type; /* Symbol table entry */ #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) diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c index e8e3df9..a6bdaee 100644 --- a/gas/config/obj-coff.c +++ b/gas/config/obj-coff.c @@ -1,5 +1,5 @@ /* 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. @@ -249,8 +249,8 @@ SA_SET_SYM_ENDNDX (sym, val) { 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; } @@ -262,8 +262,8 @@ SA_SET_SYM_TAGNDX (sym, val) { 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; } @@ -272,7 +272,7 @@ static int 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 @@ -280,7 +280,7 @@ S_SET_DATA_TYPE (sym, val) 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; } @@ -288,7 +288,7 @@ int 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 @@ -296,7 +296,7 @@ S_SET_STORAGE_CLASS (sym, val) 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; } @@ -339,7 +339,7 @@ c_dot_file_symbol (filename) 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 { @@ -385,7 +385,7 @@ coff_obj_symbol_new_hook (symbolP) 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); @@ -434,7 +434,8 @@ coff_add_linesym (sym) { 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; } @@ -532,7 +533,7 @@ obj_coff_def (what) /* 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)) @@ -585,7 +586,7 @@ obj_coff_endef (ignore) 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 ()) @@ -909,17 +910,19 @@ obj_coff_val (ignore) #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 @@ -1034,7 +1037,8 @@ coff_frob_symbol (symp, punt) 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)); } @@ -1055,7 +1059,7 @@ coff_frob_symbol (symp, punt) *punt = 1; if (SF_GET_FUNCTION (symp)) - symp->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (symp)->flags |= BSF_FUNCTION; /* more ... */ } @@ -1069,7 +1073,7 @@ coff_frob_symbol (symp, punt) /* 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))) @@ -1078,7 +1082,7 @@ coff_frob_symbol (symp, punt) 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))))) @@ -1100,22 +1104,22 @@ coff_frob_symbol (symp, punt) 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--) diff --git a/gas/config/obj-coff.h b/gas/config/obj-coff.h index 4650477..a8799a3 100644 --- a/gas/config/obj-coff.h +++ b/gas/config/obj-coff.h @@ -154,7 +154,7 @@ #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)); @@ -211,32 +211,35 @@ 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 */ @@ -298,9 +301,9 @@ extern void SA_SET_SYM_ENDNDX PARAMS ((struct symbol *, struct symbol *)); /* 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) @@ -346,13 +349,13 @@ extern int coff_line_base; 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)); @@ -364,7 +367,7 @@ extern void coff_frob_file_after_relocs PARAMS ((void)); #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. */ @@ -778,7 +781,7 @@ extern void c_dot_file_symbol PARAMS ((char *filename)); #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, @@ -792,7 +795,7 @@ extern void c_section_header PARAMS ((struct internal_scnhdr * header, 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 */ diff --git a/gas/config/obj-ecoff.h b/gas/config/obj-ecoff.h index 427e619..8bca254 100644 --- a/gas/config/obj-ecoff.h +++ b/gas/config/obj-ecoff.h @@ -36,10 +36,14 @@ 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) @@ -64,4 +68,4 @@ extern void ecoff_frob_file PARAMS ((void)); #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 *)); diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index 4ff8950..24f0926 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -1,5 +1,6 @@ /* 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. @@ -235,8 +236,8 @@ elf_file_symbol (s) 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) { @@ -322,7 +323,7 @@ obj_elf_common (ignore) as_warn (_("Common alignment negative; 0 assumed")); } } - if (symbolP->local) + if (symbol_get_obj (symbolP)->local) { segT old_sec; int old_subsec; @@ -350,8 +351,8 @@ obj_elf_common (ignore) 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; @@ -389,7 +390,7 @@ obj_elf_common (ignore) goto allocate_common; } - symbolP->bsym->flags |= BSF_OBJECT; + symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT; demand_empty_rest_of_line (); return; @@ -425,7 +426,7 @@ obj_elf_local (ignore) *input_line_pointer = c; SKIP_WHITESPACE (); S_CLEAR_EXTERNAL (symbolP); - symbolP->local = 1; + symbol_get_obj (symbolP)->local = 1; if (c == ',') { input_line_pointer++; @@ -454,7 +455,7 @@ obj_elf_weak (ignore) *input_line_pointer = c; SKIP_WHITESPACE (); S_SET_WEAK (symbolP); - symbolP->local = 1; + symbol_get_obj (symbolP)->local = 1; if (c == ',') { input_line_pointer++; @@ -815,7 +816,7 @@ obj_elf_section (xxx) /* 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)); @@ -949,7 +950,7 @@ obj_elf_symver (ignore) *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)); @@ -975,14 +976,14 @@ obj_elf_symver (ignore) *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; } @@ -1012,7 +1013,7 @@ obj_elf_vtable_inherit (ignore) 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); @@ -1055,8 +1056,9 @@ obj_elf_vtable_inherit (ignore) 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); } @@ -1113,8 +1115,11 @@ void 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) @@ -1225,8 +1230,9 @@ obj_elf_size (ignore) 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 (); } @@ -1284,7 +1290,7 @@ obj_elf_type (ignore) *input_line_pointer = c; - sym->bsym->flags |= type; + symbol_get_bfdsym (sym)->flags |= type; demand_empty_rest_of_line (); } @@ -1393,7 +1399,7 @@ elf_ecoff_set_ext (sym, ext) 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 @@ -1429,35 +1435,39 @@ elf_frob_symbol (symp, puntp) 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. @@ -1477,15 +1487,15 @@ elf_frob_symbol (symp, puntp) /* 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 { @@ -1497,7 +1507,7 @@ elf_frob_symbol (symp, puntp) 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. */ @@ -1505,9 +1515,11 @@ elf_frob_symbol (symp, puntp) /* 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); @@ -1521,7 +1533,7 @@ elf_frob_symbol (symp, puntp) } /* 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"), @@ -1537,19 +1549,21 @@ elf_frob_symbol (symp, puntp) .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 } diff --git a/gas/config/obj-elf.h b/gas/config/obj-elf.h index 2f4bc5f..4380f1f 100644 --- a/gas/config/obj-elf.h +++ b/gas/config/obj-elf.h @@ -1,5 +1,6 @@ /* 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. @@ -34,6 +35,22 @@ #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 @@ -41,25 +58,28 @@ #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 @@ -71,17 +91,20 @@ extern void elf_begin PARAMS ((void)); /* 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; @@ -110,18 +133,20 @@ extern void obj_elf_version PARAMS ((int)); #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)); \ @@ -136,30 +161,7 @@ while (0) 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. */ @@ -175,7 +177,7 @@ extern int alpha_flag_mdebug; 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 @@ -188,7 +190,7 @@ extern void elf_pop_insert PARAMS ((void)); #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 */ diff --git a/gas/config/obj-multi.h b/gas/config/obj-multi.h index fe8d98d..d54c61f 100644 --- a/gas/config/obj-multi.h +++ b/gas/config/obj-multi.h @@ -25,26 +25,20 @@ /* 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 diff --git a/gas/config/obj-vms.h b/gas/config/obj-vms.h index ac0c1fb..ad8fdce 100644 --- a/gas/config/obj-vms.h +++ b/gas/config/obj-vms.h @@ -1,5 +1,5 @@ /* 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. @@ -214,18 +214,17 @@ typedef struct nlist obj_symbol_type; /* Symbol table entry */ /* 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)); diff --git a/gas/config/tc-alpha.c b/gas/config/tc-alpha.c index 568617f..a166309 100644 --- a/gas/config/tc-alpha.c +++ b/gas/config/tc-alpha.c @@ -1173,7 +1173,7 @@ md_apply_fix (fixP, valueP) 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")); @@ -1393,7 +1393,8 @@ tc_gen_reloc (sec, fixp) 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. @@ -1435,7 +1436,7 @@ tc_gen_reloc (sec, fixp) */ 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 } @@ -3557,7 +3558,7 @@ s_alpha_ent (dummy) 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 @@ -3604,12 +3605,13 @@ s_alpha_end (dummy) /* 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; @@ -4745,7 +4747,7 @@ alpha_align (n, pfill, label, force) 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 ()); } diff --git a/gas/config/tc-alpha.h b/gas/config/tc-alpha.h index ca6903a..a350513 100644 --- a/gas/config/tc-alpha.h +++ b/gas/config/tc-alpha.h @@ -85,7 +85,7 @@ extern int tc_get_register PARAMS ((int frame)); 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)); diff --git a/gas/config/tc-arc.h b/gas/config/tc-arc.h index 6a95ff4..5066201 100644 --- a/gas/config/tc-arc.h +++ b/gas/config/tc-arc.h @@ -1,5 +1,5 @@ /* 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. @@ -66,6 +66,6 @@ struct arc_tc_sy #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 diff --git a/gas/config/tc-arm.h b/gas/config/tc-arm.h index bf99e24..7f676e7 100644 --- a/gas/config/tc-arm.h +++ b/gas/config/tc-arm.h @@ -1,5 +1,6 @@ /* 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) @@ -103,7 +104,7 @@ 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) diff --git a/gas/config/tc-d10v.c b/gas/config/tc-d10v.c index cf38f3e..bb8ace8 100644 --- a/gas/config/tc-d10v.c +++ b/gas/config/tc-d10v.c @@ -1,6 +1,6 @@ /* 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. @@ -159,7 +159,7 @@ register_name (expressionP) { 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; diff --git a/gas/config/tc-d30v.c b/gas/config/tc-d30v.c index c5033ba..8e93f2a 100644 --- a/gas/config/tc-d30v.c +++ b/gas/config/tc-d30v.c @@ -1,6 +1,6 @@ /* 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. @@ -216,7 +216,7 @@ register_name (expressionP) { 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; diff --git a/gas/config/tc-d30v.h b/gas/config/tc-d30v.h index acce285..dfebbb9 100644 --- a/gas/config/tc-d30v.h +++ b/gas/config/tc-d30v.h @@ -1,5 +1,5 @@ /* 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. @@ -15,8 +15,9 @@ 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 @@ -52,7 +53,7 @@ int d30v_cleanup PARAMS ((int)); #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)); diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c index c0f532c..80ac19a 100644 --- a/gas/config/tc-hppa.c +++ b/gas/config/tc-hppa.c @@ -1,5 +1,6 @@ /* 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. @@ -326,7 +327,7 @@ typedef struct space_dictionary_chain sd_chain_struct; label. */ typedef struct label_symbol_struct { - struct symbol *lss_label; + symbolS *lss_label; sd_chain_struct *lss_space; struct label_symbol_struct *lss_next; } diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index b06298e..ab5cbfb 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -2463,7 +2463,8 @@ md_assemble (line) && 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; @@ -2829,7 +2830,7 @@ i386_displacement (disp_start, disp_end) { 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; @@ -3789,7 +3790,7 @@ md_convert_frag (abfd, sec, fragP) /* 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. */ @@ -3943,7 +3944,7 @@ md_apply_fix3 (fixP, valp, seg) #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) @@ -4387,7 +4388,8 @@ tc_gen_reloc (section, fixp) 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 diff --git a/gas/config/tc-i960.c b/gas/config/tc-i960.c index a4e8497..60ae033 100644 --- a/gas/config/tc-i960.c +++ b/gas/config/tc-i960.c @@ -3353,7 +3353,8 @@ tc_gen_reloc (section, fixP) 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; diff --git a/gas/config/tc-i960.h b/gas/config/tc-i960.h index e415233..2746ede 100644 --- a/gas/config/tc-i960.h +++ b/gas/config/tc-i960.h @@ -130,7 +130,7 @@ struct relocation_info #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); \ @@ -140,7 +140,7 @@ struct relocation_info } #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 @@ -167,9 +167,9 @@ extern void brtab_emit PARAMS ((void)); 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) diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c index e1e1bc2..1aff3da 100644 --- a/gas/config/tc-m68k.c +++ b/gas/config/tc-m68k.c @@ -907,7 +907,8 @@ tc_gen_reloc (section, fixp) #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) @@ -4292,7 +4293,7 @@ md_convert_frag_1 (fragP) 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) @@ -4741,14 +4742,14 @@ md_estimate_size_before_relax (fragP, segment) 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; @@ -5472,7 +5473,7 @@ s_reg (ignore) 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); diff --git a/gas/config/tc-m68k.h b/gas/config/tc-m68k.h index f9a5ef9..b8492b9 100644 --- a/gas/config/tc-m68k.h +++ b/gas/config/tc-m68k.h @@ -1,5 +1,5 @@ /* 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. @@ -22,7 +22,6 @@ #define TC_M68K 1 #ifdef ANSI_PROTOTYPES -struct symbol; struct fix; #endif @@ -138,13 +137,13 @@ extern void m68k_mri_mode_change PARAMS ((int)); 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 diff --git a/gas/config/tc-mcore.c b/gas/config/tc-mcore.c index 4c12f99..28790df 100644 --- a/gas/config/tc-mcore.c +++ b/gas/config/tc-mcore.c @@ -541,7 +541,7 @@ dump_literals (isforce) { int i; struct literal * p; - struct symbol * brarsym; + symbolS * brarsym; if (poolsize == 0) return; diff --git a/gas/config/tc-mcore.h b/gas/config/tc-mcore.h index 9e487c9..e713c27 100644 --- a/gas/config/tc-mcore.h +++ b/gas/config/tc-mcore.h @@ -65,7 +65,12 @@ extern const struct relax_type md_relax_table[]; #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 */ @@ -93,7 +98,6 @@ extern boolean mcore_fix_adjustable PARAMS ((struct fix *)); # 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)); diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index c25f057..3c1c00c 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -1,5 +1,5 @@ /* 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 @@ -54,7 +54,6 @@ static int mips_output_flavor () { return OUTPUT_FLAVOR; } #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 @@ -1373,8 +1372,8 @@ mips16_mark_labels () 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); } } } @@ -1656,11 +1655,11 @@ append_insn (place, ip, address_expr, reloc_type, unmatched_hi) 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 @@ -2360,11 +2359,11 @@ mips_emit_delays (insns) 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); } } } @@ -4103,11 +4102,12 @@ macro (ip) 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) @@ -8699,10 +8699,10 @@ my_getExpression (ep, str) && 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 @@ -9472,13 +9472,13 @@ md_apply_fix (fixP, valueP) 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); @@ -9529,7 +9529,7 @@ md_apply_fix (fixP, valueP) 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 @@ -9549,7 +9549,7 @@ md_apply_fix (fixP, valueP) 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) @@ -9818,7 +9818,7 @@ mips_align (to, fill, label) 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 ()); } } @@ -10002,10 +10002,12 @@ s_float_cons (type) 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 (); @@ -10053,7 +10055,7 @@ s_mips_globl (x) flag = BSF_FUNCTION; } - symbolP->bsym->flags |= flag; + symbol_get_bfdsym (symbolP)->flags |= flag; S_SET_EXTERNAL (symbolP); demand_empty_rest_of_line (); @@ -10297,7 +10299,7 @@ s_cpload (ignore) 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, @@ -10489,7 +10491,7 @@ s_mips_weakext (ignore) ignore_rest_of_line(); return; } - symbolP->sy_value = exp; + symbol_set_value_expression (symbolP, &exp); } demand_empty_rest_of_line (); @@ -10601,15 +10603,16 @@ nopic_need_relax (sym, before_relaxing) 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 @@ -10679,23 +10682,26 @@ mips16_extended_frag (fragp, sec, stretch) 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; @@ -10737,7 +10743,8 @@ mips16_extended_frag (fragp, sec, stretch) 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; @@ -10748,7 +10755,7 @@ mips16_extended_frag (fragp, sec, stretch) 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) @@ -10882,14 +10889,14 @@ md_estimate_size_before_relax (fragp, segtype) 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; @@ -10967,7 +10974,8 @@ tc_gen_reloc (section, fixp) 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 @@ -10984,7 +10992,7 @@ tc_gen_reloc (section, fixp) 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; @@ -10996,7 +11004,7 @@ tc_gen_reloc (section, fixp) /* 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)); @@ -11055,7 +11063,8 @@ tc_gen_reloc (section, fixp) 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))); @@ -11433,7 +11442,7 @@ mips_elf_final_processing () typedef struct proc { - struct symbol *isym; + symbolS *isym; unsigned long reg_mask; unsigned long reg_offset; unsigned long fpreg_mask; @@ -11659,7 +11668,7 @@ s_mips_ent (aent) cur_proc_ptr->isym = symbolP; - symbolP->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (symbolP)->flags |= BSF_FUNCTION; numprocs++; } diff --git a/gas/config/tc-mips.h b/gas/config/tc-mips.h index 868aede..ccfd998 100644 --- a/gas/config/tc-mips.h +++ b/gas/config/tc-mips.h @@ -1,5 +1,5 @@ /* 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. @@ -85,7 +85,7 @@ extern void mips_init_after_args PARAMS ((void)); 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)); diff --git a/gas/config/tc-ns32k.h b/gas/config/tc-ns32k.h index 4b038eb..69c86ec 100644 --- a/gas/config/tc-ns32k.h +++ b/gas/config/tc-ns32k.h @@ -1,5 +1,5 @@ /* 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. @@ -76,7 +76,7 @@ extern void fix_new_ns32k_exp PARAMS((fragS *frag, 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, diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c index 0270ceb..a028e0b 100644 --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -1,5 +1,5 @@ /* 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. @@ -1405,8 +1405,8 @@ ppc_elf_lcomm(xxx) 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; @@ -4656,7 +4656,7 @@ md_apply_fix3 (fixp, valuep, seg) { /* `*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))) @@ -4887,7 +4887,7 @@ md_apply_fix3 (fixp, valuep, seg) 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 @@ -4994,7 +4994,8 @@ tc_gen_reloc (seg, fixp) 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) diff --git a/gas/config/tc-ppc.h b/gas/config/tc-ppc.h index 0871d13..1b239bc 100644 --- a/gas/config/tc-ppc.h +++ b/gas/config/tc-ppc.h @@ -1,5 +1,5 @@ /* 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. @@ -121,7 +121,7 @@ extern int ppc_pe_fix_adjustable PARAMS ((struct fix *)); 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. */ @@ -137,11 +137,11 @@ struct ppc_tc_sy 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 @@ -158,11 +158,11 @@ extern char *ppc_canonicalize_symbol_name PARAMS ((char *)); /* 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) @@ -178,7 +178,7 @@ extern void ppc_frob_section PARAMS ((asection *)); /* 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 () @@ -203,8 +203,8 @@ extern void ppc_adjust_symtab PARAMS ((void)); #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 **)); diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c index 6d8ca81..e21962c 100644 --- a/gas/config/tc-sh.c +++ b/gas/config/tc-sh.c @@ -1,5 +1,5 @@ /* 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. @@ -1450,7 +1450,8 @@ sh_frob_section (abfd, sec, ignore) 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); } } @@ -2056,7 +2057,11 @@ md_apply_fix (fixP, val) case BFD_RELOC_VTABLE_INHERIT: case BFD_RELOC_VTABLE_ENTRY: fixP->fx_done = 0; +#ifdef BFD_ASSEMBLER + return 0; +#else return; +#endif default: abort (); @@ -2377,7 +2382,8 @@ tc_gen_reloc (section, fixp) 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; diff --git a/gas/config/tc-sh.h b/gas/config/tc-sh.h index cc02eab..f4278c2 100644 --- a/gas/config/tc-sh.h +++ b/gas/config/tc-sh.h @@ -1,5 +1,5 @@ /* 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. @@ -56,6 +56,8 @@ extern int sh_force_relocation (); #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 diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c index 1518a8a..ae4de1d 100644 --- a/gas/config/tc-sparc.c +++ b/gas/config/tc-sparc.c @@ -1,5 +1,5 @@ /* 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 @@ -2504,7 +2504,7 @@ md_apply_fix3 (fixP, value, segment) 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) @@ -2549,7 +2549,7 @@ md_apply_fix3 (fixP, value, segment) && 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 @@ -2606,7 +2606,7 @@ md_apply_fix3 (fixP, value, segment) 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; @@ -2787,7 +2787,8 @@ tc_gen_reloc (section, fixp) 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) @@ -2906,7 +2907,7 @@ tc_gen_reloc (section, fixp) || 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)); @@ -2961,7 +2962,7 @@ 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; } @@ -3110,9 +3111,9 @@ s_reserve (ignore) /* 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; @@ -3218,7 +3219,7 @@ s_common (ignore) } #ifdef OBJ_ELF - if (symbolP->local) + if (symbol_get_obj (symbolP)->local) { segT old_sec; int old_subsec; @@ -3245,8 +3246,8 @@ s_common (ignore) 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; @@ -3289,7 +3290,7 @@ s_common (ignore) } #ifdef BFD_ASSEMBLER - symbolP->bsym->flags |= BSF_OBJECT; + symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT; #endif demand_empty_rest_of_line (); diff --git a/gas/config/tc-tahoe.c b/gas/config/tc-tahoe.c index 2bd63ca..26a7524 100644 --- a/gas/config/tc-tahoe.c +++ b/gas/config/tc-tahoe.c @@ -1611,7 +1611,7 @@ md_assemble (instruction_string) 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. */ diff --git a/gas/config/tc-vax.c b/gas/config/tc-vax.c index 24e4a9b..f425ccc 100644 --- a/gas/config/tc-vax.c +++ b/gas/config/tc-vax.c @@ -1,5 +1,6 @@ /* 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. @@ -335,7 +336,7 @@ md_assemble (instruction_string) 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. */ diff --git a/gas/config/tc-w65.c b/gas/config/tc-w65.c index 72201e7..e57eb0f 100644 --- a/gas/config/tc-w65.c +++ b/gas/config/tc-w65.c @@ -1081,7 +1081,7 @@ md_pcrel_from (fixP) void tc_coff_symbol_emit_hook (x) - struct symbol *x; + symbolS *x; { } diff --git a/gas/config/tc-z8k.c b/gas/config/tc-z8k.c index 1611341..f89b14b 100644 --- a/gas/config/tc-z8k.c +++ b/gas/config/tc-z8k.c @@ -1,5 +1,5 @@ /* 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. @@ -1520,7 +1520,7 @@ md_pcrel_from (fixP) void tc_coff_symbol_emit_hook (s) - struct symbol *s; + symbolS *s; { } diff --git a/gas/ecoff.c b/gas/ecoff.c index d127f52..310d667 100644 --- a/gas/ecoff.c +++ b/gas/ecoff.c @@ -1,5 +1,5 @@ /* ECOFF debugging support. - Copyright (C) 1993, 94, 95, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. Contributed by Cygnus Support. This file was put together by Ian Lance Taylor <ian@cygnus.com>. A good deal of it comes directly from mips-tfile.c, by Michael @@ -1513,6 +1513,8 @@ void ecoff_symbol_new_hook (symbolP) symbolS *symbolP; { + OBJ_SYMFIELD_TYPE *obj; + /* Make sure that we have a file pointer, but only if we have seen a file. If we haven't seen a file, then this is a probably special symbol created by md_begin which may required special handling at @@ -1521,9 +1523,10 @@ ecoff_symbol_new_hook (symbolP) if (cur_file_ptr == (efdr_t *) NULL && seen_at_least_1_file ()) add_file ((const char *) NULL, 0, 1); - symbolP->ecoff_file = cur_file_ptr; - symbolP->ecoff_symbol = NULL; - symbolP->ecoff_extern_size = 0; + obj = symbol_get_obj (symbolP); + obj->ecoff_file = cur_file_ptr; + obj->ecoff_symbol = NULL; + obj->ecoff_extern_size = 0; } /* Add a page to a varray object. */ @@ -1643,7 +1646,7 @@ add_ecoff_symbol (str, type, storage, sym_value, addend, value, indx) psym->name = str; psym->as_sym = sym_value; if (sym_value != (symbolS *) NULL) - sym_value->ecoff_symbol = psym; + symbol_get_obj (sym_value)->ecoff_symbol = psym; psym->addend = addend; psym->file_ptr = cur_file_ptr; psym->proc_ptr = cur_proc_ptr; @@ -2170,7 +2173,7 @@ add_procedure (func) /* Set the BSF_FUNCTION flag for the symbol. */ sym = symbol_find_or_make (func); - sym->bsym->flags |= BSF_FUNCTION; + symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION; /* Push the start of the function. */ new_proc_ptr->sym = add_ecoff_symbol ((const char *) NULL, st_Proc, sc_Text, @@ -3151,7 +3154,7 @@ ecoff_directive_extern (ignore) ++input_line_pointer; size = get_absolute_expression (); - symbolp->ecoff_extern_size = size; + symbol_get_obj (symbolp)->ecoff_extern_size = size; } /* Parse .file directives. */ @@ -3433,7 +3436,7 @@ ecoff_directive_weakext (ignore) ignore_rest_of_line(); return; } - symbolP->sy_value = exp; + symbol_set_value_expression (symbolP, &exp); } } @@ -3616,12 +3619,12 @@ ecoff_stab (sec, what, string, type, other, desc) ECOFF symbol. We want to compute the type of the ECOFF symbol independently. */ if (sym != (symbolS *) NULL) - hold = sym->ecoff_symbol; + hold = symbol_get_obj (sym)->ecoff_symbol; (void) add_ecoff_symbol (string, st, sc, sym, addend, value, indx); if (sym != (symbolS *) NULL) - sym->ecoff_symbol = hold; + symbol_get_obj (sym)->ecoff_symbol = hold; /* Restore normal file type. */ cur_file_ptr = save_file_ptr; @@ -3658,7 +3661,7 @@ ecoff_frob_symbol (sym) } /* Double check weak symbols. */ - if (sym->bsym->flags & BSF_WEAK) + if (S_IS_WEAK (sym)) { if (S_IS_COMMON (sym)) as_bad (_("Symbol `%s' can not be both weak and common"), @@ -4084,7 +4087,8 @@ ecoff_build_symbols (backend, buf, bufend, offset) || S_IS_WEAK (as_sym) || ! S_IS_DEFINED (as_sym))) { - if ((as_sym->bsym->flags & BSF_FUNCTION) != 0) + if ((symbol_get_bfdsym (as_sym)->flags + & BSF_FUNCTION) != 0) st = st_Proc; else st = st_Global; @@ -4096,18 +4100,19 @@ ecoff_build_symbols (backend, buf, bufend, offset) if (! S_IS_DEFINED (as_sym)) { - if (as_sym->ecoff_extern_size == 0 - || (as_sym->ecoff_extern_size - > bfd_get_gp_size (stdoutput))) + valueT s; + + s = symbol_get_obj (as_sym)->ecoff_extern_size; + if (s == 0 + || s > bfd_get_gp_size (stdoutput)) sc = sc_Undefined; else { sc = sc_SUndefined; - sym_ptr->ecoff_sym.asym.value = - as_sym->ecoff_extern_size; + sym_ptr->ecoff_sym.asym.value = s; } #ifdef S_SET_SIZE - S_SET_SIZE (as_sym, as_sym->ecoff_extern_size); + S_SET_SIZE (as_sym, s); #endif } else if (S_IS_COMMON (as_sym)) @@ -4290,7 +4295,7 @@ ecoff_build_symbols (backend, buf, bufend, offset) case this is an external symbol. Note that this destroys the asym.index field. */ if (as_sym != (symbolS *) NULL - && as_sym->ecoff_symbol == sym_ptr) + && symbol_get_obj (as_sym)->ecoff_symbol == sym_ptr) { if ((sym_ptr->ecoff_sym.asym.st == st_Proc || sym_ptr->ecoff_sym.asym.st == st_StaticProc) @@ -4659,7 +4664,7 @@ ecoff_setup_ext () for (sym = symbol_rootP; sym != (symbolS *) NULL; sym = symbol_next (sym)) { - if (sym->ecoff_symbol == NULL) + if (symbol_get_obj (sym)->ecoff_symbol == NULL) continue; /* If this is a local symbol, then force the fields to zero. */ @@ -4667,13 +4672,16 @@ ecoff_setup_ext () && ! S_IS_WEAK (sym) && S_IS_DEFINED (sym)) { - sym->ecoff_symbol->ecoff_sym.asym.value = 0; - sym->ecoff_symbol->ecoff_sym.asym.st = (int) st_Nil; - sym->ecoff_symbol->ecoff_sym.asym.sc = (int) sc_Nil; - sym->ecoff_symbol->ecoff_sym.asym.index = indexNil; + struct localsym *lsym; + + lsym = symbol_get_obj (sym)->ecoff_symbol; + lsym->ecoff_sym.asym.value = 0; + lsym->ecoff_sym.asym.st = (int) st_Nil; + lsym->ecoff_sym.asym.sc = (int) sc_Nil; + lsym->ecoff_sym.asym.index = indexNil; } - obj_ecoff_set_ext (sym, &sym->ecoff_symbol->ecoff_sym); + obj_ecoff_set_ext (sym, &symbol_get_obj (sym)->ecoff_symbol->ecoff_sym); } } @@ -4723,12 +4731,12 @@ ecoff_build_debug (hdr, bufp, backend) cur_proc_ptr = (proc_t *) NULL; for (sym = symbol_rootP; sym != (symbolS *) NULL; sym = symbol_next (sym)) { - if (sym->ecoff_symbol != NULL - || sym->ecoff_file == (efdr_t *) NULL - || (sym->bsym->flags & BSF_SECTION_SYM) != 0) + if (symbol_get_obj (sym)->ecoff_symbol != NULL + || symbol_get_obj (sym)->ecoff_file == (efdr_t *) NULL + || (symbol_get_bfdsym (sym)->flags & BSF_SECTION_SYM) != 0) continue; - cur_file_ptr = sym->ecoff_file; + cur_file_ptr = symbol_get_obj (sym)->ecoff_file; add_ecoff_symbol ((const char *) NULL, st_Nil, sc_Nil, sym, (bfd_vma) 0, S_GET_VALUE (sym), indexNil); } diff --git a/gas/ecoff.h b/gas/ecoff.h index 1a9b6fc..8ac65f8 100644 --- a/gas/ecoff.h +++ b/gas/ecoff.h @@ -1,5 +1,5 @@ /* 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>. @@ -41,10 +41,10 @@ extern void ecoff_new_file PARAMS ((const char *)); /* 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 @@ -89,7 +89,7 @@ extern void ecoff_set_gp_prolog_size PARAMS ((int sz)); /* 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 @@ -100,7 +100,7 @@ extern void ecoff_fix_loc PARAMS ((fragS *, unsigned long)); 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 */ @@ -1,5 +1,5 @@ /* 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. @@ -104,7 +104,7 @@ make_expr_symbol (expressionP) ? 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); @@ -1309,7 +1309,7 @@ operand (expressionP) /* 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) { @@ -1356,8 +1356,8 @@ clean_up_expression (expressionP) 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)))) @@ -1700,8 +1700,8 @@ expr (rank, resultP) 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))) { @@ -1815,7 +1815,7 @@ expr (rank, resultP) /* 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; } @@ -1,5 +1,5 @@ /* 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. @@ -109,9 +109,9 @@ typedef enum 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 @@ -149,14 +149,13 @@ extern void expr_begin PARAMS ((void)); 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 */ diff --git a/gas/frags.h b/gas/frags.h index 9590292..b188e33 100644 --- a/gas/frags.h +++ b/gas/frags.h @@ -1,5 +1,5 @@ /* 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. @@ -54,7 +54,7 @@ struct frag /* (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. */ diff --git a/gas/listing.c b/gas/listing.c index 4305cbd..acda916 100644 --- a/gas/listing.c +++ b/gas/listing.c @@ -789,7 +789,7 @@ list_symbol_table () { #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)) @@ -821,11 +821,11 @@ list_symbol_table () 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)); } diff --git a/gas/stabs.c b/gas/stabs.c index db7e1bf..11d4655 100644 --- a/gas/stabs.c +++ b/gas/stabs.c @@ -1,5 +1,5 @@ /* 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. @@ -152,14 +152,14 @@ aout_process_stab (what, string, type, other, desc) 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 ()); } diff --git a/gas/struc-symbol.h b/gas/struc-symbol.h index aeb0405..1087c2b 100644 --- a/gas/struc-symbol.h +++ b/gas/struc-symbol.h @@ -1,5 +1,5 @@ /* 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. @@ -21,16 +21,16 @@ #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. @@ -42,9 +42,6 @@ struct symbol /* 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. */ @@ -91,75 +88,54 @@ struct 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__ */ diff --git a/gas/subsegs.c b/gas/subsegs.c index bdf2868..70dda27 100644 --- a/gas/subsegs.c +++ b/gas/subsegs.c @@ -1,5 +1,5 @@ /* 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. @@ -547,7 +547,7 @@ section_symbol (sec) 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); } } } @@ -556,7 +556,7 @@ section_symbol (sec) /* 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; diff --git a/gas/symbols.c b/gas/symbols.c index 8a05e1f..295a9ad 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -1,5 +1,5 @@ /* 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. @@ -28,6 +28,8 @@ #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; @@ -39,6 +41,9 @@ extern int new_broken_words; /* 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; @@ -93,39 +98,53 @@ symbol_new (name, segment, valu, frag) 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. */ @@ -158,6 +177,101 @@ symbol_create (name, segment, valu, frag) return symbolP; } +#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 */ + /* * colon() @@ -238,7 +352,24 @@ colon (sym_name) /* just seen "x:" - rattle symbols & frags */ /* * 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) { @@ -329,6 +460,14 @@ colon (sym_name) /* just seen "x:" - rattle symbols & frags */ } /* 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 (), @@ -344,6 +483,8 @@ colon (sym_name) /* just seen "x:" - rattle symbols & frags */ { /* 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); @@ -379,6 +520,16 @@ symbol_table_insert (symbolP) 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"), @@ -402,6 +553,20 @@ symbol_find_or_make (name) 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); @@ -450,6 +615,8 @@ symbol_find_base (name, strip_underscore) CONST char *name; int strip_underscore; { + struct local_symbol *locsym; + if (strip_underscore && *name == '_') name++; @@ -482,6 +649,10 @@ symbol_find_base (name, strip_underscore) *copy = '\0'; } + locsym = (struct local_symbol *) hash_find (local_hash, name); + if (locsym != NULL) + return (symbolS *) locsym; + return ((symbolS *) hash_find (sy_hash, name)); } @@ -501,6 +672,11 @@ symbol_append (addme, target, rootPP, lastPP) symbolS **rootPP; symbolS **lastPP; { + if (LOCAL_SYMBOL_CHECK (addme)) + abort (); + if (target != NULL && LOCAL_SYMBOL_CHECK (target)) + abort (); + if (target == NULL) { know (*rootPP == NULL); @@ -541,6 +717,8 @@ void 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; @@ -555,6 +733,9 @@ symbol_remove (symbolP, rootPP, lastPP) symbolS **rootPP; symbolS **lastPP; { + if (LOCAL_SYMBOL_CHECK (symbolP)) + abort (); + if (symbolP == *rootPP) { *rootPP = symbolP->sy_next; @@ -586,6 +767,11 @@ symbol_insert (addme, target, rootPP, lastPP) 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; @@ -617,6 +803,9 @@ verify_symbol_chain (rootP, lastP) 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 @@ -655,6 +844,25 @@ resolve_symbol_value (symp, finalize) 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) @@ -715,12 +923,17 @@ resolve_symbol_value (symp, finalize) /* 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 @@ -738,7 +951,7 @@ resolve_symbol_value (symp, finalize) 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 @@ -748,7 +961,7 @@ resolve_symbol_value (symp, finalize) final_seg = S_GET_SEGMENT (add_symbol); } - resolved = add_symbol->sy_resolved; + resolved = symbol_resolved_p (add_symbol); break; case O_uminus: @@ -767,7 +980,7 @@ resolve_symbol_value (symp, finalize) 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: @@ -912,7 +1125,8 @@ resolve_symbol_value (symp, finalize) 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: @@ -957,6 +1171,33 @@ exit_dont_set_value: 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 @@ -1322,6 +1563,9 @@ valueT 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) @@ -1351,6 +1595,12 @@ S_SET_VALUE (s, val) 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; @@ -1360,6 +1610,11 @@ void 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. */ @@ -1378,7 +1633,12 @@ int 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; } @@ -1387,7 +1647,12 @@ int 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)) @@ -1400,6 +1665,8 @@ int S_IS_WEAK (s) symbolS *s; { + if (LOCAL_SYMBOL_CHECK (s)) + return 0; return (s->bsym->flags & BSF_WEAK) != 0; } @@ -1407,6 +1674,8 @@ int S_IS_COMMON (s) symbolS *s; { + if (LOCAL_SYMBOL_CHECK (s)) + return 0; return bfd_is_com_section (s->bsym->section); } @@ -1414,6 +1683,8 @@ int 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; } @@ -1421,6 +1692,8 @@ int S_IS_DEBUG (s) symbolS *s; { + if (LOCAL_SYMBOL_CHECK (s)) + return 0; if (s->bsym->flags & BSF_DEBUGGING) return 1; return 0; @@ -1430,9 +1703,14 @@ int 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 (); @@ -1475,6 +1753,8 @@ CONST char * S_GET_NAME (s) symbolS *s; { + if (LOCAL_SYMBOL_CHECK (s)) + return ((struct local_symbol *) s)->lsy_name; return s->bsym->name; } @@ -1482,6 +1762,8 @@ segT S_GET_SEGMENT (s) symbolS *s; { + if (LOCAL_SYMBOL_CHECK (s)) + return ((struct local_symbol *) s)->lsy_section; return s->bsym->section; } @@ -1494,6 +1776,17 @@ S_SET_SEGMENT (s, seg) 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) @@ -1507,6 +1800,8 @@ void 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. */ @@ -1520,6 +1815,8 @@ void S_CLEAR_EXTERNAL (s) symbolS *s; { + if (LOCAL_SYMBOL_CHECK (s)) + return; if ((s->bsym->flags & BSF_WEAK) != 0) { /* Let .weak override. */ @@ -1533,6 +1830,8 @@ void 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); } @@ -1542,16 +1841,375 @@ S_SET_NAME (s, name) 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 @@ -1569,6 +2227,7 @@ symbol_begin () fb_label_init (); } + int indent_level; @@ -1595,28 +2254,42 @@ print_symbol_value_1 (file, sym) 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); @@ -1629,7 +2302,11 @@ print_symbol_value_1 (file, 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--; } @@ -1787,6 +2464,11 @@ symbol_print_statistics (file) 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 */ diff --git a/gas/symbols.h b/gas/symbols.h index c6efbdb..bd7604e 100644 --- a/gas/symbols.h +++ b/gas/symbols.h @@ -1,5 +1,6 @@ /* 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. @@ -18,6 +19,18 @@ 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 @@ -49,6 +62,7 @@ void symbol_begin PARAMS ((void)); void symbol_print_statistics PARAMS ((FILE *)); void symbol_table_insert PARAMS ((symbolS * symbolP)); valueT resolve_symbol_value PARAMS ((symbolS *, int)); +void resolve_local_symbol_values PARAMS ((void)); void print_symbol_value PARAMS ((symbolS *)); void print_expr PARAMS ((expressionS *)); @@ -87,4 +101,104 @@ extern void S_CLEAR_EXTERNAL PARAMS ((symbolS *)); 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 */ diff --git a/gas/write.c b/gas/write.c index 13f78b9..a8b8046 100644 --- a/gas/write.c +++ b/gas/write.c @@ -1,5 +1,5 @@ /* 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. @@ -719,23 +719,23 @@ adjust_reloc_syms (abfd, sec, xxx) 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; @@ -752,10 +752,10 @@ adjust_reloc_syms (abfd, sec, xxx) 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; @@ -769,13 +769,13 @@ adjust_reloc_syms (abfd, sec, xxx) 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; } @@ -805,10 +805,10 @@ adjust_reloc_syms (abfd, sec, xxx) 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; } @@ -816,9 +816,9 @@ adjust_reloc_syms (abfd, sec, xxx) /* 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; } @@ -829,7 +829,7 @@ adjust_reloc_syms (abfd, sec, xxx) 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 @@ -839,7 +839,7 @@ adjust_reloc_syms (abfd, sec, xxx) #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 @@ -850,7 +850,7 @@ adjust_reloc_syms (abfd, sec, xxx) #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 @@ -864,7 +864,7 @@ adjust_reloc_syms (abfd, sec, xxx) 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: ; @@ -931,17 +931,17 @@ write_relocs (abfd, sec, xxx) 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; @@ -1004,9 +1004,9 @@ write_relocs (abfd, sec, xxx) 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); @@ -1333,8 +1333,8 @@ set_symtab () 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 @@ -1623,7 +1623,7 @@ write_object_file () /* 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) @@ -1637,7 +1637,7 @@ write_object_file () 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; @@ -1770,9 +1770,9 @@ write_object_file () 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); @@ -1795,7 +1795,7 @@ write_object_file () 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"), @@ -1817,23 +1817,11 @@ write_object_file () /* Do it again, because adjust_reloc_syms might introduce more symbols. They'll probably only be section symbols, but they'll still need to have the values computed. */ - 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); @@ -1849,15 +1837,15 @@ write_object_file () 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 @@ -1867,13 +1855,13 @@ write_object_file () 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 @@ -1884,16 +1872,16 @@ write_object_file () } /* 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); } } @@ -2002,9 +1990,7 @@ relax_frag (fragP, stretch) #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. @@ -2015,8 +2001,8 @@ relax_frag (fragP, stretch) 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; } @@ -2225,10 +2211,10 @@ relax_segment (segment_frag_root, segment) 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) { @@ -2250,8 +2236,10 @@ relax_segment (segment_frag_root, segment) 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; @@ -2301,8 +2289,8 @@ relax_segment (segment_frag_root, segment) 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); @@ -2325,7 +2313,7 @@ relax_segment (segment_frag_root, segment) 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, @@ -2465,12 +2453,13 @@ fixup_segment (fixP, this_segment_type) 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) @@ -2702,7 +2691,7 @@ fixup_segment (fixP, this_segment_type) #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; } } |