struc-symbol.h revision 60484
133965Sjdp/* struct_symbol.h - Internal symbol structure
260484Sobrien   Copyright (C) 1987, 92, 93, 94, 95, 98, 1999 Free Software Foundation, Inc.
333965Sjdp
433965Sjdp   This file is part of GAS, the GNU Assembler.
533965Sjdp
633965Sjdp   GAS is free software; you can redistribute it and/or modify
733965Sjdp   it under the terms of the GNU General Public License as published by
833965Sjdp   the Free Software Foundation; either version 2, or (at your option)
933965Sjdp   any later version.
1033965Sjdp
1133965Sjdp   GAS is distributed in the hope that it will be useful,
1233965Sjdp   but WITHOUT ANY WARRANTY; without even the implied warranty of
1333965Sjdp   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1433965Sjdp   GNU General Public License for more details.
1533965Sjdp
1633965Sjdp   You should have received a copy of the GNU General Public License
1760484Sobrien   along with GAS; see the file COPYING.  If not, write to the Free
1860484Sobrien   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
1960484Sobrien   02111-1307, USA.  */
2033965Sjdp
2133965Sjdp#ifndef __struc_symbol_h__
2233965Sjdp#define __struc_symbol_h__
2333965Sjdp
2460484Sobrien/* The information we keep for a symbol.  Note that the symbol table
2560484Sobrien   holds pointers both to this and to local_symbol structures.  See
2660484Sobrien   below.  */
2733965Sjdp
2833965Sjdpstruct symbol
2933965Sjdp{
3060484Sobrien#ifdef BFD_ASSEMBLER
3160484Sobrien  /* BFD symbol */
3260484Sobrien  asymbol *bsym;
3360484Sobrien#else
3433965Sjdp  /* The (4-origin) position of sy_name in the symbol table of the object
3533965Sjdp     file.  This will be 0 for (nameless) .stabd symbols.
3633965Sjdp
3733965Sjdp     Not used until write_object_file() time. */
3833965Sjdp  unsigned long sy_name_offset;
3933965Sjdp
4033965Sjdp  /* What we write in .o file (if permitted).  */
4133965Sjdp  obj_symbol_type sy_symbol;
4233965Sjdp
4333965Sjdp  /* The 24 bit symbol number.  Symbol numbers start at 0 and are unsigned. */
4433965Sjdp  long sy_number;
4533965Sjdp#endif
4633965Sjdp
4733965Sjdp  /* The value of the symbol.  */
4833965Sjdp  expressionS sy_value;
4933965Sjdp
5033965Sjdp  /* Forwards and (optionally) backwards chain pointers.  */
5133965Sjdp  struct symbol *sy_next;
5233965Sjdp#ifdef SYMBOLS_NEED_BACKPOINTERS
5333965Sjdp  struct symbol *sy_previous;
5433965Sjdp#endif /* SYMBOLS_NEED_BACKPOINTERS */
5533965Sjdp
5633965Sjdp  /* Pointer to the frag this symbol is attached to, if any.
5733965Sjdp     Otherwise, NULL.  */
5833965Sjdp  struct frag *sy_frag;
5933965Sjdp
6033965Sjdp  unsigned int written : 1;
6133965Sjdp  /* Whether symbol value has been completely resolved (used during
6233965Sjdp     final pass over symbol table).  */
6333965Sjdp  unsigned int sy_resolved : 1;
6433965Sjdp  /* Whether the symbol value is currently being resolved (used to
6533965Sjdp     detect loops in symbol dependencies).  */
6633965Sjdp  unsigned int sy_resolving : 1;
6733965Sjdp  /* Whether the symbol value is used in a reloc.  This is used to
6833965Sjdp     ensure that symbols used in relocs are written out, even if they
6933965Sjdp     are local and would otherwise not be.  */
7033965Sjdp  unsigned int sy_used_in_reloc : 1;
7133965Sjdp
7233965Sjdp  /* Whether the symbol is used as an operand or in an expression.
7333965Sjdp     NOTE:  Not all the backends keep this information accurate;
7433965Sjdp     backends which use this bit are responsible for setting it when
7533965Sjdp     a symbol is used in backend routines.  */
7633965Sjdp  unsigned int sy_used : 1;
7733965Sjdp
7833965Sjdp  /* This is set if the symbol is defined in an MRI common section.
7933965Sjdp     We handle such sections as single common symbols, so symbols
8033965Sjdp     defined within them must be treated specially by the relocation
8133965Sjdp     routines.  */
8233965Sjdp  unsigned int sy_mri_common : 1;
8333965Sjdp
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
9133965Sjdp};
9233965Sjdp
9360484Sobrien#ifdef BFD_ASSEMBLER
9433965Sjdp
9560484Sobrien/* A pointer in the symbol may point to either a complete symbol
9660484Sobrien   (struct symbol above) or to a local symbol (struct local_symbol
9760484Sobrien   defined here).  The symbol code can detect the case by examining
9860484Sobrien   the first field.  It is always NULL for a local symbol.
9933965Sjdp
10060484Sobrien   We do this because we ordinarily only need a small amount of
10160484Sobrien   information for a local symbol.  The symbol table takes up a lot of
10260484Sobrien   space, and storing less information for a local symbol can make a
10360484Sobrien   big difference in assembler memory usage when assembling a large
10460484Sobrien   file.  */
10533965Sjdp
10660484Sobrienstruct local_symbol
10760484Sobrien{
10860484Sobrien  /* This pointer is always NULL to indicate that this is a local
10960484Sobrien     symbol.  */
11060484Sobrien  asymbol *lsy_marker;
11133965Sjdp
11260484Sobrien  /* The symbol section.  This also serves as a flag.  If this is
11360484Sobrien     reg_section, then this symbol has been converted into a regular
11460484Sobrien     symbol, and sy_sym points to it.  */
11560484Sobrien  segT lsy_section;
11633965Sjdp
11760484Sobrien  /* The symbol name.  */
11860484Sobrien  const char *lsy_name;
11933965Sjdp
12060484Sobrien  /* The symbol frag or the real symbol, depending upon the value in
12160484Sobrien     sy_section.  If the symbol has been fully resolved, lsy_frag is
12260484Sobrien     set to NULL.  */
12360484Sobrien  union
12460484Sobrien  {
12560484Sobrien    fragS *lsy_frag;
12660484Sobrien    symbolS *lsy_sym;
12760484Sobrien  } u;
12833965Sjdp
12960484Sobrien  /* The offset within the frag.  */
13060484Sobrien  valueT lsy_offset;
13160484Sobrien};
13233965Sjdp
13360484Sobrien#define local_symbol_converted_p(l) ((l)->lsy_section == reg_section)
13460484Sobrien#define local_symbol_mark_converted(l) ((l)->lsy_section = reg_section)
13560484Sobrien#define local_symbol_resolved_p(l) ((l)->u.lsy_frag == NULL)
13660484Sobrien#define local_symbol_mark_resolved(l) ((l)->u.lsy_frag = NULL)
13760484Sobrien#define local_symbol_get_frag(l) ((l)->u.lsy_frag)
13860484Sobrien#define local_symbol_set_frag(l, f) ((l)->u.lsy_frag = (f))
13960484Sobrien#define local_symbol_get_real_symbol(l) ((l)->u.lsy_sym)
14060484Sobrien#define local_symbol_set_real_symbol(l, s) ((l)->u.lsy_sym = (s))
14133965Sjdp
14260484Sobrien#endif /* BFD_ASSEMBLER */
14333965Sjdp
14433965Sjdp#endif /* __struc_symbol_h__ */
14533965Sjdp
14633965Sjdp/* end of struc-symbol.h */
147