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. */
55 /* Make Saber happier on obstack.h. */
58 #define __PTR_TO_INT(P) ((int)(P))
60 #define __INT_TO_PTR(P) ((char *)(P))
64 #define __LINE__ "unknown"
68 #define __FILE__ "unknown"
78 #endif /* ! __STDC__ */
80 #define obstack_chunk_alloc xmalloc
81 #define obstack_chunk_free xfree
85 #define BAD_CASE(val) \
87 as_fatal("Case value %ld unexpected at line %d of file \"%s\"\n", \
88 (long) val, __LINE__, __FILE__); \
92 /* These are assembler-wide concepts */
95 extern bfd
*stdoutput
;
96 typedef bfd_vma addressT
;
97 typedef bfd_signed_vma offsetT
;
99 typedef unsigned long addressT
;
100 typedef long offsetT
;
103 /* Type of symbol value, etc. For use in prototypes. */
104 typedef addressT valueT
;
108 #define COMMON /* declare our COMMONs storage here. */
110 #define COMMON extern /* our commons live elswhere */
113 /* COMMON now defined */
117 #define know(p) assert(p) /* Verify our assumptions! */
118 #endif /* not yet defined */
120 #define know(p) /* know() checks are no-op.ed */
123 #if defined (BROKEN_ASSERT) && !defined (NDEBUG)
124 /* Used on machines where the "assert" macro is buggy. (For example, on the
125 RS/6000, Reiser-cpp substitution is done to put the condition into a
126 string, so if the condition contains a string, parse errors result.) If
127 the condition fails, just drop core file. */
129 #define assert(p) ((p) ? 0 : (abort (), 0))
135 * Supplies sanitised buffers to read.c.
136 * Also understands printing line-number part of error messages.
140 /* subsegs.c Sub-segments. Also, segment(=expression type)s.*/
142 #ifndef BFD_ASSEMBLER
146 #define N_SEGMENTS 10
147 #define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E9)
148 #define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9
149 #define SEG_TEXT SEG_E0
150 #define SEG_DATA SEG_E1
151 #define SEG_BSS SEG_E2
154 #define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS)
155 #define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS
163 SEG_GOOF
, /* Only happens if AS has a logic error. */
164 /* Invented so we don't crash printing */
165 /* error message involving weird segment. */
166 SEG_EXPR
, /* Intermediate expression values. */
167 SEG_DEBUG
, /* Debug segment */
168 SEG_NTV
, /* Transfert vector preload segment */
169 SEG_PTV
, /* Transfert vector postload segment */
170 SEG_REGISTER
/* Mythical: a register-valued expression */
173 #define SEG_MAXIMUM_ORDINAL (SEG_REGISTER)
175 typedef asection
*segT
;
176 #define SEG_NORMAL(SEG) ((SEG) != absolute_section \
177 && (SEG) != undefined_section \
178 && (SEG) != reg_section \
179 && (SEG) != expr_section)
183 /* What subseg we are accreting now? */
184 COMMON subsegT now_subseg
;
186 /* Segment our instructions emit to. */
190 #define segment_name(SEG) bfd_get_section_name (stdoutput, SEG)
192 extern char *const seg_name
[];
193 #define segment_name(SEG) seg_name[(int) (SEG)]
196 #ifndef BFD_ASSEMBLER
197 extern int section_alignment
[];
201 extern segT reg_section
, expr_section
;
202 /* Shouldn't these be eliminated someday? */
203 extern segT text_section
, data_section
, bss_section
;
204 #define absolute_section (&bfd_abs_section)
205 #define undefined_section (&bfd_und_section)
207 #define reg_section SEG_REGISTER
208 #define expr_section SEG_EXPR
209 #define text_section SEG_TEXT
210 #define data_section SEG_DATA
211 #define bss_section SEG_BSS
212 #define absolute_section SEG_ABSOLUTE
213 #define undefined_section SEG_UNKNOWN
218 typedef enum _relax_state
220 /* Variable chars to be repeated fr_offset times.
221 Fr_symbol unused. Used with fr_offset == 0 for a
222 constant length frag. */
225 /* Align: Fr_offset: power of 2. 1 variable char: fill character. */
228 /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
234 #ifndef WORKING_DOT_WORD
240 /* typedef unsigned char relax_substateT; */
241 /* JF this is more likely to leave the end of a struct frag on an align
242 boundry. Be very careful with this. */
243 typedef unsigned long relax_substateT
;
245 /* Enough bits for address, but still an integer type.
246 Could be a problem, cross-assembling for 64-bit machines. */
247 typedef addressT relax_addressT
;
253 * A code fragment (frag) is some known number of chars, followed by some
254 * unknown number of chars. Typically the unknown number of chars is an
255 * instruction address whose size is yet unknown. We always know the greatest
256 * possible size the unknown number of chars may become, and reserve that
257 * much room at the end of the frag.
258 * Once created, frags do not change address during assembly.
259 * We chain the frags in (a) forward-linked list(s). The object-file address
260 * of the 1st char of a frag is generally not known until after relax().
261 * Many things at assembly time describe an address by {object-file-address
262 * of a particular frag}+offset.
264 BUG: it may be smarter to have a single pointer off to various different
265 notes for different frag kinds. See how code pans
269 /* Object file address. */
271 /* Chain forward; ascending address order. Rooted in frch_root. */
272 struct frag
*fr_next
;
274 /* (Fixed) number of chars we know we have. May be 0. */
276 /* (Variable) number of chars after above. May be 0. */
278 /* For variable-length tail. */
279 struct symbol
*fr_symbol
;
280 /* For variable-length tail. */
282 /* Points to opcode low addr byte, for relaxation. */
286 struct list_info_struct
*line
;
289 /* What state is my tail in? */
290 relax_stateT fr_type
;
291 relax_substateT fr_subtype
;
293 /* These are needed only on the NS32K machines */
294 char fr_pcrel_adjust
;
298 One day we will compile fr_literal[0]. */
302 #define SIZEOF_STRUCT_FRAG \
303 ((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
304 /* We want to say fr_literal[0] above. */
306 typedef struct frag fragS
;
308 /* Current frag we are building. This frag is incomplete. It is, however,
309 included in frchain_now. The fr_fix field is bogus; instead, use:
310 obstack_next_free(&frags)-frag_now->fr_literal. */
311 COMMON fragS
*frag_now
;
312 #define frag_now_fix() ((char*)obstack_next_free (&frags) - frag_now->fr_literal)
314 /* For foreign-segment symbol fixups. */
315 COMMON fragS zero_address_frag
;
316 /* For local common (N_BSS segment) fixups. */
317 COMMON fragS bss_address_frag
;
319 /* main program "as.c" (command arguments etc) */
321 /* ['x'] TRUE if "-x" seen. */
322 COMMON
char flagseen
[128];
323 COMMON
unsigned char flag_readonly_data_in_text
;
324 COMMON
unsigned char flag_suppress_warnings
;
325 COMMON
unsigned char flag_always_generate_output
;
327 /* name of emitted object file */
328 COMMON
char *out_file_name
;
330 /* TRUE if we need a second pass. */
331 COMMON
int need_pass_2
;
333 /* TRUE if we should do no relaxing, and
334 leave lots of padding. */
335 COMMON
int linkrelax
;
339 /* assembler mnemonic, lower case, no '.' */
342 void (*poc_handler
) PARAMS ((int));
343 /* Value to pass to handler */
347 typedef struct _pseudo_type pseudo_typeS
;
349 #ifdef BFD_ASSEMBLER_xxx
354 struct lineno_struct
*next
;
356 typedef struct lineno_struct lineno
;
359 #if defined (__STDC__) && !defined(NO_STDARG)
362 /* for use with -Wformat */
363 #define PRINTF_LIKE(FCN) void FCN (const char *Format, ...) \
364 __attribute__ ((format (printf, 1, 2)))
365 #else /* ANSI C with stdarg, but not GNU C */
366 #define PRINTF_LIKE(FCN) void FCN (const char *Format, ...)
368 #else /* not ANSI C, or not stdarg */
369 #define PRINTF_LIKE(FCN) void FCN ()
372 PRINTF_LIKE (as_bad
);
373 PRINTF_LIKE (as_fatal
);
374 PRINTF_LIKE (as_tsktsk
);
375 PRINTF_LIKE (as_warn
);
376 void fprint_value
PARAMS ((FILE *file
, addressT value
));
377 void sprint_value
PARAMS ((char *buf
, addressT value
));
379 int had_errors
PARAMS ((void));
380 int had_warnings
PARAMS ((void));
382 void print_version_id
PARAMS ((void));
383 char *app_push
PARAMS ((void));
384 char *atof_ieee
PARAMS ((char *str
, int what_kind
, LITTLENUM_TYPE
* words
));
385 char *input_scrub_include_file
PARAMS ((char *filename
, char *position
));
386 char *input_scrub_new_file
PARAMS ((char *filename
));
387 char *input_scrub_next_buffer
PARAMS ((char **bufp
));
388 #if 0 /* incompatible with solaris 2 native cc */
389 char *strstr
PARAMS ((const char *s
, const char *wanted
));
391 char *xmalloc
PARAMS ((unsigned long size
));
392 char *xrealloc
PARAMS ((char *ptr
, unsigned long n
));
393 int do_scrub_next_char
PARAMS ((int (*get
) (void), void (*unget
) (int)));
394 int gen_to_words
PARAMS ((LITTLENUM_TYPE
* words
, int precision
,
395 long exponent_bits
));
396 int had_err
PARAMS ((void));
397 int ignore_input
PARAMS ((void));
398 int scrub_from_file
PARAMS ((void));
399 int scrub_from_string
PARAMS ((void));
400 int seen_at_least_1_file
PARAMS ((void));
401 void app_pop
PARAMS ((char *arg
));
402 void as_howmuch
PARAMS ((FILE * stream
));
403 void as_perror
PARAMS ((char *gripe
, char *filename
));
404 void as_where
PARAMS ((void));
405 void bump_line_counters
PARAMS ((void));
406 void do_scrub_begin
PARAMS ((void));
407 void input_scrub_begin
PARAMS ((void));
408 void input_scrub_close
PARAMS ((void));
409 void input_scrub_end
PARAMS ((void));
410 void int_to_gen
PARAMS ((long x
));
411 void new_logical_line
PARAMS ((char *fname
, int line_number
));
412 void scrub_to_file
PARAMS ((int ch
));
413 void scrub_to_string
PARAMS ((int ch
));
414 void subsegs_begin
PARAMS ((void));
415 void subseg_change
PARAMS ((segT seg
, int subseg
));
416 segT subseg_new
PARAMS ((const char *name
, subsegT subseg
));
417 void subseg_set
PARAMS ((segT seg
, subsegT subseg
));
419 /* this one starts the chain of target dependant headers */
420 #include "targ-env.h"
423 #include "struc-symbol.h"
436 /* Someday perhaps this will be selectable at run-time. */
437 #if defined (OBJ_AOUT) || defined (OBJ_BOUT)
438 #define OUTPUT_FLAVOR bfd_target_aout_flavour
441 #define OUTPUT_FLAVOR bfd_target_coff_flavour
444 #define OUTPUT_FLAVOR bfd_target_ecoff_flavour
447 #define OUTPUT_FLAVOR bfd_target_elf_flavour
449 #endif /* BFD_ASSEMBLER */