OSDN Git Service

1087c2b9f44faaf3ce7d90e81bc88e0241b1828b
[pf3gnuchains/pf3gnuchains3x.git] / gas / struc-symbol.h
1 /* struct_symbol.h - Internal symbol structure
2    Copyright (C) 1987, 92, 93, 94, 95, 98, 1999 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 /* The information we keep for a symbol.  Note that the symbol table
25    holds pointers both to this and to local_symbol structures.  See
26    below.  */
27
28 struct symbol
29 {
30 #ifdef BFD_ASSEMBLER
31   /* BFD symbol */
32   asymbol *bsym;
33 #else
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 #endif
46
47   /* The value of the symbol.  */
48   expressionS sy_value;
49
50   /* Forwards and (optionally) backwards chain pointers.  */
51   struct symbol *sy_next;
52 #ifdef SYMBOLS_NEED_BACKPOINTERS
53   struct symbol *sy_previous;
54 #endif /* SYMBOLS_NEED_BACKPOINTERS */
55
56   /* Pointer to the frag this symbol is attached to, if any.
57      Otherwise, NULL.  */
58   struct frag *sy_frag;
59
60   unsigned int written : 1;
61   /* Whether symbol value has been completely resolved (used during
62      final pass over symbol table).  */
63   unsigned int sy_resolved : 1;
64   /* Whether the symbol value is currently being resolved (used to
65      detect loops in symbol dependencies).  */
66   unsigned int sy_resolving : 1;
67   /* Whether the symbol value is used in a reloc.  This is used to
68      ensure that symbols used in relocs are written out, even if they
69      are local and would otherwise not be.  */
70   unsigned int sy_used_in_reloc : 1;
71
72   /* Whether the symbol is used as an operand or in an expression.  
73      NOTE:  Not all the backends keep this information accurate;
74      backends which use this bit are responsible for setting it when
75      a symbol is used in backend routines.  */
76   unsigned int sy_used : 1;
77
78   /* This is set if the symbol is defined in an MRI common section.
79      We handle such sections as single common symbols, so symbols
80      defined within them must be treated specially by the relocation
81      routines.  */
82   unsigned int sy_mri_common : 1;
83
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
91 };
92
93 /* A pointer in the symbol may point to either a complete symbol
94    (struct symbol above) or to a local symbol (struct local_symbol
95    defined here).  The symbol code can detect the case by examining
96    the first field.  It is always NULL for a local symbol.
97
98    We do this because we ordinarily only need a small amount of
99    information for a local symbol.  The symbol table takes up a lot of
100    space, and storing less information for a local symbol can make a
101    big difference in assembler memory usage when assembling a large
102    file.  */
103
104 struct local_symbol
105 {
106   /* This pointer is always NULL to indicate that this is a local
107      symbol.  */
108   asymbol *lsy_marker;
109
110   /* The symbol section.  This also serves as a flag.  If this is
111      reg_section, then this symbol has been converted into a regular
112      symbol, and sy_sym points to it.  */
113   segT lsy_section;
114
115   /* The symbol name.  */
116   const char *lsy_name;
117
118   /* The symbol frag or the real symbol, depending upon the value in
119      sy_section.  If the symbol has been fully resolved, lsy_frag is
120      set to NULL.  */
121   union
122   {
123     fragS *lsy_frag;
124     symbolS *lsy_sym;
125   } u;
126
127   /* The offset within the frag.  */
128   valueT lsy_offset;
129 };
130
131 #define local_symbol_converted_p(l) ((l)->lsy_section == reg_section)
132 #define local_symbol_mark_converted(l) ((l)->lsy_section = reg_section)
133 #define local_symbol_resolved_p(l) ((l)->u.lsy_frag == NULL)
134 #define local_symbol_mark_resolved(l) ((l)->u.lsy_frag = NULL)
135 #define local_symbol_get_frag(l) ((l)->u.lsy_frag)
136 #define local_symbol_set_frag(l, f) ((l)->u.lsy_frag = (f))
137 #define local_symbol_get_real_symbol(l) ((l)->u.lsy_sym)
138 #define local_symbol_set_real_symbol(l, s) ((l)->u.lsy_sym = (s))
139
140 #endif /* __struc_symbol_h__ */
141
142 /* end of struc-symbol.h */