Subversion Repositories Kolibri OS

Rev

Rev 5222 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5222 Rev 6324
1
/* struct_symbol.h - Internal symbol structure
1
/* struct_symbol.h - Internal symbol structure
2
   Copyright 1987, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2005,
-
 
3
   2007, 2008, 2009 Free Software Foundation, Inc.
2
   Copyright (C) 1987-2015 Free Software Foundation, Inc.
4
 
3
 
5
   This file is part of GAS, the GNU Assembler.
4
   This file is part of GAS, the GNU Assembler.
6
 
5
 
7
   GAS is free software; you can redistribute it and/or modify
6
   GAS is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
7
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3, or (at your option)
8
   the Free Software Foundation; either version 3, or (at your option)
10
   any later version.
9
   any later version.
11
 
10
 
12
   GAS is distributed in the hope that it will be useful,
11
   GAS is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
14
   GNU General Public License for more details.
16
 
15
 
17
   You should have received a copy of the GNU General Public License
16
   You should have received a copy of the GNU General Public License
18
   along with GAS; see the file COPYING.  If not, write to the Free
17
   along with GAS; see the file COPYING.  If not, write to the Free
19
   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
18
   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20
   02110-1301, USA.  */
19
   02110-1301, USA.  */
21
 
20
 
22
#ifndef __struc_symbol_h__
21
#ifndef __struc_symbol_h__
23
#define __struc_symbol_h__
22
#define __struc_symbol_h__
24
 
23
 
25
struct symbol_flags
24
struct symbol_flags
26
{
25
{
27
  /* Wether the symbol is a local_symbol.  */
26
  /* Wether the symbol is a local_symbol.  */
28
  unsigned int sy_local_symbol : 1;
27
  unsigned int sy_local_symbol : 1;
29
 
28
 
30
  /* Wether symbol has been written.  */
29
  /* Wether symbol has been written.  */
31
  unsigned int sy_written : 1;
30
  unsigned int sy_written : 1;
32
 
31
 
33
  /* Whether symbol value has been completely resolved (used during
32
  /* Whether symbol value has been completely resolved (used during
34
     final pass over symbol table).  */
33
     final pass over symbol table).  */
35
  unsigned int sy_resolved : 1;
34
  unsigned int sy_resolved : 1;
36
 
35
 
37
  /* Whether the symbol value is currently being resolved (used to
36
  /* Whether the symbol value is currently being resolved (used to
38
     detect loops in symbol dependencies).  */
37
     detect loops in symbol dependencies).  */
39
  unsigned int sy_resolving : 1;
38
  unsigned int sy_resolving : 1;
40
 
39
 
41
  /* Whether the symbol value is used in a reloc.  This is used to
40
  /* Whether the symbol value is used in a reloc.  This is used to
42
     ensure that symbols used in relocs are written out, even if they
41
     ensure that symbols used in relocs are written out, even if they
43
     are local and would otherwise not be.  */
42
     are local and would otherwise not be.  */
44
  unsigned int sy_used_in_reloc : 1;
43
  unsigned int sy_used_in_reloc : 1;
45
 
44
 
46
  /* Whether the symbol is used as an operand or in an expression.
45
  /* Whether the symbol is used as an operand or in an expression.
47
     NOTE:  Not all the backends keep this information accurate;
46
     NOTE:  Not all the backends keep this information accurate;
48
     backends which use this bit are responsible for setting it when
47
     backends which use this bit are responsible for setting it when
49
     a symbol is used in backend routines.  */
48
     a symbol is used in backend routines.  */
50
  unsigned int sy_used : 1;
49
  unsigned int sy_used : 1;
51
 
50
 
52
  /* Whether the symbol can be re-defined.  */
51
  /* Whether the symbol can be re-defined.  */
53
  unsigned int sy_volatile : 1;
52
  unsigned int sy_volatile : 1;
54
 
53
 
55
  /* Whether the symbol is a forward reference.  */
54
  /* Whether the symbol is a forward reference.  */
56
  unsigned int sy_forward_ref : 1;
55
  unsigned int sy_forward_ref : 1;
57
 
56
 
58
  /* This is set if the symbol is defined in an MRI common section.
57
  /* This is set if the symbol is defined in an MRI common section.
59
     We handle such sections as single common symbols, so symbols
58
     We handle such sections as single common symbols, so symbols
60
     defined within them must be treated specially by the relocation
59
     defined within them must be treated specially by the relocation
61
     routines.  */
60
     routines.  */
62
  unsigned int sy_mri_common : 1;
61
  unsigned int sy_mri_common : 1;
63
 
62
 
64
  /* This is set if the symbol is set with a .weakref directive.  */
63
  /* This is set if the symbol is set with a .weakref directive.  */
65
  unsigned int sy_weakrefr : 1;
64
  unsigned int sy_weakrefr : 1;
66
 
65
 
67
  /* This is set when the symbol is referenced as part of a .weakref
66
  /* This is set when the symbol is referenced as part of a .weakref
68
     directive, but only if the symbol was not in the symbol table
67
     directive, but only if the symbol was not in the symbol table
69
     before.  It is cleared as soon as any direct reference to the
68
     before.  It is cleared as soon as any direct reference to the
70
     symbol is present.  */
69
     symbol is present.  */
71
  unsigned int sy_weakrefd : 1;
70
  unsigned int sy_weakrefd : 1;
72
};
71
};
73
 
72
 
74
/* The information we keep for a symbol.  Note that the symbol table
73
/* The information we keep for a symbol.  Note that the symbol table
75
   holds pointers both to this and to local_symbol structures.  See
74
   holds pointers both to this and to local_symbol structures.  See
76
   below.  */
75
   below.  */
77
 
76
 
78
struct symbol
77
struct symbol
79
{
78
{
80
  /* Symbol flags.  */
79
  /* Symbol flags.  */
81
  struct symbol_flags sy_flags;
80
  struct symbol_flags sy_flags;
82
 
81
 
83
  /* BFD symbol */
82
  /* BFD symbol */
84
  asymbol *bsym;
83
  asymbol *bsym;
85
 
84
 
86
  /* The value of the symbol.  */
85
  /* The value of the symbol.  */
87
  expressionS sy_value;
86
  expressionS sy_value;
88
 
87
 
89
  /* Forwards and (optionally) backwards chain pointers.  */
88
  /* Forwards and (optionally) backwards chain pointers.  */
90
  struct symbol *sy_next;
89
  struct symbol *sy_next;
91
  struct symbol *sy_previous;
90
  struct symbol *sy_previous;
92
 
91
 
93
  /* Pointer to the frag this symbol is attached to, if any.
92
  /* Pointer to the frag this symbol is attached to, if any.
94
     Otherwise, NULL.  */
93
     Otherwise, NULL.  */
95
  struct frag *sy_frag;
94
  struct frag *sy_frag;
96
 
95
 
97
#ifdef OBJ_SYMFIELD_TYPE
96
#ifdef OBJ_SYMFIELD_TYPE
98
  OBJ_SYMFIELD_TYPE sy_obj;
97
  OBJ_SYMFIELD_TYPE sy_obj;
99
#endif
98
#endif
100
 
99
 
101
#ifdef TC_SYMFIELD_TYPE
100
#ifdef TC_SYMFIELD_TYPE
102
  TC_SYMFIELD_TYPE sy_tc;
101
  TC_SYMFIELD_TYPE sy_tc;
103
#endif
102
#endif
104
 
103
 
105
#ifdef TARGET_SYMBOL_FIELDS
104
#ifdef TARGET_SYMBOL_FIELDS
106
  TARGET_SYMBOL_FIELDS
105
  TARGET_SYMBOL_FIELDS
107
#endif
106
#endif
108
};
107
};
109
 
108
 
110
/* A pointer in the symbol may point to either a complete symbol
109
/* A pointer in the symbol may point to either a complete symbol
111
   (struct symbol above) or to a local symbol (struct local_symbol
110
   (struct symbol above) or to a local symbol (struct local_symbol
112
   defined here).  The symbol code can detect the case by examining
111
   defined here).  The symbol code can detect the case by examining
113
   the first field.  It is always NULL for a local symbol.
112
   the first field.  It is always NULL for a local symbol.
114
 
113
 
115
   We do this because we ordinarily only need a small amount of
114
   We do this because we ordinarily only need a small amount of
116
   information for a local symbol.  The symbol table takes up a lot of
115
   information for a local symbol.  The symbol table takes up a lot of
117
   space, and storing less information for a local symbol can make a
116
   space, and storing less information for a local symbol can make a
118
   big difference in assembler memory usage when assembling a large
117
   big difference in assembler memory usage when assembling a large
119
   file.  */
118
   file.  */
120
 
119
 
121
struct local_symbol
120
struct local_symbol
122
{
121
{
123
  /* Symbol flags.  Only sy_local_symbol and sy_resolved are relevant.  */
122
  /* Symbol flags.  Only sy_local_symbol and sy_resolved are relevant.  */
124
  struct symbol_flags lsy_flags;
123
  struct symbol_flags lsy_flags;
125
 
124
 
126
  /* The symbol section.  This also serves as a flag.  If this is
125
  /* The symbol section.  This also serves as a flag.  If this is
127
     reg_section, then this symbol has been converted into a regular
126
     reg_section, then this symbol has been converted into a regular
128
     symbol, and lsy_sym points to it.  */
127
     symbol, and lsy_sym points to it.  */
129
  segT lsy_section;
128
  segT lsy_section;
130
 
129
 
131
  /* The symbol name.  */
130
  /* The symbol name.  */
132
  const char *lsy_name;
131
  const char *lsy_name;
133
 
132
 
134
  /* The symbol frag or the real symbol, depending upon the value in
133
  /* The symbol frag or the real symbol, depending upon the value in
135
     lsy_section.  */
134
     lsy_section.  */
136
  union
135
  union
137
  {
136
  {
138
    fragS *lsy_frag;
137
    fragS *lsy_frag;
139
    symbolS *lsy_sym;
138
    symbolS *lsy_sym;
140
  } u;
139
  } u;
141
 
140
 
142
  /* The value of the symbol.  */
141
  /* The value of the symbol.  */
143
  valueT lsy_value;
142
  valueT lsy_value;
144
 
143
 
145
#ifdef TC_LOCAL_SYMFIELD_TYPE
144
#ifdef TC_LOCAL_SYMFIELD_TYPE
146
  TC_LOCAL_SYMFIELD_TYPE lsy_tc;
145
  TC_LOCAL_SYMFIELD_TYPE lsy_tc;
147
#endif
146
#endif
148
};
147
};
149
 
148
 
150
#define local_symbol_converted_p(l) ((l)->lsy_section == reg_section)
149
#define local_symbol_converted_p(l) ((l)->lsy_section == reg_section)
151
#define local_symbol_mark_converted(l) ((l)->lsy_section = reg_section)
150
#define local_symbol_mark_converted(l) ((l)->lsy_section = reg_section)
152
#define local_symbol_resolved_p(l) ((l)->lsy_flags.sy_resolved)
151
#define local_symbol_resolved_p(l) ((l)->lsy_flags.sy_resolved)
153
#define local_symbol_mark_resolved(l) ((l)->lsy_flags.sy_resolved = 1)
152
#define local_symbol_mark_resolved(l) ((l)->lsy_flags.sy_resolved = 1)
154
#define local_symbol_get_frag(l) ((l)->u.lsy_frag)
153
#define local_symbol_get_frag(l) ((l)->u.lsy_frag)
155
#define local_symbol_set_frag(l, f) ((l)->u.lsy_frag = (f))
154
#define local_symbol_set_frag(l, f) ((l)->u.lsy_frag = (f))
156
#define local_symbol_get_real_symbol(l) ((l)->u.lsy_sym)
155
#define local_symbol_get_real_symbol(l) ((l)->u.lsy_sym)
157
#define local_symbol_set_real_symbol(l, s) ((l)->u.lsy_sym = (s))
156
#define local_symbol_set_real_symbol(l, s) ((l)->u.lsy_sym = (s))
158
 
157
 
159
#endif /* __struc_symbol_h__ */
158
#endif /* __struc_symbol_h__ */