Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* struct_symbol.h - Internal symbol structure |
f7e42eb4 | 2 | Copyright 1987, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001 |
a01b9fa4 | 3 | 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 | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
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 | |
19 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
20 | 02111-1307, USA. */ | |
21 | ||
22 | #ifndef __struc_symbol_h__ | |
23 | #define __struc_symbol_h__ | |
24 | ||
0d2bcfaf NC |
25 | #ifdef BFD_ASSEMBLER |
26 | /* The BFD code wants to walk the list in both directions. */ | |
27 | #undef SYMBOLS_NEED_BACKPOINTERS | |
28 | #define SYMBOLS_NEED_BACKPOINTERS | |
29 | #endif | |
30 | ||
49309057 ILT |
31 | /* The information we keep for a symbol. Note that the symbol table |
32 | holds pointers both to this and to local_symbol structures. See | |
33 | below. */ | |
252b5132 | 34 | |
252b5132 RH |
35 | struct symbol |
36 | { | |
49309057 ILT |
37 | #ifdef BFD_ASSEMBLER |
38 | /* BFD symbol */ | |
39 | asymbol *bsym; | |
40 | #else | |
252b5132 RH |
41 | /* The (4-origin) position of sy_name in the symbol table of the object |
42 | file. This will be 0 for (nameless) .stabd symbols. | |
43 | ||
a01b9fa4 | 44 | Not used until write_object_file() time. */ |
252b5132 RH |
45 | unsigned long sy_name_offset; |
46 | ||
47 | /* What we write in .o file (if permitted). */ | |
48 | obj_symbol_type sy_symbol; | |
49 | ||
a01b9fa4 | 50 | /* The 24 bit symbol number. Symbol numbers start at 0 and are unsigned. */ |
252b5132 | 51 | long sy_number; |
252b5132 RH |
52 | #endif |
53 | ||
54 | /* The value of the symbol. */ | |
55 | expressionS sy_value; | |
56 | ||
57 | /* Forwards and (optionally) backwards chain pointers. */ | |
58 | struct symbol *sy_next; | |
59 | #ifdef SYMBOLS_NEED_BACKPOINTERS | |
60 | struct symbol *sy_previous; | |
61 | #endif /* SYMBOLS_NEED_BACKPOINTERS */ | |
62 | ||
63 | /* Pointer to the frag this symbol is attached to, if any. | |
64 | Otherwise, NULL. */ | |
65 | struct frag *sy_frag; | |
66 | ||
67 | unsigned int written : 1; | |
68 | /* Whether symbol value has been completely resolved (used during | |
69 | final pass over symbol table). */ | |
70 | unsigned int sy_resolved : 1; | |
71 | /* Whether the symbol value is currently being resolved (used to | |
72 | detect loops in symbol dependencies). */ | |
73 | unsigned int sy_resolving : 1; | |
74 | /* Whether the symbol value is used in a reloc. This is used to | |
75 | ensure that symbols used in relocs are written out, even if they | |
76 | are local and would otherwise not be. */ | |
77 | unsigned int sy_used_in_reloc : 1; | |
78 | ||
a01b9fa4 | 79 | /* Whether the symbol is used as an operand or in an expression. |
252b5132 RH |
80 | NOTE: Not all the backends keep this information accurate; |
81 | backends which use this bit are responsible for setting it when | |
82 | a symbol is used in backend routines. */ | |
83 | unsigned int sy_used : 1; | |
84 | ||
85 | /* This is set if the symbol is defined in an MRI common section. | |
86 | We handle such sections as single common symbols, so symbols | |
87 | defined within them must be treated specially by the relocation | |
88 | routines. */ | |
89 | unsigned int sy_mri_common : 1; | |
90 | ||
91 | #ifdef OBJ_SYMFIELD_TYPE | |
92 | OBJ_SYMFIELD_TYPE sy_obj; | |
93 | #endif | |
94 | ||
95 | #ifdef TC_SYMFIELD_TYPE | |
96 | TC_SYMFIELD_TYPE sy_tc; | |
97 | #endif | |
0d2bcfaf NC |
98 | |
99 | #ifdef TARGET_SYMBOL_FIELDS | |
100 | TARGET_SYMBOL_FIELDS | |
101 | #endif | |
252b5132 RH |
102 | }; |
103 | ||
a1605869 ILT |
104 | #ifdef BFD_ASSEMBLER |
105 | ||
49309057 ILT |
106 | /* A pointer in the symbol may point to either a complete symbol |
107 | (struct symbol above) or to a local symbol (struct local_symbol | |
108 | defined here). The symbol code can detect the case by examining | |
109 | the first field. It is always NULL for a local symbol. | |
252b5132 | 110 | |
49309057 ILT |
111 | We do this because we ordinarily only need a small amount of |
112 | information for a local symbol. The symbol table takes up a lot of | |
113 | space, and storing less information for a local symbol can make a | |
114 | big difference in assembler memory usage when assembling a large | |
115 | file. */ | |
252b5132 | 116 | |
49309057 ILT |
117 | struct local_symbol |
118 | { | |
119 | /* This pointer is always NULL to indicate that this is a local | |
120 | symbol. */ | |
121 | asymbol *lsy_marker; | |
122 | ||
123 | /* The symbol section. This also serves as a flag. If this is | |
124 | reg_section, then this symbol has been converted into a regular | |
bd780143 | 125 | symbol, and lsy_sym points to it. */ |
49309057 ILT |
126 | segT lsy_section; |
127 | ||
128 | /* The symbol name. */ | |
129 | const char *lsy_name; | |
130 | ||
131 | /* The symbol frag or the real symbol, depending upon the value in | |
bd780143 | 132 | lsy_section. If the symbol has been fully resolved, lsy_frag is |
49309057 ILT |
133 | set to NULL. */ |
134 | union | |
135 | { | |
136 | fragS *lsy_frag; | |
137 | symbolS *lsy_sym; | |
138 | } u; | |
252b5132 | 139 | |
bd780143 AM |
140 | /* The value of the symbol. */ |
141 | valueT lsy_value; | |
8c5e1ccd AO |
142 | |
143 | #ifdef TC_LOCAL_SYMFIELD_TYPE | |
144 | TC_LOCAL_SYMFIELD_TYPE lsy_tc; | |
145 | #endif | |
49309057 | 146 | }; |
252b5132 | 147 | |
49309057 ILT |
148 | #define local_symbol_converted_p(l) ((l)->lsy_section == reg_section) |
149 | #define local_symbol_mark_converted(l) ((l)->lsy_section = reg_section) | |
150 | #define local_symbol_resolved_p(l) ((l)->u.lsy_frag == NULL) | |
151 | #define local_symbol_mark_resolved(l) ((l)->u.lsy_frag = NULL) | |
152 | #define local_symbol_get_frag(l) ((l)->u.lsy_frag) | |
153 | #define local_symbol_set_frag(l, f) ((l)->u.lsy_frag = (f)) | |
154 | #define local_symbol_get_real_symbol(l) ((l)->u.lsy_sym) | |
155 | #define local_symbol_set_real_symbol(l, s) ((l)->u.lsy_sym = (s)) | |
252b5132 | 156 | |
a1605869 ILT |
157 | #endif /* BFD_ASSEMBLER */ |
158 | ||
252b5132 | 159 | #endif /* __struc_symbol_h__ */ |