133965Sjdp/* struct_symbol.h - Internal symbol structure
2218822Sdim   Copyright 1987, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2005
377298Sobrien   Free Software Foundation, Inc.
433965Sjdp
533965Sjdp   This file is part of GAS, the GNU Assembler.
633965Sjdp
733965Sjdp   GAS is free software; you can redistribute it and/or modify
833965Sjdp   it under the terms of the GNU General Public License as published by
933965Sjdp   the Free Software Foundation; either version 2, or (at your option)
1033965Sjdp   any later version.
1133965Sjdp
1233965Sjdp   GAS is distributed in the hope that it will be useful,
1333965Sjdp   but WITHOUT ANY WARRANTY; without even the implied warranty of
1433965Sjdp   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1533965Sjdp   GNU General Public License for more details.
1633965Sjdp
1733965Sjdp   You should have received a copy of the GNU General Public License
1860484Sobrien   along with GAS; see the file COPYING.  If not, write to the Free
19218822Sdim   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20218822Sdim   02110-1301, USA.  */
2133965Sjdp
2233965Sjdp#ifndef __struc_symbol_h__
2333965Sjdp#define __struc_symbol_h__
2433965Sjdp
2560484Sobrien/* The information we keep for a symbol.  Note that the symbol table
2660484Sobrien   holds pointers both to this and to local_symbol structures.  See
2760484Sobrien   below.  */
2833965Sjdp
2933965Sjdpstruct symbol
3033965Sjdp{
3160484Sobrien  /* BFD symbol */
3260484Sobrien  asymbol *bsym;
3333965Sjdp
3433965Sjdp  /* The value of the symbol.  */
3533965Sjdp  expressionS sy_value;
3633965Sjdp
3733965Sjdp  /* Forwards and (optionally) backwards chain pointers.  */
3833965Sjdp  struct symbol *sy_next;
3933965Sjdp  struct symbol *sy_previous;
4033965Sjdp
4133965Sjdp  /* Pointer to the frag this symbol is attached to, if any.
4233965Sjdp     Otherwise, NULL.  */
4333965Sjdp  struct frag *sy_frag;
4433965Sjdp
4533965Sjdp  unsigned int written : 1;
4633965Sjdp  /* Whether symbol value has been completely resolved (used during
4733965Sjdp     final pass over symbol table).  */
4833965Sjdp  unsigned int sy_resolved : 1;
4933965Sjdp  /* Whether the symbol value is currently being resolved (used to
5033965Sjdp     detect loops in symbol dependencies).  */
5133965Sjdp  unsigned int sy_resolving : 1;
5233965Sjdp  /* Whether the symbol value is used in a reloc.  This is used to
5333965Sjdp     ensure that symbols used in relocs are written out, even if they
5433965Sjdp     are local and would otherwise not be.  */
5533965Sjdp  unsigned int sy_used_in_reloc : 1;
5633965Sjdp
5777298Sobrien  /* Whether the symbol is used as an operand or in an expression.
5833965Sjdp     NOTE:  Not all the backends keep this information accurate;
5933965Sjdp     backends which use this bit are responsible for setting it when
6033965Sjdp     a symbol is used in backend routines.  */
6133965Sjdp  unsigned int sy_used : 1;
6233965Sjdp
63218822Sdim  /* Whether the symbol can be re-defined.  */
64218822Sdim  unsigned int sy_volatile : 1;
65218822Sdim
66218822Sdim  /* Whether the symbol is a forward reference.  */
67218822Sdim  unsigned int sy_forward_ref : 1;
68218822Sdim
6933965Sjdp  /* This is set if the symbol is defined in an MRI common section.
7033965Sjdp     We handle such sections as single common symbols, so symbols
7133965Sjdp     defined within them must be treated specially by the relocation
7233965Sjdp     routines.  */
7333965Sjdp  unsigned int sy_mri_common : 1;
7433965Sjdp
75218822Sdim  /* This is set if the symbol is set with a .weakref directive.  */
76218822Sdim  unsigned int sy_weakrefr : 1;
77218822Sdim
78218822Sdim  /* This is set when the symbol is referenced as part of a .weakref
79218822Sdim     directive, but only if the symbol was not in the symbol table
80218822Sdim     before.  It is cleared as soon as any direct reference to the
81218822Sdim     symbol is present.  */
82218822Sdim  unsigned int sy_weakrefd : 1;
83218822Sdim
8433965Sjdp#ifdef OBJ_SYMFIELD_TYPE
8533965Sjdp  OBJ_SYMFIELD_TYPE sy_obj;
8633965Sjdp#endif
8733965Sjdp
8833965Sjdp#ifdef TC_SYMFIELD_TYPE
8933965Sjdp  TC_SYMFIELD_TYPE sy_tc;
9033965Sjdp#endif
9177298Sobrien
9277298Sobrien#ifdef TARGET_SYMBOL_FIELDS
9377298Sobrien  TARGET_SYMBOL_FIELDS
9477298Sobrien#endif
9533965Sjdp};
9633965Sjdp
9760484Sobrien/* A pointer in the symbol may point to either a complete symbol
9860484Sobrien   (struct symbol above) or to a local symbol (struct local_symbol
9960484Sobrien   defined here).  The symbol code can detect the case by examining
10060484Sobrien   the first field.  It is always NULL for a local symbol.
10133965Sjdp
10260484Sobrien   We do this because we ordinarily only need a small amount of
10360484Sobrien   information for a local symbol.  The symbol table takes up a lot of
10460484Sobrien   space, and storing less information for a local symbol can make a
10560484Sobrien   big difference in assembler memory usage when assembling a large
10660484Sobrien   file.  */
10733965Sjdp
10860484Sobrienstruct local_symbol
10960484Sobrien{
11060484Sobrien  /* This pointer is always NULL to indicate that this is a local
11160484Sobrien     symbol.  */
11260484Sobrien  asymbol *lsy_marker;
11333965Sjdp
11460484Sobrien  /* The symbol section.  This also serves as a flag.  If this is
11560484Sobrien     reg_section, then this symbol has been converted into a regular
11689857Sobrien     symbol, and lsy_sym points to it.  */
11760484Sobrien  segT lsy_section;
11833965Sjdp
11960484Sobrien  /* The symbol name.  */
12060484Sobrien  const char *lsy_name;
12133965Sjdp
12260484Sobrien  /* The symbol frag or the real symbol, depending upon the value in
12389857Sobrien     lsy_section.  If the symbol has been fully resolved, lsy_frag is
12460484Sobrien     set to NULL.  */
12560484Sobrien  union
12660484Sobrien  {
12760484Sobrien    fragS *lsy_frag;
12860484Sobrien    symbolS *lsy_sym;
12960484Sobrien  } u;
13033965Sjdp
13189857Sobrien  /* The value of the symbol.  */
13289857Sobrien  valueT lsy_value;
13389857Sobrien
13489857Sobrien#ifdef TC_LOCAL_SYMFIELD_TYPE
13589857Sobrien  TC_LOCAL_SYMFIELD_TYPE lsy_tc;
13689857Sobrien#endif
13760484Sobrien};
13833965Sjdp
13960484Sobrien#define local_symbol_converted_p(l) ((l)->lsy_section == reg_section)
14060484Sobrien#define local_symbol_mark_converted(l) ((l)->lsy_section = reg_section)
14160484Sobrien#define local_symbol_resolved_p(l) ((l)->u.lsy_frag == NULL)
14260484Sobrien#define local_symbol_mark_resolved(l) ((l)->u.lsy_frag = NULL)
14360484Sobrien#define local_symbol_get_frag(l) ((l)->u.lsy_frag)
14460484Sobrien#define local_symbol_set_frag(l, f) ((l)->u.lsy_frag = (f))
14560484Sobrien#define local_symbol_get_real_symbol(l) ((l)->u.lsy_sym)
14660484Sobrien#define local_symbol_set_real_symbol(l, s) ((l)->u.lsy_sym = (s))
14733965Sjdp
14833965Sjdp#endif /* __struc_symbol_h__ */
149