1*3d8817e4Smiod /* symbols.h -
2*3d8817e4Smiod    Copyright 1987, 1990, 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001,
3*3d8817e4Smiod    2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4*3d8817e4Smiod 
5*3d8817e4Smiod    This file is part of GAS, the GNU Assembler.
6*3d8817e4Smiod 
7*3d8817e4Smiod    GAS is free software; you can redistribute it and/or modify
8*3d8817e4Smiod    it under the terms of the GNU General Public License as published by
9*3d8817e4Smiod    the Free Software Foundation; either version 2, or (at your option)
10*3d8817e4Smiod    any later version.
11*3d8817e4Smiod 
12*3d8817e4Smiod    GAS is distributed in the hope that it will be useful,
13*3d8817e4Smiod    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*3d8817e4Smiod    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*3d8817e4Smiod    GNU General Public License for more details.
16*3d8817e4Smiod 
17*3d8817e4Smiod    You should have received a copy of the GNU General Public License
18*3d8817e4Smiod    along with GAS; see the file COPYING.  If not, write to the Free
19*3d8817e4Smiod    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20*3d8817e4Smiod    02110-1301, USA.  */
21*3d8817e4Smiod 
22*3d8817e4Smiod extern struct obstack notes;	/* eg FixS live here.  */
23*3d8817e4Smiod 
24*3d8817e4Smiod extern struct obstack cond_obstack;	/* this is where we track .ifdef/.endif
25*3d8817e4Smiod 				       (if we do that at all).  */
26*3d8817e4Smiod 
27*3d8817e4Smiod extern symbolS *symbol_rootP;	/* all the symbol nodes */
28*3d8817e4Smiod extern symbolS *symbol_lastP;	/* last struct symbol we made, or NULL */
29*3d8817e4Smiod 
30*3d8817e4Smiod extern symbolS abs_symbol;
31*3d8817e4Smiod 
32*3d8817e4Smiod extern int symbol_table_frozen;
33*3d8817e4Smiod 
34*3d8817e4Smiod /* This is non-zero if symbols are case sensitive, which is the
35*3d8817e4Smiod    default.  */
36*3d8817e4Smiod extern int symbols_case_sensitive;
37*3d8817e4Smiod 
38*3d8817e4Smiod char *decode_local_label_name (char *s);
39*3d8817e4Smiod symbolS *symbol_find (const char *name);
40*3d8817e4Smiod symbolS *symbol_find_noref (const char *name, int noref);
41*3d8817e4Smiod symbolS *symbol_find_exact (const char *name);
42*3d8817e4Smiod symbolS *symbol_find_exact_noref (const char *name, int noref);
43*3d8817e4Smiod symbolS *symbol_find_or_make (const char *name);
44*3d8817e4Smiod symbolS *symbol_make (const char *name);
45*3d8817e4Smiod symbolS *symbol_new (const char *name, segT segment, valueT value,
46*3d8817e4Smiod 		     fragS * frag);
47*3d8817e4Smiod symbolS *symbol_create (const char *name, segT segment, valueT value,
48*3d8817e4Smiod 			fragS * frag);
49*3d8817e4Smiod symbolS *symbol_clone (symbolS *, int);
50*3d8817e4Smiod #undef symbol_clone_if_forward_ref
51*3d8817e4Smiod symbolS *symbol_clone_if_forward_ref (symbolS *, int);
52*3d8817e4Smiod #define symbol_clone_if_forward_ref(s) symbol_clone_if_forward_ref (s, 0)
53*3d8817e4Smiod symbolS *symbol_temp_new (segT, valueT, fragS *);
54*3d8817e4Smiod symbolS *symbol_temp_new_now (void);
55*3d8817e4Smiod symbolS *symbol_temp_make (void);
56*3d8817e4Smiod 
57*3d8817e4Smiod symbolS *colon (const char *sym_name);
58*3d8817e4Smiod void local_colon (int n);
59*3d8817e4Smiod void symbol_begin (void);
60*3d8817e4Smiod void symbol_print_statistics (FILE *);
61*3d8817e4Smiod void symbol_table_insert (symbolS * symbolP);
62*3d8817e4Smiod valueT resolve_symbol_value (symbolS *);
63*3d8817e4Smiod void resolve_local_symbol_values (void);
64*3d8817e4Smiod int snapshot_symbol (symbolS **, valueT *, segT *, fragS **);
65*3d8817e4Smiod 
66*3d8817e4Smiod void print_symbol_value (symbolS *);
67*3d8817e4Smiod void print_expr (expressionS *);
68*3d8817e4Smiod void print_expr_1 (FILE *, expressionS *);
69*3d8817e4Smiod void print_symbol_value_1 (FILE *, symbolS *);
70*3d8817e4Smiod 
71*3d8817e4Smiod int dollar_label_defined (long l);
72*3d8817e4Smiod void dollar_label_clear (void);
73*3d8817e4Smiod void define_dollar_label (long l);
74*3d8817e4Smiod char *dollar_label_name (long l, int augend);
75*3d8817e4Smiod 
76*3d8817e4Smiod void fb_label_instance_inc (long label);
77*3d8817e4Smiod char *fb_label_name (long n, long augend);
78*3d8817e4Smiod 
79*3d8817e4Smiod extern void copy_symbol_attributes (symbolS *, symbolS *);
80*3d8817e4Smiod 
81*3d8817e4Smiod /* Get and set the values of symbols.  These used to be macros.  */
82*3d8817e4Smiod extern valueT S_GET_VALUE (symbolS *);
83*3d8817e4Smiod extern void S_SET_VALUE (symbolS *, valueT);
84*3d8817e4Smiod 
85*3d8817e4Smiod extern int S_IS_FUNCTION (symbolS *);
86*3d8817e4Smiod extern int S_IS_EXTERNAL (symbolS *);
87*3d8817e4Smiod extern int S_IS_WEAK (symbolS *);
88*3d8817e4Smiod extern int S_IS_WEAKREFR (symbolS *);
89*3d8817e4Smiod extern int S_IS_WEAKREFD (symbolS *);
90*3d8817e4Smiod extern int S_IS_COMMON (symbolS *);
91*3d8817e4Smiod extern int S_IS_DEFINED (symbolS *);
92*3d8817e4Smiod extern int S_FORCE_RELOC (symbolS *, int);
93*3d8817e4Smiod extern int S_IS_DEBUG (symbolS *);
94*3d8817e4Smiod extern int S_IS_LOCAL (symbolS *);
95*3d8817e4Smiod extern int S_IS_STABD (symbolS *);
96*3d8817e4Smiod extern int S_IS_VOLATILE (const symbolS *);
97*3d8817e4Smiod extern int S_IS_FORWARD_REF (const symbolS *);
98*3d8817e4Smiod extern const char *S_GET_NAME (symbolS *);
99*3d8817e4Smiod extern segT S_GET_SEGMENT (symbolS *);
100*3d8817e4Smiod extern void S_SET_SEGMENT (symbolS *, segT);
101*3d8817e4Smiod extern void S_SET_EXTERNAL (symbolS *);
102*3d8817e4Smiod extern void S_SET_NAME (symbolS *, const char *);
103*3d8817e4Smiod extern void S_CLEAR_EXTERNAL (symbolS *);
104*3d8817e4Smiod extern void S_SET_WEAK (symbolS *);
105*3d8817e4Smiod extern void S_SET_WEAKREFR (symbolS *);
106*3d8817e4Smiod extern void S_CLEAR_WEAKREFR (symbolS *);
107*3d8817e4Smiod extern void S_SET_WEAKREFD (symbolS *);
108*3d8817e4Smiod extern void S_CLEAR_WEAKREFD (symbolS *);
109*3d8817e4Smiod extern void S_SET_THREAD_LOCAL (symbolS *);
110*3d8817e4Smiod extern void S_SET_VOLATILE (symbolS *);
111*3d8817e4Smiod extern void S_CLEAR_VOLATILE (symbolS *);
112*3d8817e4Smiod extern void S_SET_FORWARD_REF (symbolS *);
113*3d8817e4Smiod 
114*3d8817e4Smiod #ifndef WORKING_DOT_WORD
115*3d8817e4Smiod struct broken_word
116*3d8817e4Smiod   {
117*3d8817e4Smiod     /* Linked list -- one of these structures per ".word x-y+C"
118*3d8817e4Smiod        expression.  */
119*3d8817e4Smiod     struct broken_word *next_broken_word;
120*3d8817e4Smiod     /* Segment and subsegment for broken word.  */
121*3d8817e4Smiod     segT seg;
122*3d8817e4Smiod     subsegT subseg;
123*3d8817e4Smiod     /* Which frag is this broken word in?  */
124*3d8817e4Smiod     fragS *frag;
125*3d8817e4Smiod     /* Where in the frag is it?  */
126*3d8817e4Smiod     char *word_goes_here;
127*3d8817e4Smiod     /* Where to add the break.  */
128*3d8817e4Smiod     fragS *dispfrag;		/* where to add the break */
129*3d8817e4Smiod     /* Operands of expression.  */
130*3d8817e4Smiod     symbolS *add;
131*3d8817e4Smiod     symbolS *sub;
132*3d8817e4Smiod     offsetT addnum;
133*3d8817e4Smiod 
134*3d8817e4Smiod     int added;			/* nasty thing happened yet? */
135*3d8817e4Smiod     /* 1: added and has a long-jump */
136*3d8817e4Smiod     /* 2: added but uses someone elses long-jump */
137*3d8817e4Smiod 
138*3d8817e4Smiod     /* Pointer to broken_word with a similar long-jump.  */
139*3d8817e4Smiod     struct broken_word *use_jump;
140*3d8817e4Smiod   };
141*3d8817e4Smiod extern struct broken_word *broken_words;
142*3d8817e4Smiod #endif /* ndef WORKING_DOT_WORD */
143*3d8817e4Smiod 
144*3d8817e4Smiod /*
145*3d8817e4Smiod  * Current means for getting from symbols to segments and vice verse.
146*3d8817e4Smiod  * This will change for infinite-segments support (e.g. COFF).
147*3d8817e4Smiod  */
148*3d8817e4Smiod extern const segT N_TYPE_seg[];	/* subseg.c */
149*3d8817e4Smiod 
150*3d8817e4Smiod #define	SEGMENT_TO_SYMBOL_TYPE(seg)  ( seg_N_TYPE [(int) (seg)] )
151*3d8817e4Smiod extern const short seg_N_TYPE[];/* subseg.c */
152*3d8817e4Smiod 
153*3d8817e4Smiod #define	N_REGISTER	30	/* Fake N_TYPE value for SEG_REGISTER */
154*3d8817e4Smiod 
155*3d8817e4Smiod void symbol_clear_list_pointers (symbolS * symbolP);
156*3d8817e4Smiod 
157*3d8817e4Smiod void symbol_insert (symbolS * addme, symbolS * target,
158*3d8817e4Smiod 		    symbolS ** rootP, symbolS ** lastP);
159*3d8817e4Smiod void symbol_remove (symbolS * symbolP, symbolS ** rootP,
160*3d8817e4Smiod 		    symbolS ** lastP);
161*3d8817e4Smiod 
162*3d8817e4Smiod extern symbolS *symbol_previous (symbolS *);
163*3d8817e4Smiod 
164*3d8817e4Smiod void verify_symbol_chain (symbolS * rootP, symbolS * lastP);
165*3d8817e4Smiod 
166*3d8817e4Smiod void symbol_append (symbolS * addme, symbolS * target,
167*3d8817e4Smiod 		    symbolS ** rootP, symbolS ** lastP);
168*3d8817e4Smiod 
169*3d8817e4Smiod extern symbolS *symbol_next (symbolS *);
170*3d8817e4Smiod 
171*3d8817e4Smiod extern expressionS *symbol_get_value_expression (symbolS *);
172*3d8817e4Smiod extern void symbol_set_value_expression (symbolS *, const expressionS *);
173*3d8817e4Smiod extern offsetT *symbol_X_add_number (symbolS *);
174*3d8817e4Smiod extern void symbol_set_value_now (symbolS *);
175*3d8817e4Smiod extern void symbol_set_frag (symbolS *, fragS *);
176*3d8817e4Smiod extern fragS *symbol_get_frag (symbolS *);
177*3d8817e4Smiod extern void symbol_mark_used (symbolS *);
178*3d8817e4Smiod extern void symbol_clear_used (symbolS *);
179*3d8817e4Smiod extern int symbol_used_p (symbolS *);
180*3d8817e4Smiod extern void symbol_mark_used_in_reloc (symbolS *);
181*3d8817e4Smiod extern void symbol_clear_used_in_reloc (symbolS *);
182*3d8817e4Smiod extern int symbol_used_in_reloc_p (symbolS *);
183*3d8817e4Smiod extern void symbol_mark_mri_common (symbolS *);
184*3d8817e4Smiod extern void symbol_clear_mri_common (symbolS *);
185*3d8817e4Smiod extern int symbol_mri_common_p (symbolS *);
186*3d8817e4Smiod extern void symbol_mark_written (symbolS *);
187*3d8817e4Smiod extern void symbol_clear_written (symbolS *);
188*3d8817e4Smiod extern int symbol_written_p (symbolS *);
189*3d8817e4Smiod extern void symbol_mark_resolved (symbolS *);
190*3d8817e4Smiod extern int symbol_resolved_p (symbolS *);
191*3d8817e4Smiod extern int symbol_section_p (symbolS *);
192*3d8817e4Smiod extern int symbol_equated_p (symbolS *);
193*3d8817e4Smiod extern int symbol_equated_reloc_p (symbolS *);
194*3d8817e4Smiod extern int symbol_constant_p (symbolS *);
195*3d8817e4Smiod extern asymbol *symbol_get_bfdsym (symbolS *);
196*3d8817e4Smiod extern void symbol_set_bfdsym (symbolS *, asymbol *);
197*3d8817e4Smiod 
198*3d8817e4Smiod #ifdef OBJ_SYMFIELD_TYPE
199*3d8817e4Smiod OBJ_SYMFIELD_TYPE *symbol_get_obj (symbolS *);
200*3d8817e4Smiod void symbol_set_obj (symbolS *, OBJ_SYMFIELD_TYPE *);
201*3d8817e4Smiod #endif
202*3d8817e4Smiod 
203*3d8817e4Smiod #ifdef TC_SYMFIELD_TYPE
204*3d8817e4Smiod TC_SYMFIELD_TYPE *symbol_get_tc (symbolS *);
205*3d8817e4Smiod void symbol_set_tc (symbolS *, TC_SYMFIELD_TYPE *);
206*3d8817e4Smiod #endif
207