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