* Makefile.in (TARGET_FLAGS_TO_PASS): Fix syntax 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 19
7f955c18 20#ifndef GAS
fecd2382 21#define GAS 1
fecd2382
RP
22/*
23 * I think this stuff is largely out of date. xoxorich.
24 *
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.
30 *
31 * #define DEBUG to enable all the "know" assertion tests.
68878ef1 32 * #define SUSPECT when debugging hash code.
fecd2382
RP
33 * #define COMMON as "extern" for all modules except one, where you #define
34 * COMMON as "".
35 * If TEST is #defined, then we are testing a module: #define COMMON as "".
36 */
37
38/* These #defines are for parameters of entire assembler. */
39
fecd2382
RP
40/* These #includes are for type definitions etc. */
41
7f955c18
KR
42#include "config.h"
43
fecd2382 44#include <stdio.h>
68878ef1
KR
45#ifdef DEBUG
46#undef NDEBUG
47#endif
fecd2382 48#include <assert.h>
c593cf41 49
68878ef1
KR
50#include <ansidecl.h>
51#ifdef BFD_ASSEMBLER
52#include <bfd.h>
53#endif
54#include "host.h"
55#include "flonum.h"
56
b17c891e
KR
57/* Make Saber happier on obstack.h. */
58#ifdef SABER
59#undef __PTR_TO_INT
60#define __PTR_TO_INT(P) ((int)(P))
61#undef __INT_TO_PTR
62#define __INT_TO_PTR(P) ((char *)(P))
63#endif
64
68878ef1
KR
65#ifndef __LINE__
66#define __LINE__ "unknown"
67#endif /* __LINE__ */
68
69#ifndef __FILE__
70#define __FILE__ "unknown"
71#endif /* __FILE__ */
72
b17c891e
KR
73#ifndef __STDC__
74#ifndef const
75#define const
76#endif
77#ifndef volatile
78#define volatile
79#endif
80#endif /* ! __STDC__ */
81
98c6bbbe
KR
82#if !defined (__GNUC__) && !defined (inline)
83#define inline
84#endif
85
7f955c18
KR
86#ifndef FOPEN_WB
87#include "fopen-same.h"
88#endif
89
3340f7e5
RP
90#define obstack_chunk_alloc xmalloc
91#define obstack_chunk_free xfree
fecd2382 92
a39116f1
RP
93#define xfree free
94
b17c891e 95#define BAD_CASE(val) \
a39116f1 96{ \
58d4951d
ILT
97 as_fatal("Case value %ld unexpected at line %d of file \"%s\"\n", \
98 (long) val, __LINE__, __FILE__); \
a39116f1 99 }
a193acc0
ILT
100
101/* Version 2.1 of Solaris had problems with this declaration, but I
102 think that bug has since been fixed. If it causes problems on your
103 system, just delete it. */
104extern char *strstr ();
fecd2382 105\f
6efd877d 106
fecd2382
RP
107/* These are assembler-wide concepts */
108
68878ef1
KR
109#ifdef BFD_ASSEMBLER
110extern bfd *stdoutput;
b17c891e
KR
111typedef bfd_vma addressT;
112typedef bfd_signed_vma offsetT;
113#else
114typedef unsigned long addressT;
115typedef long offsetT;
68878ef1 116#endif
fecd2382 117
b17c891e
KR
118/* Type of symbol value, etc. For use in prototypes. */
119typedef addressT valueT;
120
fecd2382
RP
121#ifndef COMMON
122#ifdef TEST
123#define COMMON /* declare our COMMONs storage here. */
124#else
125#define COMMON extern /* our commons live elswhere */
126#endif
127#endif
a39116f1 128/* COMMON now defined */
c8c7e0bf 129
fecd2382 130#ifdef DEBUG
ace68c4e 131#ifndef know
fecd2382 132#define know(p) assert(p) /* Verify our assumptions! */
ace68c4e 133#endif /* not yet defined */
fecd2382
RP
134#else
135#define know(p) /* know() checks are no-op.ed */
136#endif
68878ef1
KR
137
138#if defined (BROKEN_ASSERT) && !defined (NDEBUG)
139/* Used on machines where the "assert" macro is buggy. (For example, on the
140 RS/6000, Reiser-cpp substitution is done to put the condition into a
141 string, so if the condition contains a string, parse errors result.) If
142 the condition fails, just drop core file. */
143#undef assert
144#define assert(p) ((p) ? 0 : (abort (), 0))
145#endif
fecd2382
RP
146\f
147/* input_scrub.c */
148
149/*
150 * Supplies sanitised buffers to read.c.
151 * Also understands printing line-number part of error messages.
152 */
fecd2382 153\f
6efd877d 154
fecd2382
RP
155/* subsegs.c Sub-segments. Also, segment(=expression type)s.*/
156
68878ef1 157#ifndef BFD_ASSEMBLER
ace68c4e 158
58721107 159#ifdef MANY_SEGMENTS
c8c7e0bf 160#include "bfd.h"
ace68c4e 161#define N_SEGMENTS 10
58721107 162#define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E9)
ace68c4e 163#define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9
ada269da 164#define SEG_TEXT SEG_E0
68878ef1 165#define SEG_DATA SEG_E1
ada269da 166#define SEG_BSS SEG_E2
58721107 167#else
ace68c4e 168#define N_SEGMENTS 3
58721107 169#define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS)
ace68c4e 170#define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS
58721107
SC
171#endif
172
6efd877d
KR
173typedef enum _segT
174 {
175 SEG_ABSOLUTE = 0,
176 SEG_LIST,
177 SEG_UNKNOWN,
6efd877d
KR
178 SEG_GOOF, /* Only happens if AS has a logic error. */
179 /* Invented so we don't crash printing */
180 /* error message involving weird segment. */
58d4951d 181 SEG_EXPR, /* Intermediate expression values. */
6efd877d
KR
182 SEG_DEBUG, /* Debug segment */
183 SEG_NTV, /* Transfert vector preload segment */
184 SEG_PTV, /* Transfert vector postload segment */
b17c891e 185 SEG_REGISTER /* Mythical: a register-valued expression */
6efd877d 186 } segT;
fecd2382
RP
187
188#define SEG_MAXIMUM_ORDINAL (SEG_REGISTER)
68878ef1
KR
189#else
190typedef asection *segT;
191#define SEG_NORMAL(SEG) ((SEG) != absolute_section \
192 && (SEG) != undefined_section \
68878ef1 193 && (SEG) != reg_section \
58d4951d 194 && (SEG) != expr_section)
68878ef1 195#endif
fecd2382
RP
196typedef int subsegT;
197
a39116f1 198/* What subseg we are accreting now? */
7f2cb270 199COMMON subsegT now_subseg;
fecd2382 200
a39116f1 201/* Segment our instructions emit to. */
7f2cb270 202COMMON segT now_seg;
fecd2382 203
68878ef1
KR
204#ifdef BFD_ASSEMBLER
205#define segment_name(SEG) bfd_get_section_name (stdoutput, SEG)
206#else
b17c891e 207extern char *const seg_name[];
68878ef1
KR
208#define segment_name(SEG) seg_name[(int) (SEG)]
209#endif
210
211#ifndef BFD_ASSEMBLER
fecd2382 212extern int section_alignment[];
68878ef1 213#endif
fecd2382 214
68878ef1 215#ifdef BFD_ASSEMBLER
58d4951d 216extern segT reg_section, expr_section;
68878ef1
KR
217/* Shouldn't these be eliminated someday? */
218extern segT text_section, data_section, bss_section;
219#define absolute_section (&bfd_abs_section)
220#define undefined_section (&bfd_und_section)
221#else
68878ef1 222#define reg_section SEG_REGISTER
58d4951d 223#define expr_section SEG_EXPR
68878ef1
KR
224#define text_section SEG_TEXT
225#define data_section SEG_DATA
226#define bss_section SEG_BSS
227#define absolute_section SEG_ABSOLUTE
228#define undefined_section SEG_UNKNOWN
229#endif
fecd2382
RP
230
231/* relax() */
232
6efd877d
KR
233typedef enum _relax_state
234 {
7f2cb270
KR
235 /* Variable chars to be repeated fr_offset times.
236 Fr_symbol unused. Used with fr_offset == 0 for a
237 constant length frag. */
238 rs_fill = 1,
6efd877d 239
98c6bbbe 240 /* Align: Fr_offset: power of 2. Variable chars: fill pattern. */
7f2cb270 241 rs_align,
6efd877d 242
7f2cb270
KR
243 /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
244 character. */
245 rs_org,
6efd877d 246
b17c891e 247 rs_machine_dependent
6efd877d 248
fecd2382 249#ifndef WORKING_DOT_WORD
7f2cb270 250 /* JF: gunpoint */
b17c891e 251 , rs_broken_word
fecd2382 252#endif
6efd877d 253 } relax_stateT;
fecd2382
RP
254
255/* typedef unsigned char relax_substateT; */
256/* JF this is more likely to leave the end of a struct frag on an align
257 boundry. Be very careful with this. */
258typedef unsigned long relax_substateT;
259
7f2cb270
KR
260/* Enough bits for address, but still an integer type.
261 Could be a problem, cross-assembling for 64-bit machines. */
b17c891e 262typedef addressT relax_addressT;
fecd2382 263\f
6efd877d 264
fecd2382
RP
265/* frags.c */
266
267/*
268 * A code fragment (frag) is some known number of chars, followed by some
269 * unknown number of chars. Typically the unknown number of chars is an
270 * instruction address whose size is yet unknown. We always know the greatest
271 * possible size the unknown number of chars may become, and reserve that
272 * much room at the end of the frag.
273 * Once created, frags do not change address during assembly.
274 * We chain the frags in (a) forward-linked list(s). The object-file address
275 * of the 1st char of a frag is generally not known until after relax().
276 * Many things at assembly time describe an address by {object-file-address
277 * of a particular frag}+offset.
6efd877d 278
fecd2382 279 BUG: it may be smarter to have a single pointer off to various different
6efd877d 280 notes for different frag kinds. See how code pans
fecd2382 281 */
68878ef1 282struct frag
fecd2382 283{
7f2cb270 284 /* Object file address. */
b17c891e 285 addressT fr_address;
68878ef1 286 /* Chain forward; ascending address order. Rooted in frch_root. */
7f2cb270 287 struct frag *fr_next;
6efd877d 288
68878ef1 289 /* (Fixed) number of chars we know we have. May be 0. */
b17c891e 290 offsetT fr_fix;
68878ef1 291 /* (Variable) number of chars after above. May be 0. */
b17c891e 292 offsetT fr_var;
7f2cb270
KR
293 /* For variable-length tail. */
294 struct symbol *fr_symbol;
295 /* For variable-length tail. */
b17c891e 296 offsetT fr_offset;
68878ef1 297 /* Points to opcode low addr byte, for relaxation. */
7f2cb270 298 char *fr_opcode;
68878ef1
KR
299
300#ifndef NO_LISTING
301 struct list_info_struct *line;
302#endif
303
7f2cb270
KR
304 /* What state is my tail in? */
305 relax_stateT fr_type;
6efd877d 306 relax_substateT fr_subtype;
7f2cb270 307
6efd877d
KR
308 /* These are needed only on the NS32K machines */
309 char fr_pcrel_adjust;
310 char fr_bsr;
68878ef1 311
7f2cb270
KR
312 /* Chars begin here.
313 One day we will compile fr_literal[0]. */
314 char fr_literal[1];
fecd2382 315};
6efd877d 316
fecd2382 317#define SIZEOF_STRUCT_FRAG \
a39116f1
RP
318((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
319/* We want to say fr_literal[0] above. */
fecd2382
RP
320
321typedef struct frag fragS;
322
7f2cb270
KR
323/* Current frag we are building. This frag is incomplete. It is, however,
324 included in frchain_now. The fr_fix field is bogus; instead, use:
325 obstack_next_free(&frags)-frag_now->fr_literal. */
326COMMON fragS *frag_now;
b17c891e 327#define frag_now_fix() ((char*)obstack_next_free (&frags) - frag_now->fr_literal)
fecd2382 328
7f2cb270
KR
329/* For foreign-segment symbol fixups. */
330COMMON fragS zero_address_frag;
331/* For local common (N_BSS segment) fixups. */
332COMMON fragS bss_address_frag;
fecd2382
RP
333
334/* main program "as.c" (command arguments etc) */
335
7f2cb270
KR
336/* ['x'] TRUE if "-x" seen. */
337COMMON char flagseen[128];
338COMMON unsigned char flag_readonly_data_in_text;
339COMMON unsigned char flag_suppress_warnings;
340COMMON unsigned char flag_always_generate_output;
fecd2382 341
7f2cb270
KR
342/* name of emitted object file */
343COMMON char *out_file_name;
fecd2382 344
7f2cb270
KR
345/* TRUE if we need a second pass. */
346COMMON int need_pass_2;
09952cd9 347
7f2cb270
KR
348/* TRUE if we should do no relaxing, and
349 leave lots of padding. */
350COMMON int linkrelax;
fecd2382 351
7f955c18
KR
352/* TRUE if we should produce a listing. */
353extern int listing;
354
7f2cb270 355struct _pseudo_type
6efd877d 356 {
7f2cb270
KR
357 /* assembler mnemonic, lower case, no '.' */
358 char *poc_name;
359 /* Do the work */
604633ae 360 void (*poc_handler) PARAMS ((int));
7f2cb270
KR
361 /* Value to pass to handler */
362 int poc_val;
363 };
6efd877d 364
7f2cb270 365typedef struct _pseudo_type pseudo_typeS;
fecd2382 366
68878ef1
KR
367#ifdef BFD_ASSEMBLER_xxx
368struct lineno_struct
369 {
370 alent line;
371 fragS *frag;
372 struct lineno_struct *next;
373 };
374typedef struct lineno_struct lineno;
375#endif
fecd2382 376
68878ef1 377#if defined (__STDC__) && !defined(NO_STDARG)
fecd2382 378
68878ef1
KR
379#if __GNUC__ >= 2
380/* for use with -Wformat */
7f955c18 381#define PRINTF_LIKE(FCN) void FCN (const char *format, ...) \
68878ef1 382 __attribute__ ((format (printf, 1, 2)))
a57180ad
ILT
383#define PRINTF_WHERE_LIKE(FCN) void FCN (char *file, unsigned int line, \
384 const char *format, ...) \
385 __attribute__ ((format (printf, 3, 4)))
68878ef1 386#else /* ANSI C with stdarg, but not GNU C */
7f955c18 387#define PRINTF_LIKE(FCN) void FCN (const char *format, ...)
a57180ad
ILT
388#define PRINTF_WHERE_LIKE(FCN) void FCN (char *file, unsigned int line, \
389 const char *format, ...)
68878ef1
KR
390#endif
391#else /* not ANSI C, or not stdarg */
392#define PRINTF_LIKE(FCN) void FCN ()
a57180ad 393#define PRINTF_WHERE_LIKE(FCN) void FCN ()
68878ef1 394#endif
fecd2382 395
68878ef1
KR
396PRINTF_LIKE (as_bad);
397PRINTF_LIKE (as_fatal);
398PRINTF_LIKE (as_tsktsk);
399PRINTF_LIKE (as_warn);
a57180ad
ILT
400PRINTF_WHERE_LIKE (as_bad_where);
401PRINTF_WHERE_LIKE (as_warn_where);
7f955c18 402
b17c891e
KR
403void fprint_value PARAMS ((FILE *file, addressT value));
404void sprint_value PARAMS ((char *buf, addressT value));
fecd2382 405
68878ef1
KR
406int had_errors PARAMS ((void));
407int had_warnings PARAMS ((void));
fecd2382 408
604633ae 409void print_version_id PARAMS ((void));
7f2cb270
KR
410char *app_push PARAMS ((void));
411char *atof_ieee PARAMS ((char *str, int what_kind, LITTLENUM_TYPE * words));
412char *input_scrub_include_file PARAMS ((char *filename, char *position));
413char *input_scrub_new_file PARAMS ((char *filename));
414char *input_scrub_next_buffer PARAMS ((char **bufp));
a193acc0
ILT
415PTR xmalloc PARAMS ((unsigned long size));
416PTR xrealloc PARAMS ((PTR ptr, unsigned long n));
604633ae 417int do_scrub_next_char PARAMS ((int (*get) (void), void (*unget) (int)));
7f2cb270
KR
418int gen_to_words PARAMS ((LITTLENUM_TYPE * words, int precision,
419 long exponent_bits));
420int had_err PARAMS ((void));
7f2cb270
KR
421int ignore_input PARAMS ((void));
422int scrub_from_file PARAMS ((void));
7f2cb270
KR
423int scrub_from_string PARAMS ((void));
424int seen_at_least_1_file PARAMS ((void));
425void app_pop PARAMS ((char *arg));
426void as_howmuch PARAMS ((FILE * stream));
a193acc0 427void as_perror PARAMS ((const char *gripe, const char *filename));
7f955c18 428void as_where PARAMS ((char **namep, unsigned int *linep));
7f2cb270
KR
429void bump_line_counters PARAMS ((void));
430void do_scrub_begin PARAMS ((void));
431void input_scrub_begin PARAMS ((void));
432void input_scrub_close PARAMS ((void));
433void input_scrub_end PARAMS ((void));
7f2cb270
KR
434void new_logical_line PARAMS ((char *fname, int line_number));
435void scrub_to_file PARAMS ((int ch));
436void scrub_to_string PARAMS ((int ch));
68878ef1 437void subsegs_begin PARAMS ((void));
7f2cb270 438void subseg_change PARAMS ((segT seg, int subseg));
b17c891e 439segT subseg_new PARAMS ((const char *name, subsegT subseg));
e7501ac7 440segT subseg_force_new PARAMS ((const char *name, subsegT subseg));
68878ef1 441void subseg_set PARAMS ((segT seg, subsegT subseg));
a193acc0
ILT
442#ifdef BFD_ASSEMBLER
443segT subseg_get PARAMS ((const char *, int));
444#endif
fecd2382 445
7f955c18
KR
446struct expressionS;
447struct fix;
448struct symbol;
449
450#ifdef BFD_ASSEMBLER
451/* literal.c */
452valueT add_to_literal_pool PARAMS ((struct symbol *, valueT, segT, int));
453#endif
454
a39116f1 455/* this one starts the chain of target dependant headers */
fecd2382
RP
456#include "targ-env.h"
457
85051959 458#include "expr.h"
fecd2382 459#include "struc-symbol.h"
fecd2382 460#include "write.h"
fecd2382
RP
461#include "frags.h"
462#include "hash.h"
463#include "read.h"
464#include "symbols.h"
465
466#include "tc.h"
467#include "obj.h"
468
c593cf41
SC
469#include "listing.h"
470
b17c891e
KR
471#ifdef BFD_ASSEMBLER
472/* Someday perhaps this will be selectable at run-time. */
473#if defined (OBJ_AOUT) || defined (OBJ_BOUT)
474#define OUTPUT_FLAVOR bfd_target_aout_flavour
475#endif
476#ifdef OBJ_COFF
477#define OUTPUT_FLAVOR bfd_target_coff_flavour
478#endif
479#ifdef OBJ_ECOFF
480#define OUTPUT_FLAVOR bfd_target_ecoff_flavour
481#endif
482#ifdef OBJ_ELF
483#define OUTPUT_FLAVOR bfd_target_elf_flavour
484#endif
485#endif /* BFD_ASSEMBLER */
486
7f955c18
KR
487#endif /* GAS */
488
a39116f1 489/* end of as.h */
This page took 0.188226 seconds and 4 git commands to generate.