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