symbols.h revision 130561
133965Sjdp/* symbols.h - 2104834Sobrien Copyright 1987, 1990, 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001, 3130561Sobrien 2002, 2003 Free Software Foundation, Inc. 433965Sjdp 533965Sjdp This file is part of GAS, the GNU Assembler. 633965Sjdp 733965Sjdp GAS is free software; you can redistribute it and/or modify 833965Sjdp it under the terms of the GNU General Public License as published by 933965Sjdp the Free Software Foundation; either version 2, or (at your option) 1033965Sjdp any later version. 1133965Sjdp 1233965Sjdp GAS is distributed in the hope that it will be useful, 1333965Sjdp but WITHOUT ANY WARRANTY; without even the implied warranty of 1433965Sjdp MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1533965Sjdp GNU General Public License for more details. 1633965Sjdp 1733965Sjdp You should have received a copy of the GNU General Public License 1833965Sjdp along with GAS; see the file COPYING. If not, write to the Free 1933965Sjdp Software Foundation, 59 Temple Place - Suite 330, Boston, MA 2033965Sjdp 02111-1307, USA. */ 2133965Sjdp 2260484Sobrien#ifdef BFD_ASSEMBLER 2360484Sobrien/* The BFD code wants to walk the list in both directions. */ 2460484Sobrien#undef SYMBOLS_NEED_BACKPOINTERS 2560484Sobrien#define SYMBOLS_NEED_BACKPOINTERS 2660484Sobrien#endif 2760484Sobrien 2860484Sobrien#ifndef BFD_ASSEMBLER 2960484Sobrien/* The non-BFD code expects to be able to manipulate the symbol fields 3060484Sobrien directly. */ 3160484Sobrien#include "struc-symbol.h" 3260484Sobrien#endif 3360484Sobrien 3477298Sobrienextern struct obstack notes; /* eg FixS live here. */ 3533965Sjdp 3633965Sjdpextern struct obstack cond_obstack; /* this is where we track .ifdef/.endif 3733965Sjdp (if we do that at all). */ 3833965Sjdp 3933965Sjdpextern symbolS *symbol_rootP; /* all the symbol nodes */ 4033965Sjdpextern symbolS *symbol_lastP; /* last struct symbol we made, or NULL */ 4133965Sjdp 4233965Sjdpextern symbolS abs_symbol; 4333965Sjdp 4433965Sjdpextern int symbol_table_frozen; 4533965Sjdp 4633965Sjdp/* This is non-zero if symbols are case sensitive, which is the 4733965Sjdp default. */ 4833965Sjdpextern int symbols_case_sensitive; 4933965Sjdp 50130561Sobrienchar *decode_local_label_name (char *s); 51130561SobriensymbolS *symbol_find (const char *name); 52130561SobriensymbolS *symbol_find_exact (const char *name); 53130561SobriensymbolS *symbol_find_base (const char *name, int strip_underscore); 54130561SobriensymbolS *symbol_find_or_make (const char *name); 55130561SobriensymbolS *symbol_make (const char *name); 56130561SobriensymbolS *symbol_new (const char *name, segT segment, valueT value, 57130561Sobrien fragS * frag); 58130561SobriensymbolS *symbol_create (const char *name, segT segment, valueT value, 59130561Sobrien fragS * frag); 60130561Sobrienstruct local_symbol *local_symbol_make (const char *name, segT section, 61130561Sobrien valueT value, fragS * frag); 62130561SobriensymbolS *symbol_temp_new (segT, valueT, fragS *); 63130561SobriensymbolS *symbol_temp_new_now (void); 64130561SobriensymbolS *symbol_temp_make (void); 6533965Sjdp 66130561SobriensymbolS *colon (const char *sym_name); 67130561Sobrienvoid local_colon (int n); 68130561Sobrienvoid symbol_begin (void); 69130561Sobrienvoid symbol_print_statistics (FILE *); 70130561Sobrienvoid symbol_table_insert (symbolS * symbolP); 71130561SobrienvalueT resolve_symbol_value (symbolS *); 72130561Sobrienvoid resolve_local_symbol_values (void); 7333965Sjdp 74130561Sobrienvoid print_symbol_value (symbolS *); 75130561Sobrienvoid print_expr (expressionS *); 76130561Sobrienvoid print_expr_1 (FILE *, expressionS *); 77130561Sobrienvoid print_symbol_value_1 (FILE *, symbolS *); 7833965Sjdp 79130561Sobrienint dollar_label_defined (long l); 80130561Sobrienvoid dollar_label_clear (void); 81130561Sobrienvoid define_dollar_label (long l); 82130561Sobrienchar *dollar_label_name (long l, int augend); 8333965Sjdp 84130561Sobrienvoid fb_label_instance_inc (long label); 85130561Sobrienchar *fb_label_name (long n, long augend); 8633965Sjdp 87130561Sobrienextern void copy_symbol_attributes (symbolS *, symbolS *); 88130561Sobrien 8933965Sjdp/* Get and set the values of symbols. These used to be macros. */ 90130561Sobrienextern valueT S_GET_VALUE (symbolS *); 91130561Sobrienextern void S_SET_VALUE (symbolS *, valueT); 9233965Sjdp 9333965Sjdp#ifdef BFD_ASSEMBLER 94130561Sobrienextern int S_IS_FUNCTION (symbolS *); 95130561Sobrienextern int S_IS_EXTERNAL (symbolS *); 96130561Sobrienextern int S_IS_WEAK (symbolS *); 97130561Sobrienextern int S_IS_COMMON (symbolS *); 98130561Sobrienextern int S_IS_DEFINED (symbolS *); 99130561Sobrienextern int S_FORCE_RELOC (symbolS *, int); 100130561Sobrienextern int S_IS_DEBUG (symbolS *); 101130561Sobrienextern int S_IS_LOCAL (symbolS *); 102130561Sobrienextern int S_IS_EXTERN (symbolS *); 103130561Sobrienextern int S_IS_STABD (symbolS *); 104130561Sobrienextern const char *S_GET_NAME (symbolS *); 105130561Sobrienextern segT S_GET_SEGMENT (symbolS *); 106130561Sobrienextern void S_SET_SEGMENT (symbolS *, segT); 107130561Sobrienextern void S_SET_EXTERNAL (symbolS *); 108130561Sobrienextern void S_SET_NAME (symbolS *, char *); 109130561Sobrienextern void S_CLEAR_EXTERNAL (symbolS *); 110130561Sobrienextern void S_SET_WEAK (symbolS *); 111130561Sobrienextern void S_SET_THREAD_LOCAL (symbolS *); 11233965Sjdp#endif 11333965Sjdp 11460484Sobrien#ifndef WORKING_DOT_WORD 11560484Sobrienstruct broken_word 11660484Sobrien { 11760484Sobrien /* Linked list -- one of these structures per ".word x-y+C" 11860484Sobrien expression. */ 11960484Sobrien struct broken_word *next_broken_word; 12060484Sobrien /* Segment and subsegment for broken word. */ 12160484Sobrien segT seg; 12260484Sobrien subsegT subseg; 12360484Sobrien /* Which frag is this broken word in? */ 12460484Sobrien fragS *frag; 12560484Sobrien /* Where in the frag is it? */ 12660484Sobrien char *word_goes_here; 12760484Sobrien /* Where to add the break. */ 12860484Sobrien fragS *dispfrag; /* where to add the break */ 12960484Sobrien /* Operands of expression. */ 13060484Sobrien symbolS *add; 13160484Sobrien symbolS *sub; 13260484Sobrien offsetT addnum; 13360484Sobrien 134130561Sobrien int added; /* nasty thing happened yet? */ 13560484Sobrien /* 1: added and has a long-jump */ 13660484Sobrien /* 2: added but uses someone elses long-jump */ 13760484Sobrien 13860484Sobrien /* Pointer to broken_word with a similar long-jump. */ 13960484Sobrien struct broken_word *use_jump; 14060484Sobrien }; 14160484Sobrienextern struct broken_word *broken_words; 14260484Sobrien#endif /* ndef WORKING_DOT_WORD */ 14360484Sobrien 14460484Sobrien/* 14560484Sobrien * Current means for getting from symbols to segments and vice verse. 14660484Sobrien * This will change for infinite-segments support (e.g. COFF). 14760484Sobrien */ 14860484Sobrienextern const segT N_TYPE_seg[]; /* subseg.c */ 14960484Sobrien 15060484Sobrien#define SEGMENT_TO_SYMBOL_TYPE(seg) ( seg_N_TYPE [(int) (seg)] ) 15160484Sobrienextern const short seg_N_TYPE[];/* subseg.c */ 15260484Sobrien 15360484Sobrien#define N_REGISTER 30 /* Fake N_TYPE value for SEG_REGISTER */ 15460484Sobrien 155130561Sobrienvoid symbol_clear_list_pointers (symbolS * symbolP); 15660484Sobrien 15760484Sobrien#ifdef SYMBOLS_NEED_BACKPOINTERS 15860484Sobrien 159130561Sobrienvoid symbol_insert (symbolS * addme, symbolS * target, 160130561Sobrien symbolS ** rootP, symbolS ** lastP); 161130561Sobrienvoid symbol_remove (symbolS * symbolP, symbolS ** rootP, 162130561Sobrien symbolS ** lastP); 16360484Sobrien 164130561Sobrienextern symbolS *symbol_previous (symbolS *); 16560484Sobrien 16660484Sobrien#endif /* SYMBOLS_NEED_BACKPOINTERS */ 16760484Sobrien 168130561Sobrienvoid verify_symbol_chain (symbolS * rootP, symbolS * lastP); 169130561Sobrienvoid verify_symbol_chain_2 (symbolS * symP); 17060484Sobrien 171130561Sobrienvoid symbol_append (symbolS * addme, symbolS * target, 172130561Sobrien symbolS ** rootP, symbolS ** lastP); 17360484Sobrien 174130561Sobrienextern symbolS *symbol_next (symbolS *); 17560484Sobrien 176130561Sobrienextern expressionS *symbol_get_value_expression (symbolS *); 177130561Sobrienextern void symbol_set_value_expression (symbolS *, const expressionS *); 178130561Sobrienextern void symbol_set_value_now (symbolS *); 179130561Sobrienextern void symbol_set_frag (symbolS *, fragS *); 180130561Sobrienextern fragS *symbol_get_frag (symbolS *); 181130561Sobrienextern void symbol_mark_used (symbolS *); 182130561Sobrienextern void symbol_clear_used (symbolS *); 183130561Sobrienextern int symbol_used_p (symbolS *); 184130561Sobrienextern void symbol_mark_used_in_reloc (symbolS *); 185130561Sobrienextern void symbol_clear_used_in_reloc (symbolS *); 186130561Sobrienextern int symbol_used_in_reloc_p (symbolS *); 187130561Sobrienextern void symbol_mark_mri_common (symbolS *); 188130561Sobrienextern void symbol_clear_mri_common (symbolS *); 189130561Sobrienextern int symbol_mri_common_p (symbolS *); 190130561Sobrienextern void symbol_mark_written (symbolS *); 191130561Sobrienextern void symbol_clear_written (symbolS *); 192130561Sobrienextern int symbol_written_p (symbolS *); 193130561Sobrienextern void symbol_mark_resolved (symbolS *); 194130561Sobrienextern int symbol_resolved_p (symbolS *); 195130561Sobrienextern int symbol_section_p (symbolS *); 196130561Sobrienextern int symbol_equated_p (symbolS *); 197130561Sobrienextern int symbol_equated_reloc_p (symbolS *); 198130561Sobrienextern int symbol_constant_p (symbolS *); 19960484Sobrien 20060484Sobrien#ifdef BFD_ASSEMBLER 201130561Sobrienextern asymbol *symbol_get_bfdsym (symbolS *); 202130561Sobrienextern void symbol_set_bfdsym (symbolS *, asymbol *); 20360484Sobrien#endif 20460484Sobrien 20560484Sobrien#ifdef OBJ_SYMFIELD_TYPE 206130561SobrienOBJ_SYMFIELD_TYPE *symbol_get_obj (symbolS *); 207130561Sobrienvoid symbol_set_obj (symbolS *, OBJ_SYMFIELD_TYPE *); 20860484Sobrien#endif 20960484Sobrien 21060484Sobrien#ifdef TC_SYMFIELD_TYPE 211130561SobrienTC_SYMFIELD_TYPE *symbol_get_tc (symbolS *); 212130561Sobrienvoid symbol_set_tc (symbolS *, TC_SYMFIELD_TYPE *); 21360484Sobrien#endif 214