Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* struct_symbol.h - Internal symbol structure |
ec2655a6 NC |
2 | Copyright 1987, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2005, |
3 | 2007 Free Software Foundation, Inc. | |
252b5132 RH |
4 | |
5 | This file is part of GAS, the GNU Assembler. | |
6 | ||
7 | GAS is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
ec2655a6 | 9 | the Free Software Foundation; either version 3, or (at your option) |
252b5132 RH |
10 | any later version. |
11 | ||
12 | GAS is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GAS; see the file COPYING. If not, write to the Free | |
4b4da160 NC |
19 | Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA |
20 | 02110-1301, USA. */ | |
252b5132 RH |
21 | |
22 | #ifndef __struc_symbol_h__ | |
23 | #define __struc_symbol_h__ | |
24 | ||
49309057 ILT |
25 | /* The information we keep for a symbol. Note that the symbol table |
26 | holds pointers both to this and to local_symbol structures. See | |
27 | below. */ | |
252b5132 | 28 | |
252b5132 RH |
29 | struct symbol |
30 | { | |
49309057 ILT |
31 | /* BFD symbol */ |
32 | asymbol *bsym; | |
252b5132 RH |
33 | |
34 | /* The value of the symbol. */ | |
35 | expressionS sy_value; | |
36 | ||
37 | /* Forwards and (optionally) backwards chain pointers. */ | |
38 | struct symbol *sy_next; | |
252b5132 | 39 | struct symbol *sy_previous; |
252b5132 RH |
40 | |
41 | /* Pointer to the frag this symbol is attached to, if any. | |
42 | Otherwise, NULL. */ | |
43 | struct frag *sy_frag; | |
44 | ||
45 | unsigned int written : 1; | |
46 | /* Whether symbol value has been completely resolved (used during | |
47 | final pass over symbol table). */ | |
48 | unsigned int sy_resolved : 1; | |
49 | /* Whether the symbol value is currently being resolved (used to | |
50 | detect loops in symbol dependencies). */ | |
51 | unsigned int sy_resolving : 1; | |
52 | /* Whether the symbol value is used in a reloc. This is used to | |
53 | ensure that symbols used in relocs are written out, even if they | |
54 | are local and would otherwise not be. */ | |
55 | unsigned int sy_used_in_reloc : 1; | |
56 | ||
a01b9fa4 | 57 | /* Whether the symbol is used as an operand or in an expression. |
252b5132 RH |
58 | NOTE: Not all the backends keep this information accurate; |
59 | backends which use this bit are responsible for setting it when | |
60 | a symbol is used in backend routines. */ | |
61 | unsigned int sy_used : 1; | |
62 | ||
9497f5ac NC |
63 | /* Whether the symbol can be re-defined. */ |
64 | unsigned int sy_volatile : 1; | |
65 | ||
66 | /* Whether the symbol is a forward reference. */ | |
67 | unsigned int sy_forward_ref : 1; | |
68 | ||
252b5132 RH |
69 | /* This is set if the symbol is defined in an MRI common section. |
70 | We handle such sections as single common symbols, so symbols | |
71 | defined within them must be treated specially by the relocation | |
72 | routines. */ | |
73 | unsigned int sy_mri_common : 1; | |
74 | ||
06e77878 AO |
75 | /* This is set if the symbol is set with a .weakref directive. */ |
76 | unsigned int sy_weakrefr : 1; | |
77 | ||
78 | /* This is set when the symbol is referenced as part of a .weakref | |
79 | directive, but only if the symbol was not in the symbol table | |
80 | before. It is cleared as soon as any direct reference to the | |
81 | symbol is present. */ | |
82 | unsigned int sy_weakrefd : 1; | |
83 | ||
252b5132 RH |
84 | #ifdef OBJ_SYMFIELD_TYPE |
85 | OBJ_SYMFIELD_TYPE sy_obj; | |
86 | #endif | |
87 | ||
88 | #ifdef TC_SYMFIELD_TYPE | |
89 | TC_SYMFIELD_TYPE sy_tc; | |
90 | #endif | |
0d2bcfaf NC |
91 | |
92 | #ifdef TARGET_SYMBOL_FIELDS | |
93 | TARGET_SYMBOL_FIELDS | |
94 | #endif | |
252b5132 RH |
95 | }; |
96 | ||
49309057 ILT |
97 | /* A pointer in the symbol may point to either a complete symbol |
98 | (struct symbol above) or to a local symbol (struct local_symbol | |
99 | defined here). The symbol code can detect the case by examining | |
100 | the first field. It is always NULL for a local symbol. | |
252b5132 | 101 | |
49309057 ILT |
102 | We do this because we ordinarily only need a small amount of |
103 | information for a local symbol. The symbol table takes up a lot of | |
104 | space, and storing less information for a local symbol can make a | |
105 | big difference in assembler memory usage when assembling a large | |
106 | file. */ | |
252b5132 | 107 | |
49309057 ILT |
108 | struct local_symbol |
109 | { | |
110 | /* This pointer is always NULL to indicate that this is a local | |
111 | symbol. */ | |
112 | asymbol *lsy_marker; | |
113 | ||
114 | /* The symbol section. This also serves as a flag. If this is | |
115 | reg_section, then this symbol has been converted into a regular | |
bd780143 | 116 | symbol, and lsy_sym points to it. */ |
49309057 ILT |
117 | segT lsy_section; |
118 | ||
119 | /* The symbol name. */ | |
120 | const char *lsy_name; | |
121 | ||
122 | /* The symbol frag or the real symbol, depending upon the value in | |
bd780143 | 123 | lsy_section. If the symbol has been fully resolved, lsy_frag is |
49309057 ILT |
124 | set to NULL. */ |
125 | union | |
126 | { | |
127 | fragS *lsy_frag; | |
128 | symbolS *lsy_sym; | |
129 | } u; | |
252b5132 | 130 | |
bd780143 AM |
131 | /* The value of the symbol. */ |
132 | valueT lsy_value; | |
8c5e1ccd AO |
133 | |
134 | #ifdef TC_LOCAL_SYMFIELD_TYPE | |
135 | TC_LOCAL_SYMFIELD_TYPE lsy_tc; | |
136 | #endif | |
49309057 | 137 | }; |
252b5132 | 138 | |
49309057 ILT |
139 | #define local_symbol_converted_p(l) ((l)->lsy_section == reg_section) |
140 | #define local_symbol_mark_converted(l) ((l)->lsy_section = reg_section) | |
141 | #define local_symbol_resolved_p(l) ((l)->u.lsy_frag == NULL) | |
142 | #define local_symbol_mark_resolved(l) ((l)->u.lsy_frag = NULL) | |
143 | #define local_symbol_get_frag(l) ((l)->u.lsy_frag) | |
144 | #define local_symbol_set_frag(l, f) ((l)->u.lsy_frag = (f)) | |
145 | #define local_symbol_get_real_symbol(l) ((l)->u.lsy_sym) | |
146 | #define local_symbol_set_real_symbol(l, s) ((l)->u.lsy_sym = (s)) | |
252b5132 RH |
147 | |
148 | #endif /* __struc_symbol_h__ */ |