* inferior.h, infrun.c, thread.c, infcmd.c: Remove all uses of
[deliverable/binutils-gdb.git] / gas / as.h
CommitLineData
fecd2382 1/* as.h - global header file
3340f7e5 2 Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
6efd877d 3
a39116f1 4 This file is part of GAS, the GNU Assembler.
6efd877d 5
a39116f1
RP
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)
9 any later version.
6efd877d 10
a39116f1
RP
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.
6efd877d 15
a39116f1
RP
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. */
fecd2382
RP
19
20#define GAS 1
fecd2382
RP
21/*
22 * I think this stuff is largely out of date. xoxorich.
23 *
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.
29 *
30 * #define DEBUG to enable all the "know" assertion tests.
68878ef1 31 * #define SUSPECT when debugging hash code.
fecd2382
RP
32 * #define COMMON as "extern" for all modules except one, where you #define
33 * COMMON as "".
34 * If TEST is #defined, then we are testing a module: #define COMMON as "".
35 */
36
37/* These #defines are for parameters of entire assembler. */
38
68878ef1 39#define DEBUG /* temporary */
fecd2382
RP
40/* These #includes are for type definitions etc. */
41
42#include <stdio.h>
68878ef1
KR
43#ifdef DEBUG
44#undef NDEBUG
45#endif
fecd2382 46#include <assert.h>
c593cf41 47
68878ef1
KR
48#include <ansidecl.h>
49#ifdef BFD_ASSEMBLER
50#include <bfd.h>
51#endif
52#include "host.h"
53#include "flonum.h"
54
b17c891e
KR
55/* Make Saber happier on obstack.h. */
56#ifdef SABER
57#undef __PTR_TO_INT
58#define __PTR_TO_INT(P) ((int)(P))
59#undef __INT_TO_PTR
60#define __INT_TO_PTR(P) ((char *)(P))
61#endif
62
68878ef1
KR
63#ifndef __LINE__
64#define __LINE__ "unknown"
65#endif /* __LINE__ */
66
67#ifndef __FILE__
68#define __FILE__ "unknown"
69#endif /* __FILE__ */
70
b17c891e
KR
71#ifndef __STDC__
72#ifndef const
73#define const
74#endif
75#ifndef volatile
76#define volatile
77#endif
78#endif /* ! __STDC__ */
79
3340f7e5
RP
80#define obstack_chunk_alloc xmalloc
81#define obstack_chunk_free xfree
fecd2382 82
a39116f1
RP
83#define xfree free
84
b17c891e 85#define BAD_CASE(val) \
a39116f1 86{ \
58d4951d
ILT
87 as_fatal("Case value %ld unexpected at line %d of file \"%s\"\n", \
88 (long) val, __LINE__, __FILE__); \
a39116f1 89 }
fecd2382 90\f
6efd877d 91
fecd2382
RP
92/* These are assembler-wide concepts */
93
68878ef1
KR
94#ifdef BFD_ASSEMBLER
95extern bfd *stdoutput;
b17c891e
KR
96typedef bfd_vma addressT;
97typedef bfd_signed_vma offsetT;
98#else
99typedef unsigned long addressT;
100typedef long offsetT;
68878ef1 101#endif
fecd2382 102
b17c891e
KR
103/* Type of symbol value, etc. For use in prototypes. */
104typedef addressT valueT;
105
fecd2382
RP
106#ifndef COMMON
107#ifdef TEST
108#define COMMON /* declare our COMMONs storage here. */
109#else
110#define COMMON extern /* our commons live elswhere */
111#endif
112#endif
a39116f1 113/* COMMON now defined */
c8c7e0bf 114
fecd2382 115#ifdef DEBUG
ace68c4e 116#ifndef know
fecd2382 117#define know(p) assert(p) /* Verify our assumptions! */
ace68c4e 118#endif /* not yet defined */
fecd2382
RP
119#else
120#define know(p) /* know() checks are no-op.ed */
121#endif
68878ef1
KR
122
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. */
128#undef assert
129#define assert(p) ((p) ? 0 : (abort (), 0))
130#endif
fecd2382
RP
131\f
132/* input_scrub.c */
133
134/*
135 * Supplies sanitised buffers to read.c.
136 * Also understands printing line-number part of error messages.
137 */
fecd2382 138\f
6efd877d 139
fecd2382
RP
140/* subsegs.c Sub-segments. Also, segment(=expression type)s.*/
141
68878ef1 142#ifndef BFD_ASSEMBLER
ace68c4e 143
58721107 144#ifdef MANY_SEGMENTS
c8c7e0bf 145#include "bfd.h"
ace68c4e 146#define N_SEGMENTS 10
58721107 147#define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E9)
ace68c4e 148#define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9
ada269da 149#define SEG_TEXT SEG_E0
68878ef1 150#define SEG_DATA SEG_E1
ada269da 151#define SEG_BSS SEG_E2
58721107 152#else
ace68c4e 153#define N_SEGMENTS 3
58721107 154#define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS)
ace68c4e 155#define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS
58721107
SC
156#endif
157
6efd877d
KR
158typedef enum _segT
159 {
160 SEG_ABSOLUTE = 0,
161 SEG_LIST,
162 SEG_UNKNOWN,
6efd877d
KR
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. */
58d4951d 166 SEG_EXPR, /* Intermediate expression values. */
6efd877d
KR
167 SEG_DEBUG, /* Debug segment */
168 SEG_NTV, /* Transfert vector preload segment */
169 SEG_PTV, /* Transfert vector postload segment */
b17c891e 170 SEG_REGISTER /* Mythical: a register-valued expression */
6efd877d 171 } segT;
fecd2382
RP
172
173#define SEG_MAXIMUM_ORDINAL (SEG_REGISTER)
68878ef1
KR
174#else
175typedef asection *segT;
176#define SEG_NORMAL(SEG) ((SEG) != absolute_section \
177 && (SEG) != undefined_section \
68878ef1 178 && (SEG) != reg_section \
58d4951d 179 && (SEG) != expr_section)
68878ef1 180#endif
fecd2382
RP
181typedef int subsegT;
182
a39116f1 183/* What subseg we are accreting now? */
7f2cb270 184COMMON subsegT now_subseg;
fecd2382 185
a39116f1 186/* Segment our instructions emit to. */
7f2cb270 187COMMON segT now_seg;
fecd2382 188
68878ef1
KR
189#ifdef BFD_ASSEMBLER
190#define segment_name(SEG) bfd_get_section_name (stdoutput, SEG)
191#else
b17c891e 192extern char *const seg_name[];
68878ef1
KR
193#define segment_name(SEG) seg_name[(int) (SEG)]
194#endif
195
196#ifndef BFD_ASSEMBLER
fecd2382 197extern int section_alignment[];
68878ef1 198#endif
fecd2382 199
68878ef1 200#ifdef BFD_ASSEMBLER
58d4951d 201extern segT reg_section, expr_section;
68878ef1
KR
202/* Shouldn't these be eliminated someday? */
203extern segT text_section, data_section, bss_section;
204#define absolute_section (&bfd_abs_section)
205#define undefined_section (&bfd_und_section)
206#else
68878ef1 207#define reg_section SEG_REGISTER
58d4951d 208#define expr_section SEG_EXPR
68878ef1
KR
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
214#endif
fecd2382
RP
215
216/* relax() */
217
6efd877d
KR
218typedef enum _relax_state
219 {
7f2cb270
KR
220 /* Variable chars to be repeated fr_offset times.
221 Fr_symbol unused. Used with fr_offset == 0 for a
222 constant length frag. */
223 rs_fill = 1,
6efd877d 224
7f2cb270
KR
225 /* Align: Fr_offset: power of 2. 1 variable char: fill character. */
226 rs_align,
6efd877d 227
7f2cb270
KR
228 /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
229 character. */
230 rs_org,
6efd877d 231
b17c891e 232 rs_machine_dependent
6efd877d 233
fecd2382 234#ifndef WORKING_DOT_WORD
7f2cb270 235 /* JF: gunpoint */
b17c891e 236 , rs_broken_word
fecd2382 237#endif
6efd877d 238 } relax_stateT;
fecd2382
RP
239
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. */
243typedef unsigned long relax_substateT;
244
7f2cb270
KR
245/* Enough bits for address, but still an integer type.
246 Could be a problem, cross-assembling for 64-bit machines. */
b17c891e 247typedef addressT relax_addressT;
fecd2382 248\f
6efd877d 249
fecd2382
RP
250/* frags.c */
251
252/*
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.
6efd877d 263
fecd2382 264 BUG: it may be smarter to have a single pointer off to various different
6efd877d 265 notes for different frag kinds. See how code pans
fecd2382 266 */
68878ef1 267struct frag
fecd2382 268{
7f2cb270 269 /* Object file address. */
b17c891e 270 addressT fr_address;
68878ef1 271 /* Chain forward; ascending address order. Rooted in frch_root. */
7f2cb270 272 struct frag *fr_next;
6efd877d 273
68878ef1 274 /* (Fixed) number of chars we know we have. May be 0. */
b17c891e 275 offsetT fr_fix;
68878ef1 276 /* (Variable) number of chars after above. May be 0. */
b17c891e 277 offsetT fr_var;
7f2cb270
KR
278 /* For variable-length tail. */
279 struct symbol *fr_symbol;
280 /* For variable-length tail. */
b17c891e 281 offsetT fr_offset;
68878ef1 282 /* Points to opcode low addr byte, for relaxation. */
7f2cb270 283 char *fr_opcode;
68878ef1
KR
284
285#ifndef NO_LISTING
286 struct list_info_struct *line;
287#endif
288
7f2cb270
KR
289 /* What state is my tail in? */
290 relax_stateT fr_type;
6efd877d 291 relax_substateT fr_subtype;
7f2cb270 292
6efd877d
KR
293 /* These are needed only on the NS32K machines */
294 char fr_pcrel_adjust;
295 char fr_bsr;
68878ef1 296
7f2cb270
KR
297 /* Chars begin here.
298 One day we will compile fr_literal[0]. */
299 char fr_literal[1];
fecd2382 300};
6efd877d 301
fecd2382 302#define SIZEOF_STRUCT_FRAG \
a39116f1
RP
303((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
304/* We want to say fr_literal[0] above. */
fecd2382
RP
305
306typedef struct frag fragS;
307
7f2cb270
KR
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. */
311COMMON fragS *frag_now;
b17c891e 312#define frag_now_fix() ((char*)obstack_next_free (&frags) - frag_now->fr_literal)
fecd2382 313
7f2cb270
KR
314/* For foreign-segment symbol fixups. */
315COMMON fragS zero_address_frag;
316/* For local common (N_BSS segment) fixups. */
317COMMON fragS bss_address_frag;
fecd2382
RP
318
319/* main program "as.c" (command arguments etc) */
320
7f2cb270
KR
321/* ['x'] TRUE if "-x" seen. */
322COMMON char flagseen[128];
323COMMON unsigned char flag_readonly_data_in_text;
324COMMON unsigned char flag_suppress_warnings;
325COMMON unsigned char flag_always_generate_output;
fecd2382 326
7f2cb270
KR
327/* name of emitted object file */
328COMMON char *out_file_name;
fecd2382 329
7f2cb270
KR
330/* TRUE if we need a second pass. */
331COMMON int need_pass_2;
09952cd9 332
7f2cb270
KR
333/* TRUE if we should do no relaxing, and
334 leave lots of padding. */
335COMMON int linkrelax;
fecd2382 336
7f2cb270 337struct _pseudo_type
6efd877d 338 {
7f2cb270
KR
339 /* assembler mnemonic, lower case, no '.' */
340 char *poc_name;
341 /* Do the work */
342 void (*poc_handler) ();
343 /* Value to pass to handler */
344 int poc_val;
345 };
6efd877d 346
7f2cb270 347typedef struct _pseudo_type pseudo_typeS;
fecd2382 348
68878ef1
KR
349#ifdef BFD_ASSEMBLER_xxx
350struct lineno_struct
351 {
352 alent line;
353 fragS *frag;
354 struct lineno_struct *next;
355 };
356typedef struct lineno_struct lineno;
357#endif
fecd2382 358
68878ef1 359#if defined (__STDC__) && !defined(NO_STDARG)
fecd2382 360
68878ef1
KR
361#if __GNUC__ >= 2
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, ...)
367#endif
368#else /* not ANSI C, or not stdarg */
369#define PRINTF_LIKE(FCN) void FCN ()
370#endif
fecd2382 371
68878ef1
KR
372PRINTF_LIKE (as_bad);
373PRINTF_LIKE (as_fatal);
374PRINTF_LIKE (as_tsktsk);
375PRINTF_LIKE (as_warn);
b17c891e
KR
376void fprint_value PARAMS ((FILE *file, addressT value));
377void sprint_value PARAMS ((char *buf, addressT value));
fecd2382 378
68878ef1
KR
379int had_errors PARAMS ((void));
380int had_warnings PARAMS ((void));
fecd2382 381
7f2cb270
KR
382char *app_push PARAMS ((void));
383char *atof_ieee PARAMS ((char *str, int what_kind, LITTLENUM_TYPE * words));
384char *input_scrub_include_file PARAMS ((char *filename, char *position));
385char *input_scrub_new_file PARAMS ((char *filename));
386char *input_scrub_next_buffer PARAMS ((char **bufp));
b17c891e 387#if 0 /* incompatible with solaris 2 native cc */
7f2cb270 388char *strstr PARAMS ((const char *s, const char *wanted));
b17c891e 389#endif
7f2cb270
KR
390char *xmalloc PARAMS ((long size));
391char *xrealloc PARAMS ((char *ptr, long n));
392int do_scrub_next_char PARAMS ((int (*get) (), void (*unget) ()));
393int gen_to_words PARAMS ((LITTLENUM_TYPE * words, int precision,
394 long exponent_bits));
395int had_err PARAMS ((void));
396int had_errors PARAMS ((void));
397int had_warnings PARAMS ((void));
398int ignore_input PARAMS ((void));
399int scrub_from_file PARAMS ((void));
400int scrub_from_file PARAMS ((void));
401int scrub_from_string PARAMS ((void));
402int seen_at_least_1_file PARAMS ((void));
403void app_pop PARAMS ((char *arg));
404void as_howmuch PARAMS ((FILE * stream));
405void as_perror PARAMS ((char *gripe, char *filename));
406void as_where PARAMS ((void));
407void bump_line_counters PARAMS ((void));
408void do_scrub_begin PARAMS ((void));
409void input_scrub_begin PARAMS ((void));
410void input_scrub_close PARAMS ((void));
411void input_scrub_end PARAMS ((void));
412void int_to_gen PARAMS ((long x));
413void new_logical_line PARAMS ((char *fname, int line_number));
414void scrub_to_file PARAMS ((int ch));
415void scrub_to_string PARAMS ((int ch));
68878ef1 416void subsegs_begin PARAMS ((void));
7f2cb270 417void subseg_change PARAMS ((segT seg, int subseg));
68878ef1 418#ifdef BFD_ASSEMBLER
b17c891e 419segT subseg_new PARAMS ((const char *name, subsegT subseg));
68878ef1
KR
420void subseg_set PARAMS ((segT seg, subsegT subseg));
421#else
7f2cb270 422void subseg_new PARAMS ((segT seg, subsegT subseg));
68878ef1 423#endif
fecd2382 424
a39116f1 425/* this one starts the chain of target dependant headers */
fecd2382
RP
426#include "targ-env.h"
427
85051959 428#include "expr.h"
fecd2382 429#include "struc-symbol.h"
fecd2382 430#include "write.h"
fecd2382
RP
431#include "frags.h"
432#include "hash.h"
433#include "read.h"
434#include "symbols.h"
435
436#include "tc.h"
437#include "obj.h"
438
c593cf41
SC
439#include "listing.h"
440
b17c891e
KR
441#ifdef BFD_ASSEMBLER
442/* Someday perhaps this will be selectable at run-time. */
443#if defined (OBJ_AOUT) || defined (OBJ_BOUT)
444#define OUTPUT_FLAVOR bfd_target_aout_flavour
445#endif
446#ifdef OBJ_COFF
447#define OUTPUT_FLAVOR bfd_target_coff_flavour
448#endif
449#ifdef OBJ_ECOFF
450#define OUTPUT_FLAVOR bfd_target_ecoff_flavour
451#endif
452#ifdef OBJ_ELF
453#define OUTPUT_FLAVOR bfd_target_elf_flavour
454#endif
455#endif /* BFD_ASSEMBLER */
456
a39116f1 457/* end of as.h */
This page took 0.101757 seconds and 4 git commands to generate.