* as.h: Replace flagseen with separate variables.
[external/binutils.git] / gas / config / obj-aout.h
1 /* obj-aout.h, a.out object file format for gas, the assembler.
2    Copyright (C) 1989, 1990, 1991, 1992, 1993 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
8    published by the Free Software Foundation; either version 2,
9    or (at your option) any later version.
10
11    GAS is distributed in the hope that it will be useful, but
12    WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
14    the GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public
17    License along with GAS; see the file COPYING.  If not, write
18    to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 /* Tag to validate a.out object file format processing */
21 #define OBJ_AOUT 1
22
23 #include "targ-cpu.h"
24
25 #ifdef BFD_ASSEMBLER
26
27 #include "../bfd/libaout.h"
28
29 #ifndef TARGET_FORMAT
30 /* #define TARGET_FORMAT "a.out" / * There is no "a.out" target.  */
31 #endif
32
33 #else /* ! BFD_ASSEMBLER */
34
35 #ifndef VMS
36 #include "aout_gnu.h"           /* Needed to define struct nlist. Sigh. */
37 #else
38 #include "a_out.h"
39 #endif
40
41 #ifndef AOUT_MACHTYPE
42 #define AOUT_MACHTYPE 0
43 #endif /* AOUT_MACHTYPE */
44
45 extern const short seg_N_TYPE[];
46 extern const segT N_TYPE_seg[];
47
48 #ifndef DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE
49 #define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE    (OMAGIC)
50 #endif /* DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE */
51
52 #endif /* ! BFD_ASSEMBLER */
53
54 /* SYMBOL TABLE */
55 /* Symbol table entry data type */
56
57 typedef struct nlist obj_symbol_type;   /* Symbol table entry */
58
59 /* Symbol table macros and constants */
60
61 #ifdef BFD_ASSEMBLER
62
63 #define S_SET_OTHER(S,V)                (aout_symbol((S)->bsym)->other = (V))
64 #define S_SET_TYPE(S,T)                 (aout_symbol((S)->bsym)->type = (T))
65 #define S_SET_DESC(S,D)                 (aout_symbol((S)->bsym)->desc = (D))
66 #define S_GET_OTHER(S)                  (aout_symbol((S)->bsym)->other)
67 #define S_GET_TYPE(S)                   (aout_symbol((S)->bsym)->type)
68 #define S_GET_DESC(S)                   (aout_symbol((S)->bsym)->desc)
69
70 asection *text_section, *data_section, *bss_section;
71
72 #define obj_frob_symbol(S,PUNT) obj_aout_frob_symbol (S, &PUNT)
73 #define obj_frob_file()         obj_aout_frob_file ()
74 extern void obj_aout_frob_symbol PARAMS ((struct symbol *, int *));
75 extern void obj_aout_frob_file PARAMS ((void));
76
77 #define obj_sec_sym_ok_for_reloc(SEC)   (1)
78
79 #else
80
81 /*
82  *  Macros to extract information from a symbol table entry.
83  *  This syntaxic indirection allows independence regarding a.out or coff.
84  *  The argument (s) of all these macros is a pointer to a symbol table entry.
85  */
86
87 /* True if the symbol is external */
88 #define S_IS_EXTERNAL(s)        ((s)->sy_symbol.n_type & N_EXT)
89
90 /* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT */
91 #define S_IS_DEFINED(s)         ((S_GET_TYPE(s) != N_UNDF) || (S_GET_OTHER(s) != 0) || (S_GET_DESC(s) != 0))
92
93 #define S_IS_REGISTER(s)        ((s)->sy_symbol.n_type == N_REGISTER)
94
95 /* True if a debug special symbol entry */
96 #define S_IS_DEBUG(s)           ((s)->sy_symbol.n_type & N_STAB)
97 /* True if a symbol is local symbol name */
98 /* A symbol name whose name begin with ^A is a gas internal pseudo symbol
99    nameless symbols come from .stab directives. */
100 #define S_IS_LOCAL(s)           (S_GET_NAME(s) && \
101                                  !S_IS_DEBUG(s) && \
102                                  (S_GET_NAME(s)[0] == '\001' || \
103                                   (S_LOCAL_NAME(s) && !flag_keep_locals)))
104 /* True if a symbol is not defined in this file */
105 #define S_IS_EXTERN(s)          ((s)->sy_symbol.n_type & N_EXT)
106 /* True if the symbol has been generated because of a .stabd directive */
107 #define S_IS_STABD(s)           (S_GET_NAME(s) == (char *)0)
108
109 /* Accessors */
110 /* The name of the symbol */
111 #define S_GET_NAME(s)           ((s)->sy_symbol.n_un.n_name)
112 /* The pointer to the string table */
113 #define S_GET_OFFSET(s)         ((s)->sy_symbol.n_un.n_strx)
114 /* The type of the symbol */
115 #define S_GET_TYPE(s)           ((s)->sy_symbol.n_type & N_TYPE)
116 /* The numeric value of the segment */
117 #define S_GET_SEGMENT(s)        (N_TYPE_seg[S_GET_TYPE(s)])
118 /* The n_other expression value */
119 #define S_GET_OTHER(s)          ((s)->sy_symbol.n_other)
120 /* The n_desc expression value */
121 #define S_GET_DESC(s)           ((s)->sy_symbol.n_desc)
122
123 /* Modifiers */
124 /* Assume that a symbol cannot be simultaneously in more than on segment */
125 /* set segment */
126 #define S_SET_SEGMENT(s,seg)    ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type|=SEGMENT_TO_SYMBOL_TYPE(seg))
127 /* The symbol is external */
128 #define S_SET_EXTERNAL(s)       ((s)->sy_symbol.n_type |= N_EXT)
129 /* The symbol is not external */
130 #define S_CLEAR_EXTERNAL(s)     ((s)->sy_symbol.n_type &= ~N_EXT)
131 /* Set the name of the symbol */
132 #define S_SET_NAME(s,v)         ((s)->sy_symbol.n_un.n_name = (v))
133 /* Set the offset in the string table */
134 #define S_SET_OFFSET(s,v)       ((s)->sy_symbol.n_un.n_strx = (v))
135 /* Set the n_type field */
136 #define S_SET_TYPE(s,t)         ((s)->sy_symbol.n_type = (t))
137 /* Set the n_other expression value */
138 #define S_SET_OTHER(s,v)        ((s)->sy_symbol.n_other = (v))
139 /* Set the n_desc expression value */
140 #define S_SET_DESC(s,v)         ((s)->sy_symbol.n_desc = (v))
141
142 /* File header macro and type definition */
143
144 #define H_GET_FILE_SIZE(h)      (H_GET_HEADER_SIZE(h) \
145                                  + H_GET_TEXT_SIZE(h) \
146                                  + H_GET_DATA_SIZE(h) \
147                                  + H_GET_SYMBOL_TABLE_SIZE(h) \
148                                  + H_GET_TEXT_RELOCATION_SIZE(h) \
149                                  + H_GET_DATA_RELOCATION_SIZE(h) \
150                                  + H_GET_STRING_SIZE(h))
151
152 #define H_GET_HEADER_SIZE(h)            (EXEC_BYTES_SIZE)
153 #define H_GET_TEXT_SIZE(h)              ((h)->header.a_text)
154 #define H_GET_DATA_SIZE(h)              ((h)->header.a_data)
155 #define H_GET_BSS_SIZE(h)               ((h)->header.a_bss)
156 #define H_GET_TEXT_RELOCATION_SIZE(h)   ((h)->header.a_trsize)
157 #define H_GET_DATA_RELOCATION_SIZE(h)   ((h)->header.a_drsize)
158 #define H_GET_SYMBOL_TABLE_SIZE(h)      ((h)->header.a_syms)
159 #define H_GET_ENTRY_POINT(h)            ((h)->header.a_entry)
160 #define H_GET_STRING_SIZE(h)            ((h)->string_table_size)
161 #define H_GET_LINENO_SIZE(h)            (0)
162
163 #define H_GET_DYNAMIC(h)                ((h)->header.a_info >> 31)
164 #define H_GET_VERSION(h)                (((h)->header.a_info >> 24) & 0x7f)
165 #define H_GET_MACHTYPE(h)               (((h)->header.a_info >> 16) & 0xff)
166 #define H_GET_MAGIC_NUMBER(h)           ((h)->header.a_info & 0xffff)
167
168 #define H_SET_DYNAMIC(h,v)              ((h)->header.a_info = (((v) << 31) \
169                                                                | (H_GET_VERSION(h) << 24) \
170                                                                | (H_GET_MACHTYPE(h) << 16) \
171                                                                | (H_GET_MAGIC_NUMBER(h))))
172
173 #define H_SET_VERSION(h,v)              ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
174                                                                | ((v) << 24) \
175                                                                | (H_GET_MACHTYPE(h) << 16) \
176                                                                | (H_GET_MAGIC_NUMBER(h))))
177
178 #define H_SET_MACHTYPE(h,v)             ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
179                                                                | (H_GET_VERSION(h) << 24) \
180                                                                | ((v) << 16) \
181                                                                | (H_GET_MAGIC_NUMBER(h))))
182
183 #define H_SET_MAGIC_NUMBER(h,v)         ((h)->header.a_info = ((H_GET_DYNAMIC(h) << 31) \
184                                                                | (H_GET_VERSION(h) << 24) \
185                                                                | (H_GET_MACHTYPE(h) << 16) \
186                                                                | ((v))))
187
188 #define H_SET_TEXT_SIZE(h,v)            ((h)->header.a_text = md_section_align(SEG_TEXT, (v)))
189 #define H_SET_DATA_SIZE(h,v)            ((h)->header.a_data = md_section_align(SEG_DATA, (v)))
190 #define H_SET_BSS_SIZE(h,v)             ((h)->header.a_bss = md_section_align(SEG_BSS, (v)))
191
192 #define H_SET_RELOCATION_SIZE(h,t,d)    (H_SET_TEXT_RELOCATION_SIZE((h),(t)),\
193                                          H_SET_DATA_RELOCATION_SIZE((h),(d)))
194
195 #define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v))
196 #define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v))
197 #define H_SET_SYMBOL_TABLE_SIZE(h,v)    ((h)->header.a_syms = (v) * 12)
198
199 #define H_SET_ENTRY_POINT(h,v)          ((h)->header.a_entry = (v))
200 #define H_SET_STRING_SIZE(h,v)          ((h)->string_table_size = (v))
201
202 typedef struct
203   {
204     struct exec header;         /* a.out header */
205     long string_table_size;     /* names + '\0' + sizeof(int) */
206   }
207
208 object_headers;
209
210 /* line numbering stuff. */
211 #define OBJ_EMIT_LINENO(a, b, c)        {;}
212
213 struct fix;
214 void tc_aout_fix_to_chars PARAMS ((char *where, struct fix *fixP, relax_addressT segment_address));
215
216 #endif
217
218 #define obj_symbol_new_hook(s)  {;}
219
220 #define EMIT_SECTION_SYMBOLS            0
221
222 /* end of obj-aout.h */