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. */
22 * I think this stuff is largely out of date. xoxorich.
24 * CAPITALISED names are #defined.
25 * "lowercaseH" is #defined if "lowercase.h" has been #include-d.
26 * "lowercaseT" is a typedef of "lowercase" objects.
27 * "lowercaseP" is type "pointer to object of type 'lowercase'".
28 * "lowercaseS" is typedef struct ... lowercaseS.
30 * #define DEBUG to enable all the "know" assertion tests.
31 * #define SUSPECT when debugging hash code.
32 * #define COMMON as "extern" for all modules except one, where you #define
34 * If TEST is #defined, then we are testing a module: #define COMMON as "".
37 /* These #defines are for parameters of entire assembler. */
39 #define DEBUG /* temporary */
40 /* These #includes are for type definitions etc. */
56 #define __LINE__ "unknown"
60 #define __FILE__ "unknown"
63 #define obstack_chunk_alloc xmalloc
64 #define obstack_chunk_free xfree
68 #define BAD_CASE(value) \
70 as_fatal("Case value %d unexpected at line %d of file \"%s\"\n", \
71 value, __LINE__, __FILE__); \
75 /* These are assembler-wide concepts */
78 extern bfd
*stdoutput
;
83 #define COMMON /* declare our COMMONs storage here. */
85 #define COMMON extern /* our commons live elswhere */
88 /* COMMON now defined */
92 #define know(p) assert(p) /* Verify our assumptions! */
93 #endif /* not yet defined */
95 #define know(p) /* know() checks are no-op.ed */
98 #if defined (BROKEN_ASSERT) && !defined (NDEBUG)
99 /* Used on machines where the "assert" macro is buggy. (For example, on the
100 RS/6000, Reiser-cpp substitution is done to put the condition into a
101 string, so if the condition contains a string, parse errors result.) If
102 the condition fails, just drop core file. */
104 #define assert(p) ((p) ? 0 : (abort (), 0))
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.*/
117 #ifndef BFD_ASSEMBLER
119 * This table describes the use of segments as EXPRESSION types.
121 * X_seg X_add_symbol X_subtract_symbol X_add_number
122 * SEG_ABSENT no (legal) expression
123 * SEG_PASS1 no (defined) "
124 * SEG_BIG * > 32 bits const.
130 * SEG_DIFFERENCE 0 * 0
133 * The blank fields MUST be 0, and are nugatory.
134 * The '0' fields MAY be 0. The '*' fields MAY NOT be 0.
136 * SEG_BIG: X_add_number is < 0 if the result is in
137 * generic_floating_point_number. The value is -'c' where c is the
138 * character that introduced the constant. e.g. "0f6.9" will have -'f'
139 * as a X_add_number value.
140 * X_add_number > 0 is a count of how many littlenums it took to
141 * represent a bignum.
143 * If segments of both symbols are known, they are the same segment.
144 * X_add_symbol != X_sub_symbol (then we just cancel them, => SEG_ABSOLUTE).
150 #define N_SEGMENTS 10
151 #define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E9)
152 #define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9
153 #define SEG_TEXT SEG_E0
154 #define SEG_DATA SEG_E1
155 #define SEG_BSS SEG_E2
158 #define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS)
159 #define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS
167 SEG_ABSENT
, /* Mythical Segment (absent): NO expression seen. */
168 SEG_PASS1
, /* Mythical Segment: Need another pass. */
169 SEG_GOOF
, /* Only happens if AS has a logic error. */
170 /* Invented so we don't crash printing */
171 /* error message involving weird segment. */
172 SEG_BIG
, /* Bigger than 32 bits constant. */
173 SEG_DIFFERENCE
, /* Mythical Segment: absolute difference. */
174 SEG_DEBUG
, /* Debug segment */
175 SEG_NTV
, /* Transfert vector preload segment */
176 SEG_PTV
, /* Transfert vector postload segment */
177 SEG_REGISTER
, /* Mythical: a register-valued expression */
180 #define SEG_MAXIMUM_ORDINAL (SEG_REGISTER)
182 typedef asection
*segT
;
183 #define SEG_NORMAL(SEG) ((SEG) != absolute_section \
184 && (SEG) != undefined_section \
185 && (SEG) != big_section \
186 && (SEG) != reg_section \
187 && (SEG) != pass1_section \
188 && (SEG) != diff_section \
189 && (SEG) != absent_section)
193 /* What subseg we are accreting now? */
194 COMMON subsegT now_subseg
;
196 /* Segment our instructions emit to. */
200 #define segment_name(SEG) bfd_get_section_name (stdoutput, SEG)
202 extern char *CONST seg_name
[];
203 #define segment_name(SEG) seg_name[(int) (SEG)]
206 #ifndef BFD_ASSEMBLER
207 extern int section_alignment
[];
211 extern segT big_section
, reg_section
, pass1_section
;
212 extern segT diff_section
, absent_section
;
213 /* Shouldn't these be eliminated someday? */
214 extern segT text_section
, data_section
, bss_section
;
215 #define absolute_section (&bfd_abs_section)
216 #define undefined_section (&bfd_und_section)
218 #define big_section SEG_BIG
219 #define reg_section SEG_REGISTER
220 #define pass1_section SEG_PASS1
221 #define diff_section SEG_DIFFERENCE
222 #define absent_section SEG_ABSENT
223 #define text_section SEG_TEXT
224 #define data_section SEG_DATA
225 #define bss_section SEG_BSS
226 #define absolute_section SEG_ABSOLUTE
227 #define undefined_section SEG_UNKNOWN
232 typedef enum _relax_state
234 /* Variable chars to be repeated fr_offset times.
235 Fr_symbol unused. Used with fr_offset == 0 for a
236 constant length frag. */
239 /* Align: Fr_offset: power of 2. 1 variable char: fill character. */
242 /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
246 rs_machine_dependent
,
248 #ifndef WORKING_DOT_WORD
254 /* typedef unsigned char relax_substateT; */
255 /* JF this is more likely to leave the end of a struct frag on an align
256 boundry. Be very careful with this. */
257 typedef unsigned long relax_substateT
;
259 /* Enough bits for address, but still an integer type.
260 Could be a problem, cross-assembling for 64-bit machines. */
261 typedef unsigned long relax_addressT
;
267 * A code fragment (frag) is some known number of chars, followed by some
268 * unknown number of chars. Typically the unknown number of chars is an
269 * instruction address whose size is yet unknown. We always know the greatest
270 * possible size the unknown number of chars may become, and reserve that
271 * much room at the end of the frag.
272 * Once created, frags do not change address during assembly.
273 * We chain the frags in (a) forward-linked list(s). The object-file address
274 * of the 1st char of a frag is generally not known until after relax().
275 * Many things at assembly time describe an address by {object-file-address
276 * of a particular frag}+offset.
278 BUG: it may be smarter to have a single pointer off to various different
279 notes for different frag kinds. See how code pans
283 /* Object file address. */
284 unsigned long fr_address
;
285 /* Chain forward; ascending address order. Rooted in frch_root. */
286 struct frag
*fr_next
;
288 /* (Fixed) number of chars we know we have. May be 0. */
290 /* (Variable) number of chars after above. May be 0. */
292 /* For variable-length tail. */
293 struct symbol
*fr_symbol
;
294 /* For variable-length tail. */
296 /* Points to opcode low addr byte, for relaxation. */
300 struct list_info_struct
*line
;
303 /* What state is my tail in? */
304 relax_stateT fr_type
;
305 relax_substateT fr_subtype
;
307 /* These are needed only on the NS32K machines */
308 char fr_pcrel_adjust
;
312 One day we will compile fr_literal[0]. */
316 #define SIZEOF_STRUCT_FRAG \
317 ((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
318 /* We want to say fr_literal[0] above. */
320 typedef struct frag fragS
;
322 /* Current frag we are building. This frag is incomplete. It is, however,
323 included in frchain_now. The fr_fix field is bogus; instead, use:
324 obstack_next_free(&frags)-frag_now->fr_literal. */
325 COMMON fragS
*frag_now
;
326 #define frag_now_fix() (obstack_next_free (&frags) - frag_now->fr_literal)
328 /* For foreign-segment symbol fixups. */
329 COMMON fragS zero_address_frag
;
330 /* For local common (N_BSS segment) fixups. */
331 COMMON fragS bss_address_frag
;
333 /* main program "as.c" (command arguments etc) */
335 /* ['x'] TRUE if "-x" seen. */
336 COMMON
char flagseen
[128];
337 COMMON
unsigned char flag_readonly_data_in_text
;
338 COMMON
unsigned char flag_suppress_warnings
;
339 COMMON
unsigned char flag_always_generate_output
;
341 /* name of emitted object file */
342 COMMON
char *out_file_name
;
344 /* TRUE if we need a second pass. */
345 COMMON
int need_pass_2
;
347 /* TRUE if we should do no relaxing, and
348 leave lots of padding. */
349 COMMON
int linkrelax
;
353 /* assembler mnemonic, lower case, no '.' */
356 void (*poc_handler
) ();
357 /* Value to pass to handler */
361 typedef struct _pseudo_type pseudo_typeS
;
363 #ifdef BFD_ASSEMBLER_xxx
368 struct lineno_struct
*next
;
370 typedef struct lineno_struct lineno
;
373 #if defined (__STDC__) && !defined(NO_STDARG)
376 /* for use with -Wformat */
377 #define PRINTF_LIKE(FCN) void FCN (const char *Format, ...) \
378 __attribute__ ((format (printf, 1, 2)))
379 #else /* ANSI C with stdarg, but not GNU C */
380 #define PRINTF_LIKE(FCN) void FCN (const char *Format, ...)
382 #else /* not ANSI C, or not stdarg */
383 #define PRINTF_LIKE(FCN) void FCN ()
386 PRINTF_LIKE (as_bad
);
387 PRINTF_LIKE (as_fatal
);
388 PRINTF_LIKE (as_tsktsk
);
389 PRINTF_LIKE (as_warn
);
391 int had_errors
PARAMS ((void));
392 int had_warnings
PARAMS ((void));
394 char *app_push
PARAMS ((void));
395 char *atof_ieee
PARAMS ((char *str
, int what_kind
, LITTLENUM_TYPE
* words
));
396 char *input_scrub_include_file
PARAMS ((char *filename
, char *position
));
397 char *input_scrub_new_file
PARAMS ((char *filename
));
398 char *input_scrub_next_buffer
PARAMS ((char **bufp
));
399 char *strstr
PARAMS ((const char *s
, const char *wanted
));
400 char *xmalloc
PARAMS ((long size
));
401 char *xrealloc
PARAMS ((char *ptr
, long n
));
402 int do_scrub_next_char
PARAMS ((int (*get
) (), void (*unget
) ()));
403 int gen_to_words
PARAMS ((LITTLENUM_TYPE
* words
, int precision
,
404 long exponent_bits
));
405 int had_err
PARAMS ((void));
406 int had_errors
PARAMS ((void));
407 int had_warnings
PARAMS ((void));
408 int ignore_input
PARAMS ((void));
409 int scrub_from_file
PARAMS ((void));
410 int scrub_from_file
PARAMS ((void));
411 int scrub_from_string
PARAMS ((void));
412 int seen_at_least_1_file
PARAMS ((void));
413 void app_pop
PARAMS ((char *arg
));
414 void as_howmuch
PARAMS ((FILE * stream
));
415 void as_perror
PARAMS ((char *gripe
, char *filename
));
416 void as_where
PARAMS ((void));
417 void bump_line_counters
PARAMS ((void));
418 void do_scrub_begin
PARAMS ((void));
419 void input_scrub_begin
PARAMS ((void));
420 void input_scrub_close
PARAMS ((void));
421 void input_scrub_end
PARAMS ((void));
422 void int_to_gen
PARAMS ((long x
));
423 void new_logical_line
PARAMS ((char *fname
, int line_number
));
424 void scrub_to_file
PARAMS ((int ch
));
425 void scrub_to_string
PARAMS ((int ch
));
426 void subsegs_begin
PARAMS ((void));
427 void subseg_change
PARAMS ((segT seg
, int subseg
));
429 segT subseg_new
PARAMS ((char *name
, subsegT subseg
));
430 void subseg_set
PARAMS ((segT seg
, subsegT subseg
));
432 void subseg_new
PARAMS ((segT seg
, subsegT subseg
));
435 /* this one starts the chain of target dependant headers */
436 #include "targ-env.h"
438 /* these define types needed by the interfaces */
439 #include "struc-symbol.h"