Back to index

cell-binutils  2.17cvs20070401
struc-symbol.h
Go to the documentation of this file.
00001 /* struct_symbol.h - Internal symbol structure
00002    Copyright 1987, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2005
00003    Free Software Foundation, Inc.
00004 
00005    This file is part of GAS, the GNU Assembler.
00006 
00007    GAS is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2, or (at your option)
00010    any later version.
00011 
00012    GAS is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with GAS; see the file COPYING.  If not, write to the Free
00019    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
00020    02110-1301, USA.  */
00021 
00022 #ifndef __struc_symbol_h__
00023 #define __struc_symbol_h__
00024 
00025 /* The information we keep for a symbol.  Note that the symbol table
00026    holds pointers both to this and to local_symbol structures.  See
00027    below.  */
00028 
00029 struct symbol
00030 {
00031   /* BFD symbol */
00032   asymbol *bsym;
00033 
00034   /* The value of the symbol.  */
00035   expressionS sy_value;
00036 
00037   /* Forwards and (optionally) backwards chain pointers.  */
00038   struct symbol *sy_next;
00039   struct symbol *sy_previous;
00040 
00041   /* Pointer to the frag this symbol is attached to, if any.
00042      Otherwise, NULL.  */
00043   struct frag *sy_frag;
00044 
00045   unsigned int written : 1;
00046   /* Whether symbol value has been completely resolved (used during
00047      final pass over symbol table).  */
00048   unsigned int sy_resolved : 1;
00049   /* Whether the symbol value is currently being resolved (used to
00050      detect loops in symbol dependencies).  */
00051   unsigned int sy_resolving : 1;
00052   /* Whether the symbol value is used in a reloc.  This is used to
00053      ensure that symbols used in relocs are written out, even if they
00054      are local and would otherwise not be.  */
00055   unsigned int sy_used_in_reloc : 1;
00056 
00057   /* Whether the symbol is used as an operand or in an expression.
00058      NOTE:  Not all the backends keep this information accurate;
00059      backends which use this bit are responsible for setting it when
00060      a symbol is used in backend routines.  */
00061   unsigned int sy_used : 1;
00062 
00063   /* Whether the symbol can be re-defined.  */
00064   unsigned int sy_volatile : 1;
00065 
00066   /* Whether the symbol is a forward reference.  */
00067   unsigned int sy_forward_ref : 1;
00068 
00069   /* This is set if the symbol is defined in an MRI common section.
00070      We handle such sections as single common symbols, so symbols
00071      defined within them must be treated specially by the relocation
00072      routines.  */
00073   unsigned int sy_mri_common : 1;
00074 
00075   /* This is set if the symbol is set with a .weakref directive.  */
00076   unsigned int sy_weakrefr : 1;
00077 
00078   /* This is set when the symbol is referenced as part of a .weakref
00079      directive, but only if the symbol was not in the symbol table
00080      before.  It is cleared as soon as any direct reference to the
00081      symbol is present.  */
00082   unsigned int sy_weakrefd : 1;
00083 
00084 #ifdef OBJ_SYMFIELD_TYPE
00085   OBJ_SYMFIELD_TYPE sy_obj;
00086 #endif
00087 
00088 #ifdef TC_SYMFIELD_TYPE
00089   TC_SYMFIELD_TYPE sy_tc;
00090 #endif
00091 
00092 #ifdef TARGET_SYMBOL_FIELDS
00093   TARGET_SYMBOL_FIELDS
00094 #endif
00095 };
00096 
00097 /* A pointer in the symbol may point to either a complete symbol
00098    (struct symbol above) or to a local symbol (struct local_symbol
00099    defined here).  The symbol code can detect the case by examining
00100    the first field.  It is always NULL for a local symbol.
00101 
00102    We do this because we ordinarily only need a small amount of
00103    information for a local symbol.  The symbol table takes up a lot of
00104    space, and storing less information for a local symbol can make a
00105    big difference in assembler memory usage when assembling a large
00106    file.  */
00107 
00108 struct local_symbol
00109 {
00110   /* This pointer is always NULL to indicate that this is a local
00111      symbol.  */
00112   asymbol *lsy_marker;
00113 
00114   /* The symbol section.  This also serves as a flag.  If this is
00115      reg_section, then this symbol has been converted into a regular
00116      symbol, and lsy_sym points to it.  */
00117   segT lsy_section;
00118 
00119   /* The symbol name.  */
00120   const char *lsy_name;
00121 
00122   /* The symbol frag or the real symbol, depending upon the value in
00123      lsy_section.  If the symbol has been fully resolved, lsy_frag is
00124      set to NULL.  */
00125   union
00126   {
00127     fragS *lsy_frag;
00128     symbolS *lsy_sym;
00129   } u;
00130 
00131   /* The value of the symbol.  */
00132   valueT lsy_value;
00133 
00134 #ifdef TC_LOCAL_SYMFIELD_TYPE
00135   TC_LOCAL_SYMFIELD_TYPE lsy_tc;
00136 #endif
00137 };
00138 
00139 #define local_symbol_converted_p(l) ((l)->lsy_section == reg_section)
00140 #define local_symbol_mark_converted(l) ((l)->lsy_section = reg_section)
00141 #define local_symbol_resolved_p(l) ((l)->u.lsy_frag == NULL)
00142 #define local_symbol_mark_resolved(l) ((l)->u.lsy_frag = NULL)
00143 #define local_symbol_get_frag(l) ((l)->u.lsy_frag)
00144 #define local_symbol_set_frag(l, f) ((l)->u.lsy_frag = (f))
00145 #define local_symbol_get_real_symbol(l) ((l)->u.lsy_sym)
00146 #define local_symbol_set_real_symbol(l, s) ((l)->u.lsy_sym = (s))
00147 
00148 #endif /* __struc_symbol_h__ */