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