struc-symbol.h revision 33965
1/* struct_symbol.h - Internal symbol structure
2   Copyright (C) 1987, 1992, 1993, 1994 Free Software Foundation, Inc.
3
4   This file is part of GAS, the GNU Assembler.
5
6   GAS is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   GAS is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with GAS; see the file COPYING.  If not, write to
18   the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
19
20#ifndef __struc_symbol_h__
21#define __struc_symbol_h__
22
23#ifdef BFD_ASSEMBLER
24/* The BFD code wants to walk the list in both directions.  */
25#undef  SYMBOLS_NEED_BACKPOINTERS
26#define SYMBOLS_NEED_BACKPOINTERS
27#endif
28
29/* our version of an nlist node */
30struct symbol
31{
32#ifndef BFD_ASSEMBLER
33  /* The (4-origin) position of sy_name in the symbol table of the object
34     file.  This will be 0 for (nameless) .stabd symbols.
35
36     Not used until write_object_file() time. */
37  unsigned long sy_name_offset;
38
39  /* What we write in .o file (if permitted).  */
40  obj_symbol_type sy_symbol;
41
42  /* The 24 bit symbol number.  Symbol numbers start at 0 and are unsigned. */
43  long sy_number;
44#else
45  /* BFD symbol */
46  asymbol *bsym;
47#endif
48
49  /* The value of the symbol.  */
50  expressionS sy_value;
51
52  /* Forwards and (optionally) backwards chain pointers.  */
53  struct symbol *sy_next;
54#ifdef SYMBOLS_NEED_BACKPOINTERS
55  struct symbol *sy_previous;
56#endif /* SYMBOLS_NEED_BACKPOINTERS */
57
58  /* Pointer to the frag this symbol is attached to, if any.
59     Otherwise, NULL.  */
60  struct frag *sy_frag;
61
62  unsigned int written : 1;
63  /* Whether symbol value has been completely resolved (used during
64     final pass over symbol table).  */
65  unsigned int sy_resolved : 1;
66  /* Whether the symbol value is currently being resolved (used to
67     detect loops in symbol dependencies).  */
68  unsigned int sy_resolving : 1;
69  /* Whether the symbol value is used in a reloc.  This is used to
70     ensure that symbols used in relocs are written out, even if they
71     are local and would otherwise not be.  */
72  unsigned int sy_used_in_reloc : 1;
73
74  /* Whether the symbol is used as an operand or in an expression.
75     NOTE:  Not all the backends keep this information accurate;
76     backends which use this bit are responsible for setting it when
77     a symbol is used in backend routines.  */
78  unsigned int sy_used : 1;
79
80  /* This is set if the symbol is defined in an MRI common section.
81     We handle such sections as single common symbols, so symbols
82     defined within them must be treated specially by the relocation
83     routines.  */
84  unsigned int sy_mri_common : 1;
85
86#ifdef OBJ_SYMFIELD_TYPE
87  OBJ_SYMFIELD_TYPE sy_obj;
88#endif
89
90#ifdef TC_SYMFIELD_TYPE
91  TC_SYMFIELD_TYPE sy_tc;
92#endif
93
94#ifdef TARGET_SYMBOL_FIELDS
95  TARGET_SYMBOL_FIELDS
96#endif
97};
98
99typedef struct symbol symbolS;
100
101#ifndef WORKING_DOT_WORD
102struct broken_word
103  {
104    /* Linked list -- one of these structures per ".word x-y+C"
105       expression.  */
106    struct broken_word *next_broken_word;
107    /* Which frag is this broken word in?  */
108    fragS *frag;
109    /* Where in the frag is it?  */
110    char *word_goes_here;
111    /* Where to add the break.  */
112    fragS *dispfrag;		/* where to add the break */
113    /* Operands of expression.  */
114    symbolS *add;
115    symbolS *sub;
116    offsetT addnum;
117
118    int added;			/* nasty thing happend yet? */
119    /* 1: added and has a long-jump */
120    /* 2: added but uses someone elses long-jump */
121
122    /* Pointer to broken_word with a similar long-jump.  */
123    struct broken_word *use_jump;
124  };
125extern struct broken_word *broken_words;
126#endif /* ndef WORKING_DOT_WORD */
127
128/*
129 * Current means for getting from symbols to segments and vice verse.
130 * This will change for infinite-segments support (e.g. COFF).
131 */
132extern const segT N_TYPE_seg[];	/* subseg.c */
133
134#define	SEGMENT_TO_SYMBOL_TYPE(seg)  ( seg_N_TYPE [(int) (seg)] )
135extern const short seg_N_TYPE[];/* subseg.c */
136
137#define	N_REGISTER	30	/* Fake N_TYPE value for SEG_REGISTER */
138
139void symbol_clear_list_pointers PARAMS ((symbolS * symbolP));
140
141#ifdef SYMBOLS_NEED_BACKPOINTERS
142
143void symbol_insert PARAMS ((symbolS * addme, symbolS * target,
144			    symbolS ** rootP, symbolS ** lastP));
145void symbol_remove PARAMS ((symbolS * symbolP, symbolS ** rootP,
146			    symbolS ** lastP));
147
148#define symbol_previous(s) ((s)->sy_previous)
149
150#endif /* SYMBOLS_NEED_BACKPOINTERS */
151
152void verify_symbol_chain PARAMS ((symbolS * rootP, symbolS * lastP));
153void verify_symbol_chain_2 PARAMS ((symbolS * symP));
154
155void symbol_append PARAMS ((symbolS * addme, symbolS * target,
156			    symbolS ** rootP, symbolS ** lastP));
157
158#define symbol_next(s)	((s)->sy_next)
159
160#endif /* __struc_symbol_h__ */
161
162/* end of struc-symbol.h */
163