Blame gas/struc-symbol.h

Packit ba3681
/* struct_symbol.h - Internal symbol structure
Packit ba3681
   Copyright (C) 1987-2018 Free Software Foundation, Inc.
Packit ba3681
Packit ba3681
   This file is part of GAS, the GNU Assembler.
Packit ba3681
Packit ba3681
   GAS is free software; you can redistribute it and/or modify
Packit ba3681
   it under the terms of the GNU General Public License as published by
Packit ba3681
   the Free Software Foundation; either version 3, or (at your option)
Packit ba3681
   any later version.
Packit ba3681
Packit ba3681
   GAS is distributed in the hope that it will be useful,
Packit ba3681
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit ba3681
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit ba3681
   GNU General Public License for more details.
Packit ba3681
Packit ba3681
   You should have received a copy of the GNU General Public License
Packit ba3681
   along with GAS; see the file COPYING.  If not, write to the Free
Packit ba3681
   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
Packit ba3681
   02110-1301, USA.  */
Packit ba3681
Packit ba3681
#ifndef __struc_symbol_h__
Packit ba3681
#define __struc_symbol_h__
Packit ba3681
Packit ba3681
struct symbol_flags
Packit ba3681
{
Packit ba3681
  /* Whether the symbol is a local_symbol.  */
Packit ba3681
  unsigned int sy_local_symbol : 1;
Packit ba3681
Packit ba3681
  /* Weather symbol has been written.  */
Packit ba3681
  unsigned int sy_written : 1;
Packit ba3681
Packit ba3681
  /* Whether symbol value has been completely resolved (used during
Packit ba3681
     final pass over symbol table).  */
Packit ba3681
  unsigned int sy_resolved : 1;
Packit ba3681
Packit ba3681
  /* Whether the symbol value is currently being resolved (used to
Packit ba3681
     detect loops in symbol dependencies).  */
Packit ba3681
  unsigned int sy_resolving : 1;
Packit ba3681
Packit ba3681
  /* Whether the symbol value is used in a reloc.  This is used to
Packit ba3681
     ensure that symbols used in relocs are written out, even if they
Packit ba3681
     are local and would otherwise not be.  */
Packit ba3681
  unsigned int sy_used_in_reloc : 1;
Packit ba3681
Packit ba3681
  /* Whether the symbol is used as an operand or in an expression.
Packit ba3681
     NOTE:  Not all the backends keep this information accurate;
Packit ba3681
     backends which use this bit are responsible for setting it when
Packit ba3681
     a symbol is used in backend routines.  */
Packit ba3681
  unsigned int sy_used : 1;
Packit ba3681
Packit ba3681
  /* Whether the symbol can be re-defined.  */
Packit ba3681
  unsigned int sy_volatile : 1;
Packit ba3681
Packit ba3681
  /* Whether the symbol is a forward reference.  */
Packit ba3681
  unsigned int sy_forward_ref : 1;
Packit ba3681
Packit ba3681
  /* This is set if the symbol is defined in an MRI common section.
Packit ba3681
     We handle such sections as single common symbols, so symbols
Packit ba3681
     defined within them must be treated specially by the relocation
Packit ba3681
     routines.  */
Packit ba3681
  unsigned int sy_mri_common : 1;
Packit ba3681
Packit ba3681
  /* This is set if the symbol is set with a .weakref directive.  */
Packit ba3681
  unsigned int sy_weakrefr : 1;
Packit ba3681
Packit ba3681
  /* This is set when the symbol is referenced as part of a .weakref
Packit ba3681
     directive, but only if the symbol was not in the symbol table
Packit ba3681
     before.  It is cleared as soon as any direct reference to the
Packit ba3681
     symbol is present.  */
Packit ba3681
  unsigned int sy_weakrefd : 1;
Packit ba3681
};
Packit ba3681
Packit ba3681
/* The information we keep for a symbol.  Note that the symbol table
Packit ba3681
   holds pointers both to this and to local_symbol structures.  See
Packit ba3681
   below.  */
Packit ba3681
Packit ba3681
struct symbol
Packit ba3681
{
Packit ba3681
  /* Symbol flags.  */
Packit ba3681
  struct symbol_flags sy_flags;
Packit ba3681
Packit ba3681
  /* BFD symbol */
Packit ba3681
  asymbol *bsym;
Packit ba3681
Packit ba3681
  /* The value of the symbol.  */
Packit ba3681
  expressionS sy_value;
Packit ba3681
Packit ba3681
  /* Forwards and (optionally) backwards chain pointers.  */
Packit ba3681
  struct symbol *sy_next;
Packit ba3681
  struct symbol *sy_previous;
Packit ba3681
Packit ba3681
  /* Pointer to the frag this symbol is attached to, if any.
Packit ba3681
     Otherwise, NULL.  */
Packit ba3681
  struct frag *sy_frag;
Packit ba3681
Packit ba3681
#ifdef OBJ_SYMFIELD_TYPE
Packit ba3681
  OBJ_SYMFIELD_TYPE sy_obj;
Packit ba3681
#endif
Packit ba3681
Packit ba3681
#ifdef TC_SYMFIELD_TYPE
Packit ba3681
  TC_SYMFIELD_TYPE sy_tc;
Packit ba3681
#endif
Packit ba3681
Packit ba3681
#ifdef TARGET_SYMBOL_FIELDS
Packit ba3681
  TARGET_SYMBOL_FIELDS
Packit ba3681
#endif
Packit ba3681
};
Packit ba3681
Packit ba3681
/* A pointer in the symbol may point to either a complete symbol
Packit ba3681
   (struct symbol above) or to a local symbol (struct local_symbol
Packit ba3681
   defined here).  The symbol code can detect the case by examining
Packit ba3681
   the first field.  It is always NULL for a local symbol.
Packit ba3681
Packit ba3681
   We do this because we ordinarily only need a small amount of
Packit ba3681
   information for a local symbol.  The symbol table takes up a lot of
Packit ba3681
   space, and storing less information for a local symbol can make a
Packit ba3681
   big difference in assembler memory usage when assembling a large
Packit ba3681
   file.  */
Packit ba3681
Packit ba3681
struct local_symbol
Packit ba3681
{
Packit ba3681
  /* Symbol flags.  Only sy_local_symbol and sy_resolved are relevant.  */
Packit ba3681
  struct symbol_flags lsy_flags;
Packit ba3681
Packit ba3681
  /* The symbol section.  This also serves as a flag.  If this is
Packit ba3681
     reg_section, then this symbol has been converted into a regular
Packit ba3681
     symbol, and lsy_sym points to it.  */
Packit ba3681
  segT lsy_section;
Packit ba3681
Packit ba3681
  /* The symbol name.  */
Packit ba3681
  const char *lsy_name;
Packit ba3681
Packit ba3681
  /* The symbol frag or the real symbol, depending upon the value in
Packit ba3681
     lsy_section.  */
Packit ba3681
  union
Packit ba3681
  {
Packit ba3681
    fragS *lsy_frag;
Packit ba3681
    symbolS *lsy_sym;
Packit ba3681
  } u;
Packit ba3681
Packit ba3681
  /* The value of the symbol.  */
Packit ba3681
  valueT lsy_value;
Packit ba3681
Packit ba3681
#ifdef TC_LOCAL_SYMFIELD_TYPE
Packit ba3681
  TC_LOCAL_SYMFIELD_TYPE lsy_tc;
Packit ba3681
#endif
Packit ba3681
};
Packit ba3681
Packit ba3681
#define local_symbol_converted_p(l) ((l)->lsy_section == reg_section)
Packit ba3681
#define local_symbol_mark_converted(l) ((l)->lsy_section = reg_section)
Packit ba3681
#define local_symbol_resolved_p(l) ((l)->lsy_flags.sy_resolved)
Packit ba3681
#define local_symbol_mark_resolved(l) ((l)->lsy_flags.sy_resolved = 1)
Packit ba3681
#define local_symbol_get_frag(l) ((l)->u.lsy_frag)
Packit ba3681
#define local_symbol_set_frag(l, f) ((l)->u.lsy_frag = (f))
Packit ba3681
#define local_symbol_get_real_symbol(l) ((l)->u.lsy_sym)
Packit ba3681
#define local_symbol_set_real_symbol(l, s) ((l)->u.lsy_sym = (s))
Packit ba3681
Packit ba3681
#endif /* __struc_symbol_h__ */