xref: /openbsd/gnu/usr.bin/binutils/gas/as.h (revision dfad4a00)
12159047fSniklas /* as.h - global header file
2b55d4692Sfgsch    Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3c074d1c9Sdrahn    1999, 2000, 2001, 2002, 2003
4191aa565Sniklas    Free Software Foundation, Inc.
52159047fSniklas 
62159047fSniklas    This file is part of GAS, the GNU Assembler.
72159047fSniklas 
82159047fSniklas    GAS is free software; you can redistribute it and/or modify
92159047fSniklas    it under the terms of the GNU General Public License as published by
102159047fSniklas    the Free Software Foundation; either version 2, or (at your option)
112159047fSniklas    any later version.
122159047fSniklas 
132159047fSniklas    GAS is distributed in the hope that it will be useful,
142159047fSniklas    but WITHOUT ANY WARRANTY; without even the implied warranty of
152159047fSniklas    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
162159047fSniklas    GNU General Public License for more details.
172159047fSniklas 
182159047fSniklas    You should have received a copy of the GNU General Public License
190c6d0228Sniklas    along with GAS; see the file COPYING.  If not, write to the Free
200c6d0228Sniklas    Software Foundation, 59 Temple Place - Suite 330, Boston, MA
210c6d0228Sniklas    02111-1307, USA.  */
222159047fSniklas 
232159047fSniklas #ifndef GAS
242159047fSniklas #define GAS 1
25b55d4692Sfgsch /* I think this stuff is largely out of date.  xoxorich.
262159047fSniklas  *
272159047fSniklas  * CAPITALISED names are #defined.
282159047fSniklas  * "lowercaseH" is #defined if "lowercase.h" has been #include-d.
292159047fSniklas  * "lowercaseT" is a typedef of "lowercase" objects.
302159047fSniklas  * "lowercaseP" is type "pointer to object of type 'lowercase'".
312159047fSniklas  * "lowercaseS" is typedef struct ... lowercaseS.
322159047fSniklas  *
332159047fSniklas  * #define DEBUG to enable all the "know" assertion tests.
342159047fSniklas  * #define SUSPECT when debugging hash code.
352159047fSniklas  * #define COMMON as "extern" for all modules except one, where you #define
362159047fSniklas  *	COMMON as "".
372159047fSniklas  * If TEST is #defined, then we are testing a module: #define COMMON as "".
382159047fSniklas  */
392159047fSniklas 
402159047fSniklas #include "config.h"
41b305b0f1Sespie #include "bin-bugs.h"
422159047fSniklas 
432159047fSniklas /* This is the code recommended in the autoconf documentation, almost
442159047fSniklas    verbatim.  If it doesn't work for you, let me know, and notify
452159047fSniklas    djm@gnu.ai.mit.edu as well.  */
462159047fSniklas /* Added void* version for STDC case.  This is to be compatible with
472159047fSniklas    the declaration in bison.simple, used for m68k operand parsing.
482159047fSniklas    --KR 1995.08.08 */
492159047fSniklas /* Force void* decl for hpux.  This is what Bison uses.  --KR 1995.08.16 */
502159047fSniklas 
51c074d1c9Sdrahn #ifndef __GNUC__
522159047fSniklas # if HAVE_ALLOCA_H
532159047fSniklas #  include <alloca.h>
542159047fSniklas # else
552159047fSniklas #  ifdef _AIX
56c074d1c9Sdrahn /* Indented so that pre-ansi C compilers will ignore it, rather than
57c074d1c9Sdrahn    choke on it.  Some versions of AIX require this to be the first
58c074d1c9Sdrahn    thing in the file.  */
592159047fSniklas  #pragma alloca
602159047fSniklas #  else
612159047fSniklas #   ifndef alloca /* predefined by HP cc +Olibcalls */
622159047fSniklas #    if !defined (__STDC__) && !defined (__hpux)
63b305b0f1Sespie extern char *alloca ();
642159047fSniklas #    else
65b305b0f1Sespie extern void *alloca ();
662159047fSniklas #    endif /* __STDC__, __hpux */
672159047fSniklas #   endif /* alloca */
682159047fSniklas #  endif /* _AIX */
692159047fSniklas # endif /* HAVE_ALLOCA_H */
70c074d1c9Sdrahn #endif /* __GNUC__ */
712159047fSniklas 
722159047fSniklas /* Now, tend to the rest of the configuration.  */
732159047fSniklas 
742159047fSniklas /* System include files first...  */
752159047fSniklas #include <stdio.h>
762159047fSniklas #ifdef HAVE_STRING_H
772159047fSniklas #include <string.h>
782159047fSniklas #else
790c6d0228Sniklas #ifdef HAVE_STRINGS_H
802159047fSniklas #include <strings.h>
812159047fSniklas #endif
820c6d0228Sniklas #endif
832159047fSniklas #ifdef HAVE_STDLIB_H
842159047fSniklas #include <stdlib.h>
852159047fSniklas #endif
862159047fSniklas #ifdef HAVE_UNISTD_H
872159047fSniklas #include <unistd.h>
882159047fSniklas #endif
892159047fSniklas #ifdef HAVE_SYS_TYPES_H
902159047fSniklas /* for size_t, pid_t */
912159047fSniklas #include <sys/types.h>
922159047fSniklas #endif
932159047fSniklas 
94c074d1c9Sdrahn #include "getopt.h"
952159047fSniklas /* The first getopt value for machine-independent long options.
962159047fSniklas    150 isn't special; it's just an arbitrary non-ASCII char value.  */
972159047fSniklas #define OPTION_STD_BASE 150
982159047fSniklas /* The first getopt value for machine-dependent long options.
99b55d4692Sfgsch    190 gives the standard options room to grow.  */
100b55d4692Sfgsch #define OPTION_MD_BASE 190
1012159047fSniklas 
1022159047fSniklas #ifdef DEBUG
1032159047fSniklas #undef NDEBUG
1042159047fSniklas #endif
105b305b0f1Sespie #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
1062159047fSniklas #define __PRETTY_FUNCTION__  ((char*)0)
1072159047fSniklas #endif
1082159047fSniklas #if 0
1092159047fSniklas 
1102159047fSniklas /* Handle lossage with assert.h.  */
1112159047fSniklas #ifndef BROKEN_ASSERT
1122159047fSniklas #include <assert.h>
1132159047fSniklas #else /* BROKEN_ASSERT */
1142159047fSniklas #ifndef NDEBUG
1152159047fSniklas #define assert(p) ((p) ? 0 : (as_assert (__FILE__, __LINE__, __PRETTY_FUNCTION__), 0))
1162159047fSniklas #else
1172159047fSniklas #define assert(p) ((p), 0)
1182159047fSniklas #endif
1192159047fSniklas #endif /* BROKEN_ASSERT */
1202159047fSniklas 
1212159047fSniklas #else
1222159047fSniklas 
1232159047fSniklas #define assert(P) ((P) ? 0 : (as_assert (__FILE__, __LINE__, __PRETTY_FUNCTION__), 0))
1242159047fSniklas #undef abort
1252159047fSniklas #define abort()		as_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
1262159047fSniklas 
1272159047fSniklas #endif
1282159047fSniklas 
1292159047fSniklas /* Now GNU header files...  */
130b305b0f1Sespie #include "ansidecl.h"
1312159047fSniklas #ifdef BFD_ASSEMBLER
132b305b0f1Sespie #include "bfd.h"
1332159047fSniklas #endif
134b305b0f1Sespie #include "libiberty.h"
1352159047fSniklas 
1362159047fSniklas /* Define the standard progress macros.  */
137b305b0f1Sespie #include "progress.h"
1382159047fSniklas 
1392159047fSniklas /* This doesn't get taken care of anywhere.  */
1402159047fSniklas #ifndef __MWERKS__  /* Metrowerks C chokes on the "defined (inline)" */
1412159047fSniklas #if !defined (__GNUC__) && !defined (inline)
1422159047fSniklas #define inline
1432159047fSniklas #endif
1442159047fSniklas #endif /* !__MWERKS__ */
1452159047fSniklas 
1462159047fSniklas /* Other stuff from config.h.  */
1470c6d0228Sniklas #ifdef NEED_DECLARATION_STRSTR
1480c6d0228Sniklas extern char *strstr ();
1490c6d0228Sniklas #endif
1502159047fSniklas #ifdef NEED_DECLARATION_MALLOC
1512159047fSniklas extern PTR malloc ();
1522159047fSniklas extern PTR realloc ();
1532159047fSniklas #endif
1542159047fSniklas #ifdef NEED_DECLARATION_FREE
1552159047fSniklas extern void free ();
1562159047fSniklas #endif
1572159047fSniklas #ifdef NEED_DECLARATION_ERRNO
1582159047fSniklas extern int errno;
1592159047fSniklas #endif
160b305b0f1Sespie #ifdef NEED_DECLARATION_ENVIRON
161b305b0f1Sespie extern char **environ;
162b305b0f1Sespie #endif
1632159047fSniklas 
1642159047fSniklas /* This is needed for VMS.  */
1652159047fSniklas #if ! defined (HAVE_UNLINK) && defined (HAVE_REMOVE)
1662159047fSniklas #define unlink remove
1672159047fSniklas #endif
1682159047fSniklas 
1692159047fSniklas /* Hack to make "gcc -Wall" not complain about obstack macros.  */
1702159047fSniklas #if !defined (memcpy) && !defined (bcopy)
1712159047fSniklas #define bcopy(src,dest,size)	memcpy (dest, src, size)
1722159047fSniklas #endif
1732159047fSniklas 
1742159047fSniklas /* Make Saber happier on obstack.h.  */
1752159047fSniklas #ifdef SABER
1762159047fSniklas #undef  __PTR_TO_INT
1772159047fSniklas #define __PTR_TO_INT(P) ((int) (P))
1782159047fSniklas #undef  __INT_TO_PTR
1792159047fSniklas #define __INT_TO_PTR(P) ((char *) (P))
1802159047fSniklas #endif
1812159047fSniklas 
1822159047fSniklas #ifndef __LINE__
1832159047fSniklas #define __LINE__ "unknown"
1842159047fSniklas #endif /* __LINE__ */
1852159047fSniklas 
1862159047fSniklas #ifndef __FILE__
1872159047fSniklas #define __FILE__ "unknown"
1882159047fSniklas #endif /* __FILE__ */
1892159047fSniklas 
1902159047fSniklas #ifndef FOPEN_WB
191c074d1c9Sdrahn #if defined GO32 || defined __MINGW32__
1922159047fSniklas #include "fopen-bin.h"
1932159047fSniklas #else
1942159047fSniklas #include "fopen-same.h"
1952159047fSniklas #endif
1962159047fSniklas #endif
1972159047fSniklas 
1982159047fSniklas #ifndef EXIT_SUCCESS
1992159047fSniklas #define EXIT_SUCCESS 0
2002159047fSniklas #define EXIT_FAILURE 1
2012159047fSniklas #endif
2022159047fSniklas 
203b305b0f1Sespie #ifndef SEEK_SET
204b305b0f1Sespie #define SEEK_SET 0
205b305b0f1Sespie #endif
206b305b0f1Sespie 
2072159047fSniklas #define obstack_chunk_alloc xmalloc
2082159047fSniklas #define obstack_chunk_free xfree
2092159047fSniklas 
2102159047fSniklas #define xfree free
2112159047fSniklas 
212b305b0f1Sespie #include "asintl.h"
213b305b0f1Sespie 
2142159047fSniklas #define BAD_CASE(val)							    \
2152159047fSniklas   {									    \
216b305b0f1Sespie     as_fatal (_("Case value %ld unexpected at line %d of file \"%s\"\n"),   \
2172159047fSniklas 	      (long) val, __LINE__, __FILE__);				    \
2182159047fSniklas   }
2192159047fSniklas 
2202159047fSniklas #include "flonum.h"
2212159047fSniklas 
2222159047fSniklas /* These are assembler-wide concepts */
2232159047fSniklas 
2242159047fSniklas #ifdef BFD_ASSEMBLER
2252159047fSniklas extern bfd *stdoutput;
2262159047fSniklas typedef bfd_vma addressT;
2272159047fSniklas typedef bfd_signed_vma offsetT;
2282159047fSniklas #else
2292159047fSniklas typedef unsigned long addressT;
2302159047fSniklas typedef long offsetT;
2312159047fSniklas #endif
2322159047fSniklas 
2332159047fSniklas /* Type of symbol value, etc.  For use in prototypes.  */
2342159047fSniklas typedef addressT valueT;
2352159047fSniklas 
2362159047fSniklas #ifndef COMMON
2372159047fSniklas #ifdef TEST
2382159047fSniklas #define COMMON			/* declare our COMMONs storage here.  */
2392159047fSniklas #else
240007c2a45Smiod #define COMMON extern		/* our commons live elsewhere */
2412159047fSniklas #endif
2422159047fSniklas #endif
2432159047fSniklas /* COMMON now defined */
2442159047fSniklas 
2452159047fSniklas #ifdef DEBUG
2462159047fSniklas #ifndef know
2472159047fSniklas #define know(p) assert(p)	/* Verify our assumptions! */
2482159047fSniklas #endif /* not yet defined */
2492159047fSniklas #else
2502159047fSniklas #define know(p)			/* know() checks are no-op.ed */
2512159047fSniklas #endif
2522159047fSniklas 
2532159047fSniklas /* input_scrub.c */
2542159047fSniklas 
255b55d4692Sfgsch /* Supplies sanitised buffers to read.c.
256b55d4692Sfgsch    Also understands printing line-number part of error messages.  */
2572159047fSniklas 
2582159047fSniklas /* subsegs.c     Sub-segments. Also, segment(=expression type)s.*/
2592159047fSniklas 
2602159047fSniklas #ifndef BFD_ASSEMBLER
2612159047fSniklas 
2622159047fSniklas #ifdef MANY_SEGMENTS
2632159047fSniklas #include "bfd.h"
264191aa565Sniklas #define N_SEGMENTS 40
265191aa565Sniklas #define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E39)
266191aa565Sniklas #define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9,\
267191aa565Sniklas 		 SEG_E10,SEG_E11,SEG_E12,SEG_E13,SEG_E14,SEG_E15,SEG_E16,SEG_E17,SEG_E18,SEG_E19,\
268191aa565Sniklas 		 SEG_E20,SEG_E21,SEG_E22,SEG_E23,SEG_E24,SEG_E25,SEG_E26,SEG_E27,SEG_E28,SEG_E29,\
269191aa565Sniklas 		 SEG_E30,SEG_E31,SEG_E32,SEG_E33,SEG_E34,SEG_E35,SEG_E36,SEG_E37,SEG_E38,SEG_E39
2702159047fSniklas #define SEG_TEXT SEG_E0
2712159047fSniklas #define SEG_DATA SEG_E1
2722159047fSniklas #define SEG_BSS SEG_E2
273191aa565Sniklas #define SEG_LAST SEG_E39
2742159047fSniklas #else
2752159047fSniklas #define N_SEGMENTS 3
2762159047fSniklas #define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS)
2772159047fSniklas #define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS
2782159047fSniklas #endif
2792159047fSniklas 
280b55d4692Sfgsch typedef enum _segT {
2812159047fSniklas   SEG_ABSOLUTE = 0,
2822159047fSniklas   SEG_LIST,
2832159047fSniklas   SEG_UNKNOWN,
2842159047fSniklas   SEG_GOOF,			/* Only happens if AS has a logic error.  */
2852159047fSniklas   /* Invented so we don't crash printing */
2862159047fSniklas   /* error message involving weird segment.  */
2872159047fSniklas   SEG_EXPR,			/* Intermediate expression values.  */
2882159047fSniklas   SEG_DEBUG,			/* Debug segment */
2892159047fSniklas   SEG_NTV,			/* Transfert vector preload segment */
2902159047fSniklas   SEG_PTV,			/* Transfert vector postload segment */
2912159047fSniklas   SEG_REGISTER			/* Mythical: a register-valued expression */
2922159047fSniklas } segT;
2932159047fSniklas 
2942159047fSniklas #define SEG_MAXIMUM_ORDINAL (SEG_REGISTER)
2952159047fSniklas #else
2962159047fSniklas typedef asection *segT;
2972159047fSniklas #define SEG_NORMAL(SEG)		((SEG) != absolute_section	\
2982159047fSniklas 				 && (SEG) != undefined_section	\
2992159047fSniklas 				 && (SEG) != reg_section	\
3002159047fSniklas 				 && (SEG) != expr_section)
3012159047fSniklas #endif
3022159047fSniklas typedef int subsegT;
3032159047fSniklas 
304007c2a45Smiod /* What subseg we are accessing now? */
3052159047fSniklas COMMON subsegT now_subseg;
3062159047fSniklas 
3072159047fSniklas /* Segment our instructions emit to.  */
3082159047fSniklas COMMON segT now_seg;
3092159047fSniklas 
3102159047fSniklas #ifdef BFD_ASSEMBLER
3112159047fSniklas #define segment_name(SEG)	bfd_get_section_name (stdoutput, SEG)
3122159047fSniklas #else
3132159047fSniklas extern char const *const seg_name[];
3142159047fSniklas #define segment_name(SEG)	seg_name[(int) (SEG)]
3152159047fSniklas #endif
3162159047fSniklas 
3172159047fSniklas #ifndef BFD_ASSEMBLER
3182159047fSniklas extern int section_alignment[];
3192159047fSniklas #endif
3202159047fSniklas 
3212159047fSniklas #ifdef BFD_ASSEMBLER
3222159047fSniklas extern segT reg_section, expr_section;
3232159047fSniklas /* Shouldn't these be eliminated someday?  */
3242159047fSniklas extern segT text_section, data_section, bss_section;
3252159047fSniklas #define absolute_section	bfd_abs_section_ptr
3262159047fSniklas #define undefined_section	bfd_und_section_ptr
3272159047fSniklas #else
3282159047fSniklas #define reg_section		SEG_REGISTER
3292159047fSniklas #define expr_section		SEG_EXPR
3302159047fSniklas #define text_section		SEG_TEXT
3312159047fSniklas #define data_section		SEG_DATA
3322159047fSniklas #define bss_section		SEG_BSS
3332159047fSniklas #define absolute_section	SEG_ABSOLUTE
3342159047fSniklas #define undefined_section	SEG_UNKNOWN
3352159047fSniklas #endif
3362159047fSniklas 
3372159047fSniklas /* relax() */
3382159047fSniklas 
339b55d4692Sfgsch enum _relax_state {
3402159047fSniklas   /* Variable chars to be repeated fr_offset times.
3412159047fSniklas      Fr_symbol unused. Used with fr_offset == 0 for a
3422159047fSniklas      constant length frag.  */
3432159047fSniklas   rs_fill = 1,
3442159047fSniklas 
345b305b0f1Sespie   /* Align.  The fr_offset field holds the power of 2 to which to
346b305b0f1Sespie      align.  The fr_var field holds the number of characters in the
347b305b0f1Sespie      fill pattern.  The fr_subtype field holds the maximum number of
348b305b0f1Sespie      bytes to skip when aligning, or 0 if there is no maximum.  */
3492159047fSniklas   rs_align,
3502159047fSniklas 
351b305b0f1Sespie   /* Align code.  The fr_offset field holds the power of 2 to which
352b305b0f1Sespie      to align.  This type is only generated by machine specific
353b305b0f1Sespie      code, which is normally responsible for handling the fill
354b305b0f1Sespie      pattern.  The fr_subtype field holds the maximum number of
355b305b0f1Sespie      bytes to skip when aligning, or 0 if there is no maximum.  */
3562159047fSniklas   rs_align_code,
3572159047fSniklas 
358b55d4692Sfgsch   /* Test for alignment.  Like rs_align, but used by several targets
359b55d4692Sfgsch      to warn if data is not properly aligned.  */
360b55d4692Sfgsch   rs_align_test,
361b55d4692Sfgsch 
3622159047fSniklas   /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
3632159047fSniklas      character.  */
3642159047fSniklas   rs_org,
3652159047fSniklas 
3662159047fSniklas #ifndef WORKING_DOT_WORD
3672159047fSniklas   /* JF: gunpoint */
3682159047fSniklas   rs_broken_word,
3692159047fSniklas #endif
3702159047fSniklas 
3712159047fSniklas   /* machine-specific relaxable (or similarly alterable) instruction */
3722159047fSniklas   rs_machine_dependent,
3732159047fSniklas 
3742159047fSniklas   /* .space directive with expression operand that needs to be computed
3752159047fSniklas      later.  Similar to rs_org, but different.
3762159047fSniklas      fr_symbol: operand
3772159047fSniklas      1 variable char: fill character  */
378b305b0f1Sespie   rs_space,
379b305b0f1Sespie 
380b305b0f1Sespie   /* A DWARF leb128 value; only ELF uses this.  The subtype is 0 for
381b305b0f1Sespie      unsigned, 1 for signed.  */
382b305b0f1Sespie   rs_leb128,
383b305b0f1Sespie 
384b305b0f1Sespie   /* Exception frame information which we may be able to optimize.  */
385b55d4692Sfgsch   rs_cfa,
386b55d4692Sfgsch 
387b55d4692Sfgsch   /* Cross-fragment dwarf2 line number optimization.  */
388b55d4692Sfgsch   rs_dwarf2dbg
3892159047fSniklas };
3902159047fSniklas 
3912159047fSniklas typedef enum _relax_state relax_stateT;
3922159047fSniklas 
3932159047fSniklas /* This type is used in prototypes, so it can't be a type that will be
3942159047fSniklas    widened for argument passing.  */
3952159047fSniklas typedef unsigned int relax_substateT;
3962159047fSniklas 
3972159047fSniklas /* Enough bits for address, but still an integer type.
3982159047fSniklas    Could be a problem, cross-assembling for 64-bit machines.  */
3992159047fSniklas typedef addressT relax_addressT;
400*dfad4a00Skettenis 
401*dfad4a00Skettenis struct relax_type
402*dfad4a00Skettenis {
403*dfad4a00Skettenis   /* Forward reach. Signed number. > 0.  */
404*dfad4a00Skettenis   long rlx_forward;
405*dfad4a00Skettenis   /* Backward reach. Signed number. < 0.  */
406*dfad4a00Skettenis   long rlx_backward;
407*dfad4a00Skettenis 
408*dfad4a00Skettenis   /* Bytes length of this address.  */
409*dfad4a00Skettenis   unsigned char rlx_length;
410*dfad4a00Skettenis 
411*dfad4a00Skettenis   /* Next longer relax-state.  0 means there is no 'next' relax-state.  */
412*dfad4a00Skettenis   relax_substateT rlx_more;
413*dfad4a00Skettenis };
414*dfad4a00Skettenis 
415*dfad4a00Skettenis typedef struct relax_type relax_typeS;
4162159047fSniklas 
4172159047fSniklas /* main program "as.c" (command arguments etc) */
4182159047fSniklas 
4192159047fSniklas COMMON unsigned char flag_no_comments; /* -f */
4202159047fSniklas COMMON unsigned char flag_debug; /* -D */
4212159047fSniklas COMMON unsigned char flag_signed_overflow_ok; /* -J */
4222159047fSniklas #ifndef WORKING_DOT_WORD
4232159047fSniklas COMMON unsigned char flag_warn_displacement; /* -K */
4242159047fSniklas #endif
4252159047fSniklas 
4262159047fSniklas /* True if local symbols should be retained.  */
4272159047fSniklas COMMON int flag_keep_locals; /* -L */
4282159047fSniklas 
429191aa565Sniklas /* True if we are assembling in MRI mode.  */
4302159047fSniklas COMMON int flag_mri;
4312159047fSniklas 
4322159047fSniklas /* Should the data section be made read-only and appended to the text
4332159047fSniklas    section?  */
4342159047fSniklas COMMON unsigned char flag_readonly_data_in_text; /* -R */
4352159047fSniklas 
4362159047fSniklas /* True if warnings should be inhibited.  */
4372159047fSniklas COMMON int flag_no_warnings; /* -W */
4382159047fSniklas 
439b305b0f1Sespie /* True if warnings count as errors.  */
440b305b0f1Sespie COMMON int flag_fatal_warnings; /* --fatal-warnings */
441b305b0f1Sespie 
4422159047fSniklas /* True if we should attempt to generate output even if non-fatal errors
4432159047fSniklas    are detected.  */
4442159047fSniklas COMMON unsigned char flag_always_generate_output; /* -Z */
4452159047fSniklas 
4462159047fSniklas /* This is true if the assembler should output time and space usage.  */
4472159047fSniklas COMMON unsigned char flag_print_statistics;
4482159047fSniklas 
449b305b0f1Sespie /* True if local absolute symbols are to be stripped.  */
450b305b0f1Sespie COMMON int flag_strip_local_absolute;
451b305b0f1Sespie 
452b305b0f1Sespie /* True if we should generate a traditional format object file.  */
453b305b0f1Sespie COMMON int flag_traditional_format;
454e93f7393Sniklas 
455007c2a45Smiod /* TRUE if .note.GNU-stack section with SEC_CODE should be created */
456007c2a45Smiod COMMON int flag_execstack;
457007c2a45Smiod 
458007c2a45Smiod /* TRUE if .note.GNU-stack section with SEC_CODE should be created */
459007c2a45Smiod COMMON int flag_noexecstack;
460007c2a45Smiod 
4612159047fSniklas /* name of emitted object file */
4622159047fSniklas COMMON char *out_file_name;
4632159047fSniklas 
464b305b0f1Sespie /* name of file defining extensions to the basic instruction set */
465b305b0f1Sespie COMMON char *insttbl_file_name;
466b305b0f1Sespie 
4672159047fSniklas /* TRUE if we need a second pass.  */
4682159047fSniklas COMMON int need_pass_2;
4692159047fSniklas 
4702159047fSniklas /* TRUE if we should do no relaxing, and
4712159047fSniklas    leave lots of padding.  */
4722159047fSniklas COMMON int linkrelax;
4732159047fSniklas 
4742159047fSniklas /* TRUE if we should produce a listing.  */
4752159047fSniklas extern int listing;
4762159047fSniklas 
477b55d4692Sfgsch /* Type of debugging information we should generate.  We currently support
478b55d4692Sfgsch    stabs, ECOFF, and DWARF2.
479b305b0f1Sespie 
480b55d4692Sfgsch    NOTE!  This means debug information about the assembly source code itself
481b55d4692Sfgsch    and _not_ about possible debug information from a high-level language.
482b55d4692Sfgsch    This is especially relevant to DWARF2, since the compiler may emit line
483b55d4692Sfgsch    number directives that the assembler resolves.  */
484b55d4692Sfgsch 
485b55d4692Sfgsch enum debug_info_type {
486b305b0f1Sespie   DEBUG_UNSPECIFIED,
487b305b0f1Sespie   DEBUG_NONE,
488b305b0f1Sespie   DEBUG_STABS,
489b305b0f1Sespie   DEBUG_ECOFF,
490b305b0f1Sespie   DEBUG_DWARF,
491b305b0f1Sespie   DEBUG_DWARF2
492b305b0f1Sespie };
493b305b0f1Sespie 
494b305b0f1Sespie extern enum debug_info_type debug_type;
495007c2a45Smiod extern int use_gnu_debug_info_extensions;
496b305b0f1Sespie 
4972159047fSniklas /* Maximum level of macro nesting.  */
4982159047fSniklas extern int max_macro_nest;
4992159047fSniklas 
500007c2a45Smiod /* Verbosity level.  */
501007c2a45Smiod extern int verbose;
502007c2a45Smiod 
5032159047fSniklas /* Obstack chunk size.  Keep large for efficient space use, make small to
5042159047fSniklas    increase malloc calls for monitoring memory allocation.  */
5052159047fSniklas extern int chunksize;
5062159047fSniklas 
507b55d4692Sfgsch struct _pseudo_type {
5082159047fSniklas   /* assembler mnemonic, lower case, no '.' */
5092159047fSniklas   const char *poc_name;
5102159047fSniklas   /* Do the work */
511007c2a45Smiod   void (*poc_handler) (int);
5122159047fSniklas   /* Value to pass to handler */
5132159047fSniklas   int poc_val;
5142159047fSniklas };
5152159047fSniklas 
5162159047fSniklas typedef struct _pseudo_type pseudo_typeS;
5172159047fSniklas 
5182159047fSniklas /* Prefer varargs for non-ANSI compiler, since some will barf if the
5192159047fSniklas    ellipsis definition is used with a no-arguments declaration.  */
5202159047fSniklas #if defined (HAVE_VARARGS_H) && !defined (__STDC__)
5212159047fSniklas #undef HAVE_STDARG_H
5222159047fSniklas #endif
5232159047fSniklas 
5242159047fSniklas #if defined (HAVE_STDARG_H)
5252159047fSniklas #define USE_STDARG
5262159047fSniklas #endif
5272159047fSniklas #if !defined (USE_STDARG) && defined (HAVE_VARARGS_H)
5282159047fSniklas #define USE_VARARGS
5292159047fSniklas #endif
5302159047fSniklas 
5312159047fSniklas #ifdef USE_STDARG
5320c6d0228Sniklas #if (__GNUC__ >= 2) && !defined(VMS)
5332159047fSniklas /* for use with -Wformat */
534b305b0f1Sespie 
535b305b0f1Sespie #if __GNUC__ == 2 && __GNUC_MINOR__ < 6
536b305b0f1Sespie /* Support for double underscores in attribute names was added in gcc
537b305b0f1Sespie    2.6, so avoid them if we are using an earlier version.  */
538b305b0f1Sespie #define __printf__ printf
539b305b0f1Sespie #define __format__ format
540b305b0f1Sespie #endif
541b305b0f1Sespie 
542b305b0f1Sespie #define PRINTF_LIKE(FCN) \
543b305b0f1Sespie   void FCN (const char *format, ...) \
544b305b0f1Sespie     __attribute__ ((__format__ (__printf__, 1, 2)))
545b305b0f1Sespie #define PRINTF_WHERE_LIKE(FCN) \
546b305b0f1Sespie   void FCN (char *file, unsigned int line, const char *format, ...) \
547b305b0f1Sespie     __attribute__ ((__format__ (__printf__, 3, 4)))
548b305b0f1Sespie 
549b305b0f1Sespie #else /* __GNUC__ < 2 || defined(VMS) */
550b305b0f1Sespie 
551007c2a45Smiod #define PRINTF_LIKE(FCN)	void FCN (const char *format, ...)
552007c2a45Smiod #define PRINTF_WHERE_LIKE(FCN)	void FCN (char *file, \
5532159047fSniklas 					  unsigned int line, \
554007c2a45Smiod 					  const char *format, ...)
555b305b0f1Sespie 
556b305b0f1Sespie #endif /* __GNUC__ < 2 || defined(VMS) */
557b305b0f1Sespie 
558b305b0f1Sespie #else /* ! USE_STDARG */
559b305b0f1Sespie 
5602159047fSniklas #define PRINTF_LIKE(FCN)	void FCN ()
5612159047fSniklas #define PRINTF_WHERE_LIKE(FCN)	void FCN ()
562b305b0f1Sespie 
563b305b0f1Sespie #endif /* ! USE_STDARG */
5642159047fSniklas 
5652159047fSniklas PRINTF_LIKE (as_bad);
566b305b0f1Sespie PRINTF_LIKE (as_fatal) ATTRIBUTE_NORETURN;
5672159047fSniklas PRINTF_LIKE (as_tsktsk);
5682159047fSniklas PRINTF_LIKE (as_warn);
5692159047fSniklas PRINTF_WHERE_LIKE (as_bad_where);
5702159047fSniklas PRINTF_WHERE_LIKE (as_warn_where);
571b305b0f1Sespie 
572007c2a45Smiod void as_assert (const char *, int, const char *);
573007c2a45Smiod void as_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
5742159047fSniklas 
575007c2a45Smiod void fprint_value (FILE *file, addressT value);
576007c2a45Smiod void sprint_value (char *buf, addressT value);
5772159047fSniklas 
578007c2a45Smiod int had_errors (void);
579007c2a45Smiod int had_warnings (void);
5802159047fSniklas 
581007c2a45Smiod void print_version_id (void);
582007c2a45Smiod char *app_push (void);
583007c2a45Smiod char *atof_ieee (char *str, int what_kind, LITTLENUM_TYPE * words);
584007c2a45Smiod char *input_scrub_include_file (char *filename, char *position);
585007c2a45Smiod extern void input_scrub_insert_line (const char *line);
586007c2a45Smiod extern void input_scrub_insert_file (char *path);
587007c2a45Smiod char *input_scrub_new_file (char *filename);
588007c2a45Smiod char *input_scrub_next_buffer (char **bufp);
589007c2a45Smiod int do_scrub_chars (int (*get) (char *, int), char *to, int tolen);
590007c2a45Smiod int gen_to_words (LITTLENUM_TYPE * words, int precision,
591007c2a45Smiod 			  long exponent_bits);
592007c2a45Smiod int had_err (void);
593007c2a45Smiod int ignore_input (void);
594007c2a45Smiod void cond_finish_check (int);
595007c2a45Smiod void cond_exit_macro (int);
596007c2a45Smiod int seen_at_least_1_file (void);
597007c2a45Smiod void app_pop (char *arg);
598007c2a45Smiod void as_howmuch (FILE * stream);
599007c2a45Smiod void as_perror (const char *gripe, const char *filename);
600007c2a45Smiod void as_where (char **namep, unsigned int *linep);
601007c2a45Smiod void bump_line_counters (void);
602007c2a45Smiod void do_scrub_begin (int);
603007c2a45Smiod void input_scrub_begin (void);
604007c2a45Smiod void input_scrub_close (void);
605007c2a45Smiod void input_scrub_end (void);
606007c2a45Smiod int new_logical_line (char *fname, int line_number);
607007c2a45Smiod void subsegs_begin (void);
608007c2a45Smiod void subseg_change (segT seg, int subseg);
609007c2a45Smiod segT subseg_new (const char *name, subsegT subseg);
610007c2a45Smiod segT subseg_force_new (const char *name, subsegT subseg);
611007c2a45Smiod void subseg_set (segT seg, subsegT subseg);
6122159047fSniklas #ifdef BFD_ASSEMBLER
613007c2a45Smiod segT subseg_get (const char *, int);
6142159047fSniklas #endif
615007c2a45Smiod int subseg_text_p (segT);
616b305b0f1Sespie 
617007c2a45Smiod void start_dependencies (char *);
618007c2a45Smiod void register_dependency (char *);
619007c2a45Smiod void print_dependencies (void);
6202159047fSniklas 
6212159047fSniklas struct expressionS;
6222159047fSniklas struct fix;
623b305b0f1Sespie typedef struct symbol symbolS;
624b305b0f1Sespie typedef struct frag fragS;
6252159047fSniklas 
6262159047fSniklas #ifdef BFD_ASSEMBLER
6272159047fSniklas /* literal.c */
628007c2a45Smiod valueT add_to_literal_pool (symbolS *, valueT, segT, int);
6292159047fSniklas #endif
6302159047fSniklas 
631007c2a45Smiod int check_eh_frame (struct expressionS *, unsigned int *);
632007c2a45Smiod int eh_frame_estimate_size_before_relax (fragS *);
633007c2a45Smiod int eh_frame_relax_frag (fragS *);
634007c2a45Smiod void eh_frame_convert_frag (fragS *);
635b305b0f1Sespie 
636007c2a45Smiod int generic_force_reloc (struct fix *);
637c074d1c9Sdrahn 
6382159047fSniklas #include "expr.h"		/* Before targ-*.h */
6392159047fSniklas 
6402159047fSniklas /* this one starts the chain of target dependant headers */
6412159047fSniklas #include "targ-env.h"
6422159047fSniklas 
643c074d1c9Sdrahn #ifdef OBJ_MAYBE_ELF
644c074d1c9Sdrahn #define IS_ELF (OUTPUT_FLAVOR == bfd_target_elf_flavour)
645c074d1c9Sdrahn #else
646c074d1c9Sdrahn #ifdef OBJ_ELF
647c074d1c9Sdrahn #define IS_ELF 1
648c074d1c9Sdrahn #else
649c074d1c9Sdrahn #define IS_ELF 0
650c074d1c9Sdrahn #endif
651b55d4692Sfgsch #endif
652b55d4692Sfgsch 
6532159047fSniklas #include "write.h"
6542159047fSniklas #include "frags.h"
6552159047fSniklas #include "hash.h"
6562159047fSniklas #include "read.h"
6572159047fSniklas #include "symbols.h"
6582159047fSniklas 
6592159047fSniklas #include "tc.h"
6602159047fSniklas #include "obj.h"
6612159047fSniklas 
6622159047fSniklas #ifdef USE_EMULATIONS
6632159047fSniklas #include "emul.h"
6642159047fSniklas #endif
6652159047fSniklas #include "listing.h"
6662159047fSniklas 
667b305b0f1Sespie #ifdef TC_M68K
668b305b0f1Sespie /* True if we are assembling in m68k MRI mode.  */
669b305b0f1Sespie COMMON int flag_m68k_mri;
670b305b0f1Sespie #else
671b305b0f1Sespie #define flag_m68k_mri 0
672b305b0f1Sespie #endif
673b305b0f1Sespie 
674b55d4692Sfgsch #ifdef WARN_COMMENTS
675b55d4692Sfgsch COMMON int warn_comment;
676b55d4692Sfgsch COMMON unsigned int found_comment;
677b55d4692Sfgsch COMMON char *found_comment_file;
678b55d4692Sfgsch #endif
679b55d4692Sfgsch 
680b305b0f1Sespie #ifndef NUMBERS_WITH_SUFFIX
681b305b0f1Sespie #define NUMBERS_WITH_SUFFIX 0
682b305b0f1Sespie #endif
683b305b0f1Sespie 
6842159047fSniklas #ifndef LOCAL_LABELS_DOLLAR
6852159047fSniklas #define LOCAL_LABELS_DOLLAR 0
6862159047fSniklas #endif
6872159047fSniklas 
6882159047fSniklas #ifndef LOCAL_LABELS_FB
6892159047fSniklas #define LOCAL_LABELS_FB 0
6902159047fSniklas #endif
6912159047fSniklas 
692b305b0f1Sespie #ifndef LABELS_WITHOUT_COLONS
693b305b0f1Sespie #define LABELS_WITHOUT_COLONS 0
694b305b0f1Sespie #endif
695b305b0f1Sespie 
696b305b0f1Sespie #ifndef NO_PSEUDO_DOT
697b305b0f1Sespie #define NO_PSEUDO_DOT 0
698b305b0f1Sespie #endif
699b305b0f1Sespie 
700b305b0f1Sespie #ifndef TEXT_SECTION_NAME
701b305b0f1Sespie #define TEXT_SECTION_NAME	".text"
702b305b0f1Sespie #define DATA_SECTION_NAME	".data"
703b305b0f1Sespie #define BSS_SECTION_NAME	".bss"
704b305b0f1Sespie #endif
705b305b0f1Sespie 
706b305b0f1Sespie #ifndef OCTETS_PER_BYTE_POWER
707b305b0f1Sespie #define OCTETS_PER_BYTE_POWER 0
708b305b0f1Sespie #endif
709b305b0f1Sespie #ifndef OCTETS_PER_BYTE
710b305b0f1Sespie #define OCTETS_PER_BYTE (1<<OCTETS_PER_BYTE_POWER)
711b305b0f1Sespie #endif
712b305b0f1Sespie #if OCTETS_PER_BYTE != (1<<OCTETS_PER_BYTE_POWER)
713b305b0f1Sespie  #error "Octets per byte conflicts with its power-of-two definition!"
714b305b0f1Sespie #endif
715b305b0f1Sespie 
7162159047fSniklas #endif /* GAS */
717