Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | /* struct_symbol.h - Internal symbol structure |
2 | Copyright (C) 1987, 92, 93, 94, 95, 1998 Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of GAS, the GNU Assembler. | |
5 | ||
6 | GAS is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GAS is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GAS; see the file COPYING. If not, write to the Free | |
18 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
19 | 02111-1307, USA. */ | |
20 | ||
21 | #ifndef __struc_symbol_h__ | |
22 | #define __struc_symbol_h__ | |
23 | ||
24 | #ifdef BFD_ASSEMBLER | |
25 | /* The BFD code wants to walk the list in both directions. */ | |
26 | #undef SYMBOLS_NEED_BACKPOINTERS | |
27 | #define SYMBOLS_NEED_BACKPOINTERS | |
28 | #endif | |
29 | ||
30 | /* our version of an nlist node */ | |
31 | struct symbol | |
32 | { | |
33 | #ifndef BFD_ASSEMBLER | |
34 | /* The (4-origin) position of sy_name in the symbol table of the object | |
35 | file. This will be 0 for (nameless) .stabd symbols. | |
36 | ||
37 | Not used until write_object_file() time. */ | |
38 | unsigned long sy_name_offset; | |
39 | ||
40 | /* What we write in .o file (if permitted). */ | |
41 | obj_symbol_type sy_symbol; | |
42 | ||
43 | /* The 24 bit symbol number. Symbol numbers start at 0 and are unsigned. */ | |
44 | long sy_number; | |
45 | #else | |
46 | /* BFD symbol */ | |
47 | asymbol *bsym; | |
48 | #endif | |
49 | ||
50 | /* The value of the symbol. */ | |
51 | expressionS sy_value; | |
52 | ||
53 | /* Forwards and (optionally) backwards chain pointers. */ | |
54 | struct symbol *sy_next; | |
55 | #ifdef SYMBOLS_NEED_BACKPOINTERS | |
56 | struct symbol *sy_previous; | |
57 | #endif /* SYMBOLS_NEED_BACKPOINTERS */ | |
58 | ||
59 | /* Pointer to the frag this symbol is attached to, if any. | |
60 | Otherwise, NULL. */ | |
61 | struct frag *sy_frag; | |
62 | ||
63 | unsigned int written : 1; | |
64 | /* Whether symbol value has been completely resolved (used during | |
65 | final pass over symbol table). */ | |
66 | unsigned int sy_resolved : 1; | |
67 | /* Whether the symbol value is currently being resolved (used to | |
68 | detect loops in symbol dependencies). */ | |
69 | unsigned int sy_resolving : 1; | |
70 | /* Whether the symbol value is used in a reloc. This is used to | |
71 | ensure that symbols used in relocs are written out, even if they | |
72 | are local and would otherwise not be. */ | |
73 | unsigned int sy_used_in_reloc : 1; | |
74 | ||
75 | /* Whether the symbol is used as an operand or in an expression. | |
76 | NOTE: Not all the backends keep this information accurate; | |
77 | backends which use this bit are responsible for setting it when | |
78 | a symbol is used in backend routines. */ | |
79 | unsigned int sy_used : 1; | |
80 | ||
81 | /* This is set if the symbol is defined in an MRI common section. | |
82 | We handle such sections as single common symbols, so symbols | |
83 | defined within them must be treated specially by the relocation | |
84 | routines. */ | |
85 | unsigned int sy_mri_common : 1; | |
86 | ||
87 | #ifdef OBJ_SYMFIELD_TYPE | |
88 | OBJ_SYMFIELD_TYPE sy_obj; | |
89 | #endif | |
90 | ||
91 | #ifdef TC_SYMFIELD_TYPE | |
92 | TC_SYMFIELD_TYPE sy_tc; | |
93 | #endif | |
94 | ||
95 | #ifdef TARGET_SYMBOL_FIELDS | |
96 | TARGET_SYMBOL_FIELDS | |
97 | #endif | |
98 | }; | |
99 | ||
100 | typedef struct symbol symbolS; | |
101 | ||
102 | #ifndef WORKING_DOT_WORD | |
103 | struct broken_word | |
104 | { | |
105 | /* Linked list -- one of these structures per ".word x-y+C" | |
106 | expression. */ | |
107 | struct broken_word *next_broken_word; | |
108 | /* Segment and subsegment for broken word. */ | |
109 | segT seg; | |
110 | subsegT subseg; | |
111 | /* Which frag is this broken word in? */ | |
112 | fragS *frag; | |
113 | /* Where in the frag is it? */ | |
114 | char *word_goes_here; | |
115 | /* Where to add the break. */ | |
116 | fragS *dispfrag; /* where to add the break */ | |
117 | /* Operands of expression. */ | |
118 | symbolS *add; | |
119 | symbolS *sub; | |
120 | offsetT addnum; | |
121 | ||
122 | int added; /* nasty thing happend yet? */ | |
123 | /* 1: added and has a long-jump */ | |
124 | /* 2: added but uses someone elses long-jump */ | |
125 | ||
126 | /* Pointer to broken_word with a similar long-jump. */ | |
127 | struct broken_word *use_jump; | |
128 | }; | |
129 | extern struct broken_word *broken_words; | |
130 | #endif /* ndef WORKING_DOT_WORD */ | |
131 | ||
132 | /* | |
133 | * Current means for getting from symbols to segments and vice verse. | |
134 | * This will change for infinite-segments support (e.g. COFF). | |
135 | */ | |
136 | extern const segT N_TYPE_seg[]; /* subseg.c */ | |
137 | ||
138 | #define SEGMENT_TO_SYMBOL_TYPE(seg) ( seg_N_TYPE [(int) (seg)] ) | |
139 | extern const short seg_N_TYPE[];/* subseg.c */ | |
140 | ||
141 | #define N_REGISTER 30 /* Fake N_TYPE value for SEG_REGISTER */ | |
142 | ||
143 | void symbol_clear_list_pointers PARAMS ((symbolS * symbolP)); | |
144 | ||
145 | #ifdef SYMBOLS_NEED_BACKPOINTERS | |
146 | ||
147 | void symbol_insert PARAMS ((symbolS * addme, symbolS * target, | |
148 | symbolS ** rootP, symbolS ** lastP)); | |
149 | void symbol_remove PARAMS ((symbolS * symbolP, symbolS ** rootP, | |
150 | symbolS ** lastP)); | |
151 | ||
152 | #define symbol_previous(s) ((s)->sy_previous) | |
153 | ||
154 | #endif /* SYMBOLS_NEED_BACKPOINTERS */ | |
155 | ||
156 | void verify_symbol_chain PARAMS ((symbolS * rootP, symbolS * lastP)); | |
157 | void verify_symbol_chain_2 PARAMS ((symbolS * symP)); | |
158 | ||
159 | void symbol_append PARAMS ((symbolS * addme, symbolS * target, | |
160 | symbolS ** rootP, symbolS ** lastP)); | |
161 | ||
162 | #define symbol_next(s) ((s)->sy_next) | |
163 | ||
164 | #endif /* __struc_symbol_h__ */ | |
165 | ||
166 | /* end of struc-symbol.h */ |