* Makefile.in (install): Don't put strings in tooldir/bin.
[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
RP
86{ \
87 as_fatal("Case value %d unexpected at line %d of file \"%s\"\n", \
b17c891e 88 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
fecd2382
RP
143/*
144 * This table describes the use of segments as EXPRESSION types.
145 *
146 * X_seg X_add_symbol X_subtract_symbol X_add_number
147 * SEG_ABSENT no (legal) expression
148 * SEG_PASS1 no (defined) "
149 * SEG_BIG * > 32 bits const.
150 * SEG_ABSOLUTE 0
151 * SEG_DATA * 0
152 * SEG_TEXT * 0
153 * SEG_BSS * 0
154 * SEG_UNKNOWN * 0
155 * SEG_DIFFERENCE 0 * 0
156 * SEG_REGISTER *
157 *
158 * The blank fields MUST be 0, and are nugatory.
159 * The '0' fields MAY be 0. The '*' fields MAY NOT be 0.
160 *
161 * SEG_BIG: X_add_number is < 0 if the result is in
162 * generic_floating_point_number. The value is -'c' where c is the
163 * character that introduced the constant. e.g. "0f6.9" will have -'f'
164 * as a X_add_number value.
165 * X_add_number > 0 is a count of how many littlenums it took to
166 * represent a bignum.
167 * SEG_DIFFERENCE:
168 * If segments of both symbols are known, they are the same segment.
169 * X_add_symbol != X_sub_symbol (then we just cancel them, => SEG_ABSOLUTE).
170 */
171
ace68c4e 172
58721107 173#ifdef MANY_SEGMENTS
c8c7e0bf 174#include "bfd.h"
ace68c4e 175#define N_SEGMENTS 10
58721107 176#define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E9)
ace68c4e 177#define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9
ada269da 178#define SEG_TEXT SEG_E0
68878ef1 179#define SEG_DATA SEG_E1
ada269da 180#define SEG_BSS SEG_E2
58721107 181#else
ace68c4e 182#define N_SEGMENTS 3
58721107 183#define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS)
ace68c4e 184#define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS
58721107
SC
185#endif
186
6efd877d
KR
187typedef enum _segT
188 {
189 SEG_ABSOLUTE = 0,
190 SEG_LIST,
191 SEG_UNKNOWN,
192 SEG_ABSENT, /* Mythical Segment (absent): NO expression seen. */
193 SEG_PASS1, /* Mythical Segment: Need another pass. */
194 SEG_GOOF, /* Only happens if AS has a logic error. */
195 /* Invented so we don't crash printing */
196 /* error message involving weird segment. */
197 SEG_BIG, /* Bigger than 32 bits constant. */
198 SEG_DIFFERENCE, /* Mythical Segment: absolute difference. */
199 SEG_DEBUG, /* Debug segment */
200 SEG_NTV, /* Transfert vector preload segment */
201 SEG_PTV, /* Transfert vector postload segment */
b17c891e 202 SEG_REGISTER /* Mythical: a register-valued expression */
6efd877d 203 } segT;
fecd2382
RP
204
205#define SEG_MAXIMUM_ORDINAL (SEG_REGISTER)
68878ef1
KR
206#else
207typedef asection *segT;
208#define SEG_NORMAL(SEG) ((SEG) != absolute_section \
209 && (SEG) != undefined_section \
210 && (SEG) != big_section \
211 && (SEG) != reg_section \
212 && (SEG) != pass1_section \
213 && (SEG) != diff_section \
214 && (SEG) != absent_section)
215#endif
fecd2382
RP
216typedef int subsegT;
217
a39116f1 218/* What subseg we are accreting now? */
7f2cb270 219COMMON subsegT now_subseg;
fecd2382 220
a39116f1 221/* Segment our instructions emit to. */
7f2cb270 222COMMON segT now_seg;
fecd2382 223
68878ef1
KR
224#ifdef BFD_ASSEMBLER
225#define segment_name(SEG) bfd_get_section_name (stdoutput, SEG)
226#else
b17c891e 227extern char *const seg_name[];
68878ef1
KR
228#define segment_name(SEG) seg_name[(int) (SEG)]
229#endif
230
231#ifndef BFD_ASSEMBLER
fecd2382 232extern int section_alignment[];
68878ef1 233#endif
fecd2382 234
68878ef1
KR
235#ifdef BFD_ASSEMBLER
236extern segT big_section, reg_section, pass1_section;
237extern segT diff_section, absent_section;
238/* Shouldn't these be eliminated someday? */
239extern segT text_section, data_section, bss_section;
240#define absolute_section (&bfd_abs_section)
241#define undefined_section (&bfd_und_section)
242#else
243#define big_section SEG_BIG
244#define reg_section SEG_REGISTER
245#define pass1_section SEG_PASS1
246#define diff_section SEG_DIFFERENCE
247#define absent_section SEG_ABSENT
248#define text_section SEG_TEXT
249#define data_section SEG_DATA
250#define bss_section SEG_BSS
251#define absolute_section SEG_ABSOLUTE
252#define undefined_section SEG_UNKNOWN
253#endif
fecd2382
RP
254
255/* relax() */
256
6efd877d
KR
257typedef enum _relax_state
258 {
7f2cb270
KR
259 /* Variable chars to be repeated fr_offset times.
260 Fr_symbol unused. Used with fr_offset == 0 for a
261 constant length frag. */
262 rs_fill = 1,
6efd877d 263
7f2cb270
KR
264 /* Align: Fr_offset: power of 2. 1 variable char: fill character. */
265 rs_align,
6efd877d 266
7f2cb270
KR
267 /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
268 character. */
269 rs_org,
6efd877d 270
b17c891e 271 rs_machine_dependent
6efd877d 272
fecd2382 273#ifndef WORKING_DOT_WORD
7f2cb270 274 /* JF: gunpoint */
b17c891e 275 , rs_broken_word
fecd2382 276#endif
6efd877d 277 } relax_stateT;
fecd2382
RP
278
279/* typedef unsigned char relax_substateT; */
280/* JF this is more likely to leave the end of a struct frag on an align
281 boundry. Be very careful with this. */
282typedef unsigned long relax_substateT;
283
7f2cb270
KR
284/* Enough bits for address, but still an integer type.
285 Could be a problem, cross-assembling for 64-bit machines. */
b17c891e 286typedef addressT relax_addressT;
fecd2382 287\f
6efd877d 288
fecd2382
RP
289/* frags.c */
290
291/*
292 * A code fragment (frag) is some known number of chars, followed by some
293 * unknown number of chars. Typically the unknown number of chars is an
294 * instruction address whose size is yet unknown. We always know the greatest
295 * possible size the unknown number of chars may become, and reserve that
296 * much room at the end of the frag.
297 * Once created, frags do not change address during assembly.
298 * We chain the frags in (a) forward-linked list(s). The object-file address
299 * of the 1st char of a frag is generally not known until after relax().
300 * Many things at assembly time describe an address by {object-file-address
301 * of a particular frag}+offset.
6efd877d 302
fecd2382 303 BUG: it may be smarter to have a single pointer off to various different
6efd877d 304 notes for different frag kinds. See how code pans
fecd2382 305 */
68878ef1 306struct frag
fecd2382 307{
7f2cb270 308 /* Object file address. */
b17c891e 309 addressT fr_address;
68878ef1 310 /* Chain forward; ascending address order. Rooted in frch_root. */
7f2cb270 311 struct frag *fr_next;
6efd877d 312
68878ef1 313 /* (Fixed) number of chars we know we have. May be 0. */
b17c891e 314 offsetT fr_fix;
68878ef1 315 /* (Variable) number of chars after above. May be 0. */
b17c891e 316 offsetT fr_var;
7f2cb270
KR
317 /* For variable-length tail. */
318 struct symbol *fr_symbol;
319 /* For variable-length tail. */
b17c891e 320 offsetT fr_offset;
68878ef1 321 /* Points to opcode low addr byte, for relaxation. */
7f2cb270 322 char *fr_opcode;
68878ef1
KR
323
324#ifndef NO_LISTING
325 struct list_info_struct *line;
326#endif
327
7f2cb270
KR
328 /* What state is my tail in? */
329 relax_stateT fr_type;
6efd877d 330 relax_substateT fr_subtype;
7f2cb270 331
6efd877d
KR
332 /* These are needed only on the NS32K machines */
333 char fr_pcrel_adjust;
334 char fr_bsr;
68878ef1 335
7f2cb270
KR
336 /* Chars begin here.
337 One day we will compile fr_literal[0]. */
338 char fr_literal[1];
fecd2382 339};
6efd877d 340
fecd2382 341#define SIZEOF_STRUCT_FRAG \
a39116f1
RP
342((int)zero_address_frag.fr_literal-(int)&zero_address_frag)
343/* We want to say fr_literal[0] above. */
fecd2382
RP
344
345typedef struct frag fragS;
346
7f2cb270
KR
347/* Current frag we are building. This frag is incomplete. It is, however,
348 included in frchain_now. The fr_fix field is bogus; instead, use:
349 obstack_next_free(&frags)-frag_now->fr_literal. */
350COMMON fragS *frag_now;
b17c891e 351#define frag_now_fix() ((char*)obstack_next_free (&frags) - frag_now->fr_literal)
fecd2382 352
7f2cb270
KR
353/* For foreign-segment symbol fixups. */
354COMMON fragS zero_address_frag;
355/* For local common (N_BSS segment) fixups. */
356COMMON fragS bss_address_frag;
fecd2382
RP
357
358/* main program "as.c" (command arguments etc) */
359
7f2cb270
KR
360/* ['x'] TRUE if "-x" seen. */
361COMMON char flagseen[128];
362COMMON unsigned char flag_readonly_data_in_text;
363COMMON unsigned char flag_suppress_warnings;
364COMMON unsigned char flag_always_generate_output;
fecd2382 365
7f2cb270
KR
366/* name of emitted object file */
367COMMON char *out_file_name;
fecd2382 368
7f2cb270
KR
369/* TRUE if we need a second pass. */
370COMMON int need_pass_2;
09952cd9 371
7f2cb270
KR
372/* TRUE if we should do no relaxing, and
373 leave lots of padding. */
374COMMON int linkrelax;
fecd2382 375
7f2cb270 376struct _pseudo_type
6efd877d 377 {
7f2cb270
KR
378 /* assembler mnemonic, lower case, no '.' */
379 char *poc_name;
380 /* Do the work */
381 void (*poc_handler) ();
382 /* Value to pass to handler */
383 int poc_val;
384 };
6efd877d 385
7f2cb270 386typedef struct _pseudo_type pseudo_typeS;
fecd2382 387
68878ef1
KR
388#ifdef BFD_ASSEMBLER_xxx
389struct lineno_struct
390 {
391 alent line;
392 fragS *frag;
393 struct lineno_struct *next;
394 };
395typedef struct lineno_struct lineno;
396#endif
fecd2382 397
68878ef1 398#if defined (__STDC__) && !defined(NO_STDARG)
fecd2382 399
68878ef1
KR
400#if __GNUC__ >= 2
401/* for use with -Wformat */
402#define PRINTF_LIKE(FCN) void FCN (const char *Format, ...) \
403 __attribute__ ((format (printf, 1, 2)))
404#else /* ANSI C with stdarg, but not GNU C */
405#define PRINTF_LIKE(FCN) void FCN (const char *Format, ...)
406#endif
407#else /* not ANSI C, or not stdarg */
408#define PRINTF_LIKE(FCN) void FCN ()
409#endif
fecd2382 410
68878ef1
KR
411PRINTF_LIKE (as_bad);
412PRINTF_LIKE (as_fatal);
413PRINTF_LIKE (as_tsktsk);
414PRINTF_LIKE (as_warn);
b17c891e
KR
415void fprint_value PARAMS ((FILE *file, addressT value));
416void sprint_value PARAMS ((char *buf, addressT value));
fecd2382 417
68878ef1
KR
418int had_errors PARAMS ((void));
419int had_warnings PARAMS ((void));
fecd2382 420
7f2cb270
KR
421char *app_push PARAMS ((void));
422char *atof_ieee PARAMS ((char *str, int what_kind, LITTLENUM_TYPE * words));
423char *input_scrub_include_file PARAMS ((char *filename, char *position));
424char *input_scrub_new_file PARAMS ((char *filename));
425char *input_scrub_next_buffer PARAMS ((char **bufp));
b17c891e 426#if 0 /* incompatible with solaris 2 native cc */
7f2cb270 427char *strstr PARAMS ((const char *s, const char *wanted));
b17c891e 428#endif
7f2cb270
KR
429char *xmalloc PARAMS ((long size));
430char *xrealloc PARAMS ((char *ptr, long n));
431int do_scrub_next_char PARAMS ((int (*get) (), void (*unget) ()));
432int gen_to_words PARAMS ((LITTLENUM_TYPE * words, int precision,
433 long exponent_bits));
434int had_err PARAMS ((void));
435int had_errors PARAMS ((void));
436int had_warnings PARAMS ((void));
437int ignore_input PARAMS ((void));
438int scrub_from_file PARAMS ((void));
439int scrub_from_file PARAMS ((void));
440int scrub_from_string PARAMS ((void));
441int seen_at_least_1_file PARAMS ((void));
442void app_pop PARAMS ((char *arg));
443void as_howmuch PARAMS ((FILE * stream));
444void as_perror PARAMS ((char *gripe, char *filename));
445void as_where PARAMS ((void));
446void bump_line_counters PARAMS ((void));
447void do_scrub_begin PARAMS ((void));
448void input_scrub_begin PARAMS ((void));
449void input_scrub_close PARAMS ((void));
450void input_scrub_end PARAMS ((void));
451void int_to_gen PARAMS ((long x));
452void new_logical_line PARAMS ((char *fname, int line_number));
453void scrub_to_file PARAMS ((int ch));
454void scrub_to_string PARAMS ((int ch));
68878ef1 455void subsegs_begin PARAMS ((void));
7f2cb270 456void subseg_change PARAMS ((segT seg, int subseg));
68878ef1 457#ifdef BFD_ASSEMBLER
b17c891e 458segT subseg_new PARAMS ((const char *name, subsegT subseg));
68878ef1
KR
459void subseg_set PARAMS ((segT seg, subsegT subseg));
460#else
7f2cb270 461void subseg_new PARAMS ((segT seg, subsegT subseg));
68878ef1 462#endif
fecd2382 463
a39116f1 464/* this one starts the chain of target dependant headers */
fecd2382
RP
465#include "targ-env.h"
466
85051959 467#include "expr.h"
fecd2382 468#include "struc-symbol.h"
fecd2382 469#include "write.h"
fecd2382
RP
470#include "frags.h"
471#include "hash.h"
472#include "read.h"
473#include "symbols.h"
474
475#include "tc.h"
476#include "obj.h"
477
c593cf41
SC
478#include "listing.h"
479
b17c891e
KR
480#ifdef BFD_ASSEMBLER
481/* Someday perhaps this will be selectable at run-time. */
482#if defined (OBJ_AOUT) || defined (OBJ_BOUT)
483#define OUTPUT_FLAVOR bfd_target_aout_flavour
484#endif
485#ifdef OBJ_COFF
486#define OUTPUT_FLAVOR bfd_target_coff_flavour
487#endif
488#ifdef OBJ_ECOFF
489#define OUTPUT_FLAVOR bfd_target_ecoff_flavour
490#endif
491#ifdef OBJ_ELF
492#define OUTPUT_FLAVOR bfd_target_elf_flavour
493#endif
494#endif /* BFD_ASSEMBLER */
495
a39116f1 496/* end of as.h */
This page took 0.105 seconds and 4 git commands to generate.