1 /* as.h - global header file
2 Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
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)
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.
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
33 #define __LINE__ "unknown"
37 #define __FILE__ "unknown"
41 * I think this stuff is largely out of date. xoxorich.
43 * CAPITALISED names are #defined.
44 * "lowercaseH" is #defined if "lowercase.h" has been #include-d.
45 * "lowercaseT" is a typedef of "lowercase" objects.
46 * "lowercaseP" is type "pointer to object of type 'lowercase'".
47 * "lowercaseS" is typedef struct ... lowercaseS.
49 * #define DEBUG to enable all the "know" assertion tests.
50 * #define SUSPECT when debugging.
51 * #define COMMON as "extern" for all modules except one, where you #define
53 * If TEST is #defined, then we are testing a module: #define COMMON as "".
56 /* These #defines are for parameters of entire assembler. */
58 /* #define SUSPECT JF remove for speed testing */
59 /* These #includes are for type definitions etc. */
64 #define obstack_chunk_alloc xmalloc
65 #define obstack_chunk_free xfree
69 #define BAD_CASE(value) \
71 as_fatal("Case value %d unexpected at line %d of file \"%s\"\n", \
72 value, __LINE__, __FILE__); \
76 /* These are assembler-wide concepts */
81 #define COMMON /* declare our COMMONs storage here. */
83 #define COMMON extern /* our commons live elswhere */
86 /* COMMON now defined */
87 #define DEBUG /* temporary */
90 /* Turn off all assertion checks, on machines where the assert macro
91 is buggy. (For example, on the RS/6000, Reiser-cpp substitution is
92 done to put the condition into a string, so if the condition contains
93 a string, parse errors result.) */
101 #define know(p) assert(p) /* Verify our assumptions! */
102 #endif /* not yet defined */
104 #define know(p) /* know() checks are no-op.ed */
110 * Supplies sanitised buffers to read.c.
111 * Also understands printing line-number part of error messages.
115 /* subsegs.c Sub-segments. Also, segment(=expression type)s.*/
118 * This table describes the use of segments as EXPRESSION types.
120 * X_seg X_add_symbol X_subtract_symbol X_add_number
121 * SEG_ABSENT no (legal) expression
122 * SEG_PASS1 no (defined) "
123 * SEG_BIG * > 32 bits const.
129 * SEG_DIFFERENCE 0 * 0
132 * The blank fields MUST be 0, and are nugatory.
133 * The '0' fields MAY be 0. The '*' fields MAY NOT be 0.
135 * SEG_BIG: X_add_number is < 0 if the result is in
136 * generic_floating_point_number. The value is -'c' where c is the
137 * character that introduced the constant. e.g. "0f6.9" will have -'f'
138 * as a X_add_number value.
139 * X_add_number > 0 is a count of how many littlenums it took to
140 * represent a bignum.
142 * If segments of both symbols are known, they are the same segment.
143 * X_add_symbol != X_sub_symbol (then we just cancel them, => SEG_ABSOLUTE).
149 #define N_SEGMENTS 10
150 #define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E9)
151 #define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9
152 #define SEG_DATA SEG_E1
153 #define SEG_TEXT SEG_E0
154 #define SEG_BSS SEG_E2
157 #define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS)
158 #define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS
166 SEG_ABSENT
, /* Mythical Segment (absent): NO expression seen. */
167 SEG_PASS1
, /* Mythical Segment: Need another pass. */
168 SEG_GOOF
, /* Only happens if AS has a logic error. */
169 /* Invented so we don't crash printing */
170 /* error message involving weird segment. */
171 SEG_BIG
, /* Bigger than 32 bits constant. */
172 SEG_DIFFERENCE
, /* Mythical Segment: absolute difference. */
173 SEG_DEBUG
, /* Debug segment */
174 SEG_NTV
, /* Transfert vector preload segment */
175 SEG_PTV
, /* Transfert vector postload segment */
176 SEG_REGISTER
, /* Mythical: a register-valued expression */
179 #define SEG_MAXIMUM_ORDINAL (SEG_REGISTER)
183 /* What subseg we are accreting now? */
184 COMMON subsegT now_subseg
;
186 /* Segment our instructions emit to. */
187 /* Only OK values are SEG_TEXT or SEG_DATA. */
190 extern char *const seg_name
[];
191 extern int section_alignment
[];
196 typedef enum _relax_state
198 /* Variable chars to be repeated fr_offset times.
199 Fr_symbol unused. Used with fr_offset == 0 for a
200 constant length frag. */
203 /* Align: Fr_offset: power of 2. 1 variable char: fill character. */
206 /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
210 rs_machine_dependent
,
212 #ifndef WORKING_DOT_WORD
218 /* typedef unsigned char relax_substateT; */
219 /* JF this is more likely to leave the end of a struct frag on an align
220 boundry. Be very careful with this. */
221 typedef unsigned long relax_substateT
;
223 /* Enough bits for address, but still an integer type.
224 Could be a problem, cross-assembling for 64-bit machines. */
225 typedef unsigned long relax_addressT
;
231 * A code fragment (frag) is some known number of chars, followed by some
232 * unknown number of chars. Typically the unknown number of chars is an
233 * instruction address whose size is yet unknown. We always know the greatest
234 * possible size the unknown number of chars may become, and reserve that
235 * much room at the end of the frag.
236 * Once created, frags do not change address during assembly.
237 * We chain the frags in (a) forward-linked list(s). The object-file address
238 * of the 1st char of a frag is generally not known until after relax().
239 * Many things at assembly time describe an address by {object-file-address
240 * of a particular frag}+offset.
242 BUG: it may be smarter to have a single pointer off to various different
243 notes for different frag kinds. See how code pans
245 struct frag
/* a code fragment */
247 /* Object file address. */
248 unsigned long fr_address
;
249 /* Chain forward; ascending address order. */
250 /* Rooted in frch_root. */
251 struct frag
*fr_next
;
253 /* (Fixed) number of chars we know we have. */
256 /* (Variable) number of chars after above. */
259 /* For variable-length tail. */
260 struct symbol
*fr_symbol
;
261 /* For variable-length tail. */
263 /*->opcode low addr byte,for relax()ation*/
265 /* What state is my tail in? */
266 relax_stateT fr_type
;
267 relax_substateT fr_subtype
;
269 /* These are needed only on the NS32K machines */
270 char fr_pcrel_adjust
;
273 struct list_info_struct
*line
;
276 One day we will compile fr_literal[0]. */
280 #define SIZEOF_STRUCT_FRAG \
281 ((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
282 /* We want to say fr_literal[0] above. */
284 typedef struct frag fragS
;
286 /* Current frag we are building. This frag is incomplete. It is, however,
287 included in frchain_now. The fr_fix field is bogus; instead, use:
288 obstack_next_free(&frags)-frag_now->fr_literal. */
289 COMMON fragS
*frag_now
;
291 /* For foreign-segment symbol fixups. */
292 COMMON fragS zero_address_frag
;
293 /* For local common (N_BSS segment) fixups. */
294 COMMON fragS bss_address_frag
;
296 /* main program "as.c" (command arguments etc) */
298 /* ['x'] TRUE if "-x" seen. */
299 COMMON
char flagseen
[128];
300 COMMON
unsigned char flag_readonly_data_in_text
;
301 COMMON
unsigned char flag_suppress_warnings
;
302 COMMON
unsigned char flag_always_generate_output
;
304 /* name of emitted object file */
305 COMMON
char *out_file_name
;
307 /* TRUE if we need a second pass. */
308 COMMON
int need_pass_2
;
310 /* TRUE if we should do no relaxing, and
311 leave lots of padding. */
312 COMMON
int linkrelax
;
316 /* assembler mnemonic, lower case, no '.' */
319 void (*poc_handler
) ();
320 /* Value to pass to handler */
324 typedef struct _pseudo_type pseudo_typeS
;
328 int had_errors
PARAMS ((void));
329 int had_warnings
PARAMS ((void));
330 void as_bad
PARAMS ((const char *Format
,...));
331 void as_fatal
PARAMS ((const char *Format
,...));
332 void as_tsktsk
PARAMS ((const char *Format
,...));
333 void as_warn
PARAMS ((const char *Format
,...));
344 #endif /* __STDC__ & !NO_STDARG */
346 char *app_push
PARAMS ((void));
347 char *atof_ieee
PARAMS ((char *str
, int what_kind
, LITTLENUM_TYPE
* words
));
348 char *input_scrub_include_file
PARAMS ((char *filename
, char *position
));
349 char *input_scrub_new_file
PARAMS ((char *filename
));
350 char *input_scrub_next_buffer
PARAMS ((char **bufp
));
351 char *strstr
PARAMS ((const char *s
, const char *wanted
));
352 char *xmalloc
PARAMS ((long size
));
353 char *xrealloc
PARAMS ((char *ptr
, long n
));
354 int do_scrub_next_char
PARAMS ((int (*get
) (), void (*unget
) ()));
355 int gen_to_words
PARAMS ((LITTLENUM_TYPE
* words
, int precision
,
356 long exponent_bits
));
357 int had_err
PARAMS ((void));
358 int had_errors
PARAMS ((void));
359 int had_warnings
PARAMS ((void));
360 int ignore_input
PARAMS ((void));
361 int scrub_from_file
PARAMS ((void));
362 int scrub_from_file
PARAMS ((void));
363 int scrub_from_string
PARAMS ((void));
364 int seen_at_least_1_file
PARAMS ((void));
365 void app_pop
PARAMS ((char *arg
));
366 void as_howmuch
PARAMS ((FILE * stream
));
367 void as_perror
PARAMS ((char *gripe
, char *filename
));
368 void as_where
PARAMS ((void));
369 void bump_line_counters
PARAMS ((void));
370 void do_scrub_begin
PARAMS ((void));
371 void input_scrub_begin
PARAMS ((void));
372 void input_scrub_close
PARAMS ((void));
373 void input_scrub_end
PARAMS ((void));
374 void int_to_gen
PARAMS ((long x
));
375 void new_logical_line
PARAMS ((char *fname
, int line_number
));
376 void scrub_to_file
PARAMS ((int ch
));
377 void scrub_to_string
PARAMS ((int ch
));
378 void subseg_change
PARAMS ((segT seg
, int subseg
));
379 void subseg_new
PARAMS ((segT seg
, subsegT subseg
));
380 void subsegs_begin
PARAMS ((void));
382 /* this one starts the chain of target dependant headers */
383 #include "targ-env.h"
385 /* these define types needed by the interfaces */
386 #include "struc-symbol.h"