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. */
23 * I think this stuff is largely out of date. xoxorich.
25 * CAPITALISED names are #defined.
26 * "lowercaseH" is #defined if "lowercase.h" has been #include-d.
27 * "lowercaseT" is a typedef of "lowercase" objects.
28 * "lowercaseP" is type "pointer to object of type 'lowercase'".
29 * "lowercaseS" is typedef struct ... lowercaseS.
31 * #define DEBUG to enable all the "know" assertion tests.
32 * #define SUSPECT when debugging hash code.
33 * #define COMMON as "extern" for all modules except one, where you #define
35 * If TEST is #defined, then we are testing a module: #define COMMON as "".
38 /* These #defines are for parameters of entire assembler. */
40 /* For some systems, this is required to be first. */
41 #include "../libiberty/alloca-conf.h"
43 /* Now, tend to the rest of the configuration. */
46 /* System include files first... */
60 #ifdef HAVE_SYS_TYPES_H
61 /* for size_t, pid_t */
62 #include <sys/types.h>
65 /* Some systems do declare this, but this seems to be the universal
66 declaration, though the parameter type varies. (It ought to use
67 `const' but many systems prototype it without.) Include it here
68 for systems that don't declare it. If conflicts arise, just add
69 another autoconf test... */
70 extern char *strdup (/* const char * */);
73 /* The first getopt value for machine-independent long options.
74 150 isn't special; it's just an arbitrary non-ASCII char value. */
75 #define OPTION_STD_BASE 150
76 /* The first getopt value for machine-dependent long options.
77 170 gives the standard options room to grow. */
78 #define OPTION_MD_BASE 170
83 /* Handle lossage with assert.h. */
86 #else /* BROKEN_ASSERT */
88 #define assert(p) ((p) ? 0 : (abort(), 0))
90 #define assert(p) ((p), 0)
92 #endif /* BROKEN_ASSERT */
95 /* Now GNU header files... */
101 #ifdef WANT_FOPEN_BIN
102 #include "fopen-bin.h"
104 #include "fopen-same.h"
107 /* This doesn't get taken care of by ansidecl.h. */
108 #if !defined (__STDC__) && !defined (volatile)
112 /* This doesn't get taken care of anywhere. */
113 #if !defined (__GNUC__) && !defined (inline)
117 /* Other stuff from config.h. */
118 #ifdef NEED_MALLOC_DECLARATION
119 extern PTR malloc ();
120 extern PTR realloc ();
122 #ifdef NEED_FREE_DECLARATION
127 /* This one doesn't get declared, but we're using it anyways. This
128 should be fixed -- either it's part of the external interface or
130 extern PTR bfd_alloc_by_size_t PARAMS ((bfd *abfd, size_t sz));
133 /* Make Saber happier on obstack.h. */
136 #define __PTR_TO_INT(P) ((int)(P))
138 #define __INT_TO_PTR(P) ((char *)(P))
142 #define __LINE__ "unknown"
143 #endif /* __LINE__ */
146 #define __FILE__ "unknown"
147 #endif /* __FILE__ */
156 #endif /* ! __STDC__ */
158 #if !defined (__GNUC__) && !defined (inline)
164 #include "fopen-bin.h"
166 #include "fopen-same.h"
170 #define obstack_chunk_alloc xmalloc
171 #define obstack_chunk_free xfree
175 #define BAD_CASE(val) \
177 as_fatal("Case value %ld unexpected at line %d of file \"%s\"\n", \
178 (long) val, __LINE__, __FILE__); \
181 /* Version 2.1 of Solaris had problems with this declaration, but I
182 think that bug has since been fixed. If it causes problems on your
183 system, just delete it. */
184 extern char *strstr ();
188 /* These are assembler-wide concepts */
191 extern bfd *stdoutput;
192 typedef bfd_vma addressT;
193 typedef bfd_signed_vma offsetT;
195 typedef unsigned long addressT;
196 typedef long offsetT;
199 /* Type of symbol value, etc. For use in prototypes. */
200 typedef addressT valueT;
204 #define COMMON /* declare our COMMONs storage here. */
206 #define COMMON extern /* our commons live elswhere */
209 /* COMMON now defined */
213 #define know(p) assert(p) /* Verify our assumptions! */
214 #endif /* not yet defined */
216 #define know(p) /* know() checks are no-op.ed */
222 * Supplies sanitised buffers to read.c.
223 * Also understands printing line-number part of error messages.
227 /* subsegs.c Sub-segments. Also, segment(=expression type)s.*/
229 #ifndef BFD_ASSEMBLER
233 #define N_SEGMENTS 10
234 #define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E9)
235 #define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9
236 #define SEG_TEXT SEG_E0
237 #define SEG_DATA SEG_E1
238 #define SEG_BSS SEG_E2
241 #define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS)
242 #define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS
250 SEG_GOOF, /* Only happens if AS has a logic error. */
251 /* Invented so we don't crash printing */
252 /* error message involving weird segment. */
253 SEG_EXPR, /* Intermediate expression values. */
254 SEG_DEBUG, /* Debug segment */
255 SEG_NTV, /* Transfert vector preload segment */
256 SEG_PTV, /* Transfert vector postload segment */
257 SEG_REGISTER /* Mythical: a register-valued expression */
260 #define SEG_MAXIMUM_ORDINAL (SEG_REGISTER)
262 typedef asection *segT;
263 #define SEG_NORMAL(SEG) ((SEG) != absolute_section \
264 && (SEG) != undefined_section \
265 && (SEG) != reg_section \
266 && (SEG) != expr_section)
270 /* What subseg we are accreting now? */
271 COMMON subsegT now_subseg;
273 /* Segment our instructions emit to. */
277 #define segment_name(SEG) bfd_get_section_name (stdoutput, SEG)
279 extern char *const seg_name[];
280 #define segment_name(SEG) seg_name[(int) (SEG)]
283 #ifndef BFD_ASSEMBLER
284 extern int section_alignment[];
288 extern segT reg_section, expr_section;
289 /* Shouldn't these be eliminated someday? */
290 extern segT text_section, data_section, bss_section;
291 #define absolute_section bfd_abs_section_ptr
292 #define undefined_section bfd_und_section_ptr
294 #define reg_section SEG_REGISTER
295 #define expr_section SEG_EXPR
296 #define text_section SEG_TEXT
297 #define data_section SEG_DATA
298 #define bss_section SEG_BSS
299 #define absolute_section SEG_ABSOLUTE
300 #define undefined_section SEG_UNKNOWN
305 typedef enum _relax_state
307 /* Variable chars to be repeated fr_offset times.
308 Fr_symbol unused. Used with fr_offset == 0 for a
309 constant length frag. */
312 /* Align: Fr_offset: power of 2. Variable chars: fill pattern. */
315 /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
321 #ifndef WORKING_DOT_WORD
327 /* typedef unsigned char relax_substateT; */
328 /* JF this is more likely to leave the end of a struct frag on an align
329 boundry. Be very careful with this. */
330 typedef unsigned long relax_substateT;
332 /* Enough bits for address, but still an integer type.
333 Could be a problem, cross-assembling for 64-bit machines. */
334 typedef addressT relax_addressT;
340 * A code fragment (frag) is some known number of chars, followed by some
341 * unknown number of chars. Typically the unknown number of chars is an
342 * instruction address whose size is yet unknown. We always know the greatest
343 * possible size the unknown number of chars may become, and reserve that
344 * much room at the end of the frag.
345 * Once created, frags do not change address during assembly.
346 * We chain the frags in (a) forward-linked list(s). The object-file address
347 * of the 1st char of a frag is generally not known until after relax().
348 * Many things at assembly time describe an address by {object-file-address
349 * of a particular frag}+offset.
351 BUG: it may be smarter to have a single pointer off to various different
352 notes for different frag kinds. See how code pans
356 /* Object file address. */
358 /* Chain forward; ascending address order. Rooted in frch_root. */
359 struct frag *fr_next;
361 /* (Fixed) number of chars we know we have. May be 0. */
363 /* (Variable) number of chars after above. May be 0. */
365 /* For variable-length tail. */
366 struct symbol *fr_symbol;
367 /* For variable-length tail. */
369 /* Points to opcode low addr byte, for relaxation. */
373 struct list_info_struct *line;
376 /* What state is my tail in? */
377 relax_stateT fr_type;
378 relax_substateT fr_subtype;
380 /* These are needed only on the NS32K machines */
381 char fr_pcrel_adjust;
385 One day we will compile fr_literal[0]. */
389 #define SIZEOF_STRUCT_FRAG \
390 ((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
391 /* We want to say fr_literal[0] above. */
393 typedef struct frag fragS;
395 /* Current frag we are building. This frag is incomplete. It is, however,
396 included in frchain_now. The fr_fix field is bogus; instead, use:
397 obstack_next_free(&frags)-frag_now->fr_literal. */
398 COMMON fragS *frag_now;
399 #define frag_now_fix() ((char*)obstack_next_free (&frags) - frag_now->fr_literal)
401 /* For foreign-segment symbol fixups. */
402 COMMON fragS zero_address_frag;
403 /* For local common (N_BSS segment) fixups. */
404 COMMON fragS bss_address_frag;
406 /* main program "as.c" (command arguments etc) */
408 COMMON unsigned char flag_no_comments; /* -f */
409 COMMON unsigned char flag_debug; /* -D */
410 COMMON unsigned char flag_signed_overflow_ok; /* -J */
411 COMMON unsigned char flag_warn_displacement; /* -K */
412 COMMON unsigned char flag_keep_locals; /* -L */
413 COMMON unsigned char flag_readonly_data_in_text; /* -R */
414 COMMON unsigned char flag_no_warnings; /* -W */
415 COMMON unsigned char flag_always_generate_output; /* -Z */
417 /* name of emitted object file */
418 COMMON char *out_file_name;
420 /* TRUE if we need a second pass. */
421 COMMON int need_pass_2;
423 /* TRUE if we should do no relaxing, and
424 leave lots of padding. */
425 COMMON int linkrelax;
427 /* TRUE if we should produce a listing. */
432 /* assembler mnemonic, lower case, no '.' */
435 void (*poc_handler) PARAMS ((int));
436 /* Value to pass to handler */
440 typedef struct _pseudo_type pseudo_typeS;
442 #ifdef BFD_ASSEMBLER_xxx
447 struct lineno_struct *next;
449 typedef struct lineno_struct lineno;
452 #if defined (__STDC__) && !defined(NO_STDARG)
455 /* for use with -Wformat */
456 #define PRINTF_LIKE(FCN) void FCN (const char *format, ...) \
457 __attribute__ ((format (printf, 1, 2)))
458 #define PRINTF_WHERE_LIKE(FCN) void FCN (char *file, unsigned int line, \
459 const char *format, ...) \
460 __attribute__ ((format (printf, 3, 4)))
461 #else /* ANSI C with stdarg, but not GNU C */
462 #define PRINTF_LIKE(FCN) void FCN (const char *format, ...)
463 #define PRINTF_WHERE_LIKE(FCN) void FCN (char *file, unsigned int line, \
464 const char *format, ...)
466 #else /* not ANSI C, or not stdarg */
467 #define PRINTF_LIKE(FCN) void FCN ()
468 #define PRINTF_WHERE_LIKE(FCN) void FCN ()
471 PRINTF_LIKE (as_bad);
472 PRINTF_LIKE (as_fatal);
473 PRINTF_LIKE (as_tsktsk);
474 PRINTF_LIKE (as_warn);
475 PRINTF_WHERE_LIKE (as_bad_where);
476 PRINTF_WHERE_LIKE (as_warn_where);
478 void fprint_value PARAMS ((FILE *file, addressT value));
479 void sprint_value PARAMS ((char *buf, addressT value));
481 int had_errors PARAMS ((void));
482 int had_warnings PARAMS ((void));
484 void print_version_id PARAMS ((void));
485 char *app_push PARAMS ((void));
486 char *atof_ieee PARAMS ((char *str, int what_kind, LITTLENUM_TYPE * words));
487 char *input_scrub_include_file PARAMS ((char *filename, char *position));
488 char *input_scrub_new_file PARAMS ((char *filename));
489 char *input_scrub_next_buffer PARAMS ((char **bufp));
490 PTR xmalloc PARAMS ((unsigned long size));
491 PTR xrealloc PARAMS ((PTR ptr, unsigned long n));
492 int do_scrub_next_char PARAMS ((int (*get) (void), void (*unget) (int)));
493 int gen_to_words PARAMS ((LITTLENUM_TYPE * words, int precision,
494 long exponent_bits));
495 int had_err PARAMS ((void));
496 int ignore_input PARAMS ((void));
497 int scrub_from_file PARAMS ((void));
498 int scrub_from_string PARAMS ((void));
499 int seen_at_least_1_file PARAMS ((void));
500 void app_pop PARAMS ((char *arg));
501 void as_howmuch PARAMS ((FILE * stream));
502 void as_perror PARAMS ((const char *gripe, const char *filename));
503 void as_where PARAMS ((char **namep, unsigned int *linep));
504 void bump_line_counters PARAMS ((void));
505 void do_scrub_begin PARAMS ((void));
506 void input_scrub_begin PARAMS ((void));
507 void input_scrub_close PARAMS ((void));
508 void input_scrub_end PARAMS ((void));
509 void new_logical_line PARAMS ((char *fname, int line_number));
510 void scrub_to_file PARAMS ((int ch));
511 void scrub_to_string PARAMS ((int ch));
512 void subsegs_begin PARAMS ((void));
513 void subseg_change PARAMS ((segT seg, int subseg));
514 segT subseg_new PARAMS ((const char *name, subsegT subseg));
515 segT subseg_force_new PARAMS ((const char *name, subsegT subseg));
516 void subseg_set PARAMS ((segT seg, subsegT subseg));
518 segT subseg_get PARAMS ((const char *, int));
527 valueT add_to_literal_pool PARAMS ((struct symbol *, valueT, segT, int));
530 #include "expr.h" /* Before targ-*.h */
532 /* this one starts the chain of target dependant headers */
533 #include "targ-env.h"
535 #include "struc-symbol.h"
548 /* Someday perhaps this will be selectable at run-time. */
549 #if defined (OBJ_AOUT) || defined (OBJ_BOUT)
550 #define OUTPUT_FLAVOR bfd_target_aout_flavour
553 #define OUTPUT_FLAVOR bfd_target_coff_flavour
556 #define OUTPUT_FLAVOR bfd_target_ecoff_flavour
559 #define OUTPUT_FLAVOR bfd_target_elf_flavour
561 #endif /* BFD_ASSEMBLER */