as.h revision 168433
133965Sjdp/* as.h - global header file 278828Sobrien Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 3168433Skan 1999, 2000, 2001, 2002, 2003, 2004, 2005 433965Sjdp Free Software Foundation, Inc. 533965Sjdp 633965Sjdp This file is part of GAS, the GNU Assembler. 733965Sjdp 833965Sjdp GAS is free software; you can redistribute it and/or modify 933965Sjdp it under the terms of the GNU General Public License as published by 1033965Sjdp the Free Software Foundation; either version 2, or (at your option) 1133965Sjdp any later version. 1233965Sjdp 1333965Sjdp GAS is distributed in the hope that it will be useful, 1433965Sjdp but WITHOUT ANY WARRANTY; without even the implied warranty of 1533965Sjdp MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1633965Sjdp GNU General Public License for more details. 1733965Sjdp 1833965Sjdp You should have received a copy of the GNU General Public License 1933965Sjdp along with GAS; see the file COPYING. If not, write to the Free 2033965Sjdp Software Foundation, 59 Temple Place - Suite 330, Boston, MA 2133965Sjdp 02111-1307, USA. */ 2233965Sjdp 2333965Sjdp#ifndef GAS 2433965Sjdp#define GAS 1 2577298Sobrien/* I think this stuff is largely out of date. xoxorich. 2633965Sjdp * 2733965Sjdp * CAPITALISED names are #defined. 2833965Sjdp * "lowercaseH" is #defined if "lowercase.h" has been #include-d. 2933965Sjdp * "lowercaseT" is a typedef of "lowercase" objects. 3033965Sjdp * "lowercaseP" is type "pointer to object of type 'lowercase'". 3133965Sjdp * "lowercaseS" is typedef struct ... lowercaseS. 3233965Sjdp * 3333965Sjdp * #define DEBUG to enable all the "know" assertion tests. 3433965Sjdp * #define SUSPECT when debugging hash code. 3533965Sjdp * #define COMMON as "extern" for all modules except one, where you #define 3633965Sjdp * COMMON as "". 3733965Sjdp * If TEST is #defined, then we are testing a module: #define COMMON as "". 3833965Sjdp */ 3933965Sjdp 4033965Sjdp#include "config.h" 4160484Sobrien#include "bin-bugs.h" 4233965Sjdp 4333965Sjdp/* This is the code recommended in the autoconf documentation, almost 4433965Sjdp verbatim. If it doesn't work for you, let me know, and notify 4533965Sjdp djm@gnu.ai.mit.edu as well. */ 4633965Sjdp/* Added void* version for STDC case. This is to be compatible with 4733965Sjdp the declaration in bison.simple, used for m68k operand parsing. 4833965Sjdp --KR 1995.08.08 */ 4933965Sjdp/* Force void* decl for hpux. This is what Bison uses. --KR 1995.08.16 */ 5033965Sjdp 5189857Sobrien#ifndef __GNUC__ 5233965Sjdp# if HAVE_ALLOCA_H 5333965Sjdp# include <alloca.h> 5433965Sjdp# else 5533965Sjdp# ifdef _AIX 5689857Sobrien/* Indented so that pre-ansi C compilers will ignore it, rather than 5789857Sobrien choke on it. Some versions of AIX require this to be the first 5889857Sobrien thing in the file. */ 5933965Sjdp #pragma alloca 6033965Sjdp# else 6133965Sjdp# ifndef alloca /* predefined by HP cc +Olibcalls */ 6233965Sjdp# if !defined (__STDC__) && !defined (__hpux) 6338889Sjdpextern char *alloca (); 6433965Sjdp# else 6538889Sjdpextern void *alloca (); 6633965Sjdp# endif /* __STDC__, __hpux */ 6733965Sjdp# endif /* alloca */ 6833965Sjdp# endif /* _AIX */ 6933965Sjdp# endif /* HAVE_ALLOCA_H */ 7089857Sobrien#endif /* __GNUC__ */ 7133965Sjdp 7233965Sjdp/* Now, tend to the rest of the configuration. */ 7333965Sjdp 7477298Sobrien/* System include files first... */ 7533965Sjdp#include <stdio.h> 7633965Sjdp#ifdef HAVE_STRING_H 7733965Sjdp#include <string.h> 7833965Sjdp#else 7933965Sjdp#ifdef HAVE_STRINGS_H 8033965Sjdp#include <strings.h> 8133965Sjdp#endif 8233965Sjdp#endif 8333965Sjdp#ifdef HAVE_STDLIB_H 8433965Sjdp#include <stdlib.h> 8533965Sjdp#endif 8633965Sjdp#ifdef HAVE_UNISTD_H 8733965Sjdp#include <unistd.h> 8833965Sjdp#endif 8933965Sjdp#ifdef HAVE_SYS_TYPES_H 9033965Sjdp/* for size_t, pid_t */ 9133965Sjdp#include <sys/types.h> 9233965Sjdp#endif 9333965Sjdp 94104834Sobrien#include "getopt.h" 9533965Sjdp/* The first getopt value for machine-independent long options. 9633965Sjdp 150 isn't special; it's just an arbitrary non-ASCII char value. */ 9733965Sjdp#define OPTION_STD_BASE 150 9833965Sjdp/* The first getopt value for machine-dependent long options. 9977298Sobrien 190 gives the standard options room to grow. */ 10077298Sobrien#define OPTION_MD_BASE 190 10133965Sjdp 10233965Sjdp#ifdef DEBUG 10333965Sjdp#undef NDEBUG 10433965Sjdp#endif 10560484Sobrien#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) 10633965Sjdp#define __PRETTY_FUNCTION__ ((char*)0) 10733965Sjdp#endif 10833965Sjdp#if 0 10933965Sjdp 11033965Sjdp/* Handle lossage with assert.h. */ 11133965Sjdp#ifndef BROKEN_ASSERT 11233965Sjdp#include <assert.h> 11333965Sjdp#else /* BROKEN_ASSERT */ 11433965Sjdp#ifndef NDEBUG 11533965Sjdp#define assert(p) ((p) ? 0 : (as_assert (__FILE__, __LINE__, __PRETTY_FUNCTION__), 0)) 11633965Sjdp#else 11733965Sjdp#define assert(p) ((p), 0) 11833965Sjdp#endif 11933965Sjdp#endif /* BROKEN_ASSERT */ 12033965Sjdp 12133965Sjdp#else 12233965Sjdp 12333965Sjdp#define assert(P) ((P) ? 0 : (as_assert (__FILE__, __LINE__, __PRETTY_FUNCTION__), 0)) 12433965Sjdp#undef abort 12533965Sjdp#define abort() as_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__) 12633965Sjdp 12733965Sjdp#endif 12833965Sjdp 12977298Sobrien/* Now GNU header files... */ 13060484Sobrien#include "ansidecl.h" 13133965Sjdp#ifdef BFD_ASSEMBLER 13260484Sobrien#include "bfd.h" 13333965Sjdp#endif 13460484Sobrien#include "libiberty.h" 13533965Sjdp 13633965Sjdp/* Define the standard progress macros. */ 13760484Sobrien#include "progress.h" 13833965Sjdp 13933965Sjdp/* This doesn't get taken care of anywhere. */ 14033965Sjdp#ifndef __MWERKS__ /* Metrowerks C chokes on the "defined (inline)" */ 14133965Sjdp#if !defined (__GNUC__) && !defined (inline) 14233965Sjdp#define inline 14333965Sjdp#endif 14433965Sjdp#endif /* !__MWERKS__ */ 14533965Sjdp 14633965Sjdp/* Other stuff from config.h. */ 14733965Sjdp#ifdef NEED_DECLARATION_STRSTR 14833965Sjdpextern char *strstr (); 14933965Sjdp#endif 15033965Sjdp#ifdef NEED_DECLARATION_MALLOC 15133965Sjdpextern PTR malloc (); 15233965Sjdpextern PTR realloc (); 15333965Sjdp#endif 15433965Sjdp#ifdef NEED_DECLARATION_FREE 15533965Sjdpextern void free (); 15633965Sjdp#endif 15733965Sjdp#ifdef NEED_DECLARATION_ERRNO 15833965Sjdpextern int errno; 15933965Sjdp#endif 16060484Sobrien#ifdef NEED_DECLARATION_ENVIRON 16160484Sobrienextern char **environ; 16260484Sobrien#endif 16333965Sjdp 16438889Sjdp/* This is needed for VMS. */ 16538889Sjdp#if ! defined (HAVE_UNLINK) && defined (HAVE_REMOVE) 16633965Sjdp#define unlink remove 16733965Sjdp#endif 16833965Sjdp 16933965Sjdp/* Hack to make "gcc -Wall" not complain about obstack macros. */ 17033965Sjdp#if !defined (memcpy) && !defined (bcopy) 171104834Sobrien#define bcopy(src,dest,size) memcpy (dest, src, size) 17233965Sjdp#endif 17333965Sjdp 17433965Sjdp/* Make Saber happier on obstack.h. */ 17533965Sjdp#ifdef SABER 17633965Sjdp#undef __PTR_TO_INT 17777298Sobrien#define __PTR_TO_INT(P) ((int) (P)) 17833965Sjdp#undef __INT_TO_PTR 17977298Sobrien#define __INT_TO_PTR(P) ((char *) (P)) 18033965Sjdp#endif 18133965Sjdp 18233965Sjdp#ifndef __LINE__ 18333965Sjdp#define __LINE__ "unknown" 18433965Sjdp#endif /* __LINE__ */ 18533965Sjdp 18633965Sjdp#ifndef __FILE__ 18733965Sjdp#define __FILE__ "unknown" 18833965Sjdp#endif /* __FILE__ */ 18933965Sjdp 19033965Sjdp#ifndef FOPEN_WB 191130561Sobrien#if defined GO32 || defined __MINGW32__ 19233965Sjdp#include "fopen-bin.h" 19333965Sjdp#else 19433965Sjdp#include "fopen-same.h" 19533965Sjdp#endif 19633965Sjdp#endif 19733965Sjdp 19833965Sjdp#ifndef EXIT_SUCCESS 19933965Sjdp#define EXIT_SUCCESS 0 20033965Sjdp#define EXIT_FAILURE 1 20133965Sjdp#endif 20233965Sjdp 20360484Sobrien#ifndef SEEK_SET 20460484Sobrien#define SEEK_SET 0 20560484Sobrien#endif 20660484Sobrien 20733965Sjdp#define obstack_chunk_alloc xmalloc 20833965Sjdp#define obstack_chunk_free xfree 20933965Sjdp 21033965Sjdp#define xfree free 21133965Sjdp 21260484Sobrien#include "asintl.h" 21360484Sobrien 21477298Sobrien#define BAD_CASE(val) \ 21577298Sobrien { \ 21677298Sobrien as_fatal (_("Case value %ld unexpected at line %d of file \"%s\"\n"), \ 21777298Sobrien (long) val, __LINE__, __FILE__); \ 21877298Sobrien } 21933965Sjdp 22033965Sjdp#include "flonum.h" 22133965Sjdp 22233965Sjdp/* These are assembler-wide concepts */ 22333965Sjdp 22433965Sjdp#ifdef BFD_ASSEMBLER 22533965Sjdpextern bfd *stdoutput; 22633965Sjdptypedef bfd_vma addressT; 22733965Sjdptypedef bfd_signed_vma offsetT; 22833965Sjdp#else 22933965Sjdptypedef unsigned long addressT; 23033965Sjdptypedef long offsetT; 23133965Sjdp#endif 23233965Sjdp 23333965Sjdp/* Type of symbol value, etc. For use in prototypes. */ 23433965Sjdptypedef addressT valueT; 23533965Sjdp 23633965Sjdp#ifndef COMMON 23733965Sjdp#ifdef TEST 23877298Sobrien#define COMMON /* declare our COMMONs storage here. */ 23933965Sjdp#else 240130561Sobrien#define COMMON extern /* our commons live elsewhere */ 24133965Sjdp#endif 24233965Sjdp#endif 24333965Sjdp/* COMMON now defined */ 24433965Sjdp 24533965Sjdp#ifdef DEBUG 24633965Sjdp#ifndef know 24733965Sjdp#define know(p) assert(p) /* Verify our assumptions! */ 24833965Sjdp#endif /* not yet defined */ 24933965Sjdp#else 25033965Sjdp#define know(p) /* know() checks are no-op.ed */ 25133965Sjdp#endif 25233965Sjdp 25333965Sjdp/* input_scrub.c */ 25433965Sjdp 25577298Sobrien/* Supplies sanitised buffers to read.c. 25677298Sobrien Also understands printing line-number part of error messages. */ 25733965Sjdp 25833965Sjdp/* subsegs.c Sub-segments. Also, segment(=expression type)s.*/ 25933965Sjdp 26033965Sjdp#ifndef BFD_ASSEMBLER 26133965Sjdp 26233965Sjdp#ifdef MANY_SEGMENTS 26333965Sjdp#include "bfd.h" 26433965Sjdp#define N_SEGMENTS 40 26533965Sjdp#define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E39) 26633965Sjdp#define SEG_LIST SEG_E0,SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9,\ 26733965Sjdp SEG_E10,SEG_E11,SEG_E12,SEG_E13,SEG_E14,SEG_E15,SEG_E16,SEG_E17,SEG_E18,SEG_E19,\ 26833965Sjdp SEG_E20,SEG_E21,SEG_E22,SEG_E23,SEG_E24,SEG_E25,SEG_E26,SEG_E27,SEG_E28,SEG_E29,\ 26933965Sjdp SEG_E30,SEG_E31,SEG_E32,SEG_E33,SEG_E34,SEG_E35,SEG_E36,SEG_E37,SEG_E38,SEG_E39 27033965Sjdp#define SEG_TEXT SEG_E0 27133965Sjdp#define SEG_DATA SEG_E1 27233965Sjdp#define SEG_BSS SEG_E2 27333965Sjdp#define SEG_LAST SEG_E39 27433965Sjdp#else 27533965Sjdp#define N_SEGMENTS 3 27633965Sjdp#define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS) 27733965Sjdp#define SEG_LIST SEG_TEXT,SEG_DATA,SEG_BSS 27833965Sjdp#endif 27933965Sjdp 28077298Sobrientypedef enum _segT { 28177298Sobrien SEG_ABSOLUTE = 0, 28277298Sobrien SEG_LIST, 28377298Sobrien SEG_UNKNOWN, 28477298Sobrien SEG_GOOF, /* Only happens if AS has a logic error. */ 28577298Sobrien /* Invented so we don't crash printing */ 28677298Sobrien /* error message involving weird segment. */ 28777298Sobrien SEG_EXPR, /* Intermediate expression values. */ 28877298Sobrien SEG_DEBUG, /* Debug segment */ 28977298Sobrien SEG_NTV, /* Transfert vector preload segment */ 29077298Sobrien SEG_PTV, /* Transfert vector postload segment */ 29177298Sobrien SEG_REGISTER /* Mythical: a register-valued expression */ 29277298Sobrien} segT; 29333965Sjdp 29433965Sjdp#define SEG_MAXIMUM_ORDINAL (SEG_REGISTER) 29533965Sjdp#else 29633965Sjdptypedef asection *segT; 29733965Sjdp#define SEG_NORMAL(SEG) ((SEG) != absolute_section \ 29833965Sjdp && (SEG) != undefined_section \ 29933965Sjdp && (SEG) != reg_section \ 30033965Sjdp && (SEG) != expr_section) 30133965Sjdp#endif 30233965Sjdptypedef int subsegT; 30333965Sjdp 304130561Sobrien/* What subseg we are accessing now? */ 30533965SjdpCOMMON subsegT now_subseg; 30633965Sjdp 30777298Sobrien/* Segment our instructions emit to. */ 30833965SjdpCOMMON segT now_seg; 30933965Sjdp 31033965Sjdp#ifdef BFD_ASSEMBLER 31133965Sjdp#define segment_name(SEG) bfd_get_section_name (stdoutput, SEG) 31233965Sjdp#else 31333965Sjdpextern char const *const seg_name[]; 31433965Sjdp#define segment_name(SEG) seg_name[(int) (SEG)] 31533965Sjdp#endif 31633965Sjdp 31733965Sjdp#ifndef BFD_ASSEMBLER 31833965Sjdpextern int section_alignment[]; 31933965Sjdp#endif 32033965Sjdp 32133965Sjdp#ifdef BFD_ASSEMBLER 32233965Sjdpextern segT reg_section, expr_section; 32333965Sjdp/* Shouldn't these be eliminated someday? */ 32433965Sjdpextern segT text_section, data_section, bss_section; 32533965Sjdp#define absolute_section bfd_abs_section_ptr 32633965Sjdp#define undefined_section bfd_und_section_ptr 32733965Sjdp#else 32833965Sjdp#define reg_section SEG_REGISTER 32933965Sjdp#define expr_section SEG_EXPR 33033965Sjdp#define text_section SEG_TEXT 33133965Sjdp#define data_section SEG_DATA 33233965Sjdp#define bss_section SEG_BSS 33333965Sjdp#define absolute_section SEG_ABSOLUTE 33433965Sjdp#define undefined_section SEG_UNKNOWN 33533965Sjdp#endif 33633965Sjdp 33733965Sjdp/* relax() */ 33833965Sjdp 33977298Sobrienenum _relax_state { 34077298Sobrien /* Variable chars to be repeated fr_offset times. 34177298Sobrien Fr_symbol unused. Used with fr_offset == 0 for a 34277298Sobrien constant length frag. */ 34377298Sobrien rs_fill = 1, 34433965Sjdp 34577298Sobrien /* Align. The fr_offset field holds the power of 2 to which to 34677298Sobrien align. The fr_var field holds the number of characters in the 34777298Sobrien fill pattern. The fr_subtype field holds the maximum number of 34877298Sobrien bytes to skip when aligning, or 0 if there is no maximum. */ 34977298Sobrien rs_align, 35033965Sjdp 35177298Sobrien /* Align code. The fr_offset field holds the power of 2 to which 35277298Sobrien to align. This type is only generated by machine specific 35377298Sobrien code, which is normally responsible for handling the fill 35477298Sobrien pattern. The fr_subtype field holds the maximum number of 35577298Sobrien bytes to skip when aligning, or 0 if there is no maximum. */ 35677298Sobrien rs_align_code, 35733965Sjdp 35877298Sobrien /* Test for alignment. Like rs_align, but used by several targets 35977298Sobrien to warn if data is not properly aligned. */ 36077298Sobrien rs_align_test, 36133965Sjdp 36277298Sobrien /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill 36377298Sobrien character. */ 36477298Sobrien rs_org, 36577298Sobrien 36633965Sjdp#ifndef WORKING_DOT_WORD 36777298Sobrien /* JF: gunpoint */ 36877298Sobrien rs_broken_word, 36933965Sjdp#endif 37033965Sjdp 37177298Sobrien /* machine-specific relaxable (or similarly alterable) instruction */ 37277298Sobrien rs_machine_dependent, 37333965Sjdp 37477298Sobrien /* .space directive with expression operand that needs to be computed 37577298Sobrien later. Similar to rs_org, but different. 37677298Sobrien fr_symbol: operand 37777298Sobrien 1 variable char: fill character */ 37877298Sobrien rs_space, 37938889Sjdp 38077298Sobrien /* A DWARF leb128 value; only ELF uses this. The subtype is 0 for 38177298Sobrien unsigned, 1 for signed. */ 38277298Sobrien rs_leb128, 38338889Sjdp 38477298Sobrien /* Exception frame information which we may be able to optimize. */ 38577298Sobrien rs_cfa, 38633965Sjdp 38777298Sobrien /* Cross-fragment dwarf2 line number optimization. */ 38877298Sobrien rs_dwarf2dbg 38977298Sobrien}; 39077298Sobrien 39133965Sjdptypedef enum _relax_state relax_stateT; 39233965Sjdp 39333965Sjdp/* This type is used in prototypes, so it can't be a type that will be 39433965Sjdp widened for argument passing. */ 39533965Sjdptypedef unsigned int relax_substateT; 39633965Sjdp 39733965Sjdp/* Enough bits for address, but still an integer type. 39833965Sjdp Could be a problem, cross-assembling for 64-bit machines. */ 39933965Sjdptypedef addressT relax_addressT; 400168433Skan 401168433Skanstruct relax_type 402168433Skan{ 403168433Skan /* Forward reach. Signed number. > 0. */ 404168433Skan offsetT rlx_forward; 405168433Skan /* Backward reach. Signed number. < 0. */ 406168433Skan offsetT rlx_backward; 407168433Skan 408168433Skan /* Bytes length of this address. */ 409168433Skan unsigned char rlx_length; 410168433Skan 411168433Skan /* Next longer relax-state. 0 means there is no 'next' relax-state. */ 412168433Skan relax_substateT rlx_more; 413168433Skan}; 414168433Skan 415168433Skantypedef struct relax_type relax_typeS; 41633965Sjdp 41733965Sjdp/* main program "as.c" (command arguments etc) */ 41833965Sjdp 41933965SjdpCOMMON unsigned char flag_no_comments; /* -f */ 42033965SjdpCOMMON unsigned char flag_debug; /* -D */ 42133965SjdpCOMMON unsigned char flag_signed_overflow_ok; /* -J */ 42233965Sjdp#ifndef WORKING_DOT_WORD 42333965SjdpCOMMON unsigned char flag_warn_displacement; /* -K */ 42433965Sjdp#endif 42533965Sjdp 42633965Sjdp/* True if local symbols should be retained. */ 42733965SjdpCOMMON int flag_keep_locals; /* -L */ 42833965Sjdp 42933965Sjdp/* True if we are assembling in MRI mode. */ 43033965SjdpCOMMON int flag_mri; 43133965Sjdp 43233965Sjdp/* Should the data section be made read-only and appended to the text 43333965Sjdp section? */ 43433965SjdpCOMMON unsigned char flag_readonly_data_in_text; /* -R */ 43533965Sjdp 43633965Sjdp/* True if warnings should be inhibited. */ 43733965SjdpCOMMON int flag_no_warnings; /* -W */ 43833965Sjdp 43960484Sobrien/* True if warnings count as errors. */ 44060484SobrienCOMMON int flag_fatal_warnings; /* --fatal-warnings */ 44160484Sobrien 44233965Sjdp/* True if we should attempt to generate output even if non-fatal errors 44333965Sjdp are detected. */ 44433965SjdpCOMMON unsigned char flag_always_generate_output; /* -Z */ 44533965Sjdp 44677298Sobrien/* This is true if the assembler should output time and space usage. */ 44733965SjdpCOMMON unsigned char flag_print_statistics; 44833965Sjdp 44938889Sjdp/* True if local absolute symbols are to be stripped. */ 45038889SjdpCOMMON int flag_strip_local_absolute; 45138889Sjdp 45238889Sjdp/* True if we should generate a traditional format object file. */ 45338889SjdpCOMMON int flag_traditional_format; 45438889Sjdp 455130561Sobrien/* TRUE if .note.GNU-stack section with SEC_CODE should be created */ 456130561SobrienCOMMON int flag_execstack; 457130561Sobrien 458130561Sobrien/* TRUE if .note.GNU-stack section with SEC_CODE should be created */ 459130561SobrienCOMMON int flag_noexecstack; 460130561Sobrien 46133965Sjdp/* name of emitted object file */ 46233965SjdpCOMMON char *out_file_name; 46333965Sjdp 46433965Sjdp/* name of file defining extensions to the basic instruction set */ 46533965SjdpCOMMON char *insttbl_file_name; 46633965Sjdp 46777298Sobrien/* TRUE if we need a second pass. */ 46833965SjdpCOMMON int need_pass_2; 46933965Sjdp 47033965Sjdp/* TRUE if we should do no relaxing, and 47133965Sjdp leave lots of padding. */ 47233965SjdpCOMMON int linkrelax; 47333965Sjdp 47433965Sjdp/* TRUE if we should produce a listing. */ 47533965Sjdpextern int listing; 47633965Sjdp 47777298Sobrien/* Type of debugging information we should generate. We currently support 47877298Sobrien stabs, ECOFF, and DWARF2. 47938889Sjdp 48077298Sobrien NOTE! This means debug information about the assembly source code itself 48177298Sobrien and _not_ about possible debug information from a high-level language. 48277298Sobrien This is especially relevant to DWARF2, since the compiler may emit line 48377298Sobrien number directives that the assembler resolves. */ 48438889Sjdp 48577298Sobrienenum debug_info_type { 48677298Sobrien DEBUG_UNSPECIFIED, 48777298Sobrien DEBUG_NONE, 48877298Sobrien DEBUG_STABS, 48977298Sobrien DEBUG_ECOFF, 49077298Sobrien DEBUG_DWARF, 49177298Sobrien DEBUG_DWARF2 49277298Sobrien}; 49377298Sobrien 49438889Sjdpextern enum debug_info_type debug_type; 495130561Sobrienextern int use_gnu_debug_info_extensions; 49638889Sjdp 49733965Sjdp/* Maximum level of macro nesting. */ 49833965Sjdpextern int max_macro_nest; 49933965Sjdp 500130561Sobrien/* Verbosity level. */ 501130561Sobrienextern int verbose; 502130561Sobrien 50333965Sjdp/* Obstack chunk size. Keep large for efficient space use, make small to 50433965Sjdp increase malloc calls for monitoring memory allocation. */ 50533965Sjdpextern int chunksize; 50633965Sjdp 50777298Sobrienstruct _pseudo_type { 50877298Sobrien /* assembler mnemonic, lower case, no '.' */ 50977298Sobrien const char *poc_name; 51077298Sobrien /* Do the work */ 511130561Sobrien void (*poc_handler) (int); 51277298Sobrien /* Value to pass to handler */ 51377298Sobrien int poc_val; 51477298Sobrien}; 51533965Sjdp 51633965Sjdptypedef struct _pseudo_type pseudo_typeS; 51733965Sjdp 51833965Sjdp/* Prefer varargs for non-ANSI compiler, since some will barf if the 51933965Sjdp ellipsis definition is used with a no-arguments declaration. */ 52033965Sjdp#if defined (HAVE_VARARGS_H) && !defined (__STDC__) 52133965Sjdp#undef HAVE_STDARG_H 52233965Sjdp#endif 52333965Sjdp 52433965Sjdp#if defined (HAVE_STDARG_H) 52533965Sjdp#define USE_STDARG 52633965Sjdp#endif 52733965Sjdp#if !defined (USE_STDARG) && defined (HAVE_VARARGS_H) 52833965Sjdp#define USE_VARARGS 52933965Sjdp#endif 53033965Sjdp 53133965Sjdp#ifdef USE_STDARG 53233965Sjdp#if (__GNUC__ >= 2) && !defined(VMS) 53333965Sjdp/* for use with -Wformat */ 53438889Sjdp 53560484Sobrien#if __GNUC__ == 2 && __GNUC_MINOR__ < 6 53638889Sjdp/* Support for double underscores in attribute names was added in gcc 53738889Sjdp 2.6, so avoid them if we are using an earlier version. */ 53838889Sjdp#define __printf__ printf 53938889Sjdp#define __format__ format 54038889Sjdp#endif 54138889Sjdp 54238889Sjdp#define PRINTF_LIKE(FCN) \ 54338889Sjdp void FCN (const char *format, ...) \ 54438889Sjdp __attribute__ ((__format__ (__printf__, 1, 2))) 54538889Sjdp#define PRINTF_WHERE_LIKE(FCN) \ 54638889Sjdp void FCN (char *file, unsigned int line, const char *format, ...) \ 54738889Sjdp __attribute__ ((__format__ (__printf__, 3, 4))) 54838889Sjdp 54938889Sjdp#else /* __GNUC__ < 2 || defined(VMS) */ 55038889Sjdp 551130561Sobrien#define PRINTF_LIKE(FCN) void FCN (const char *format, ...) 552130561Sobrien#define PRINTF_WHERE_LIKE(FCN) void FCN (char *file, \ 553130561Sobrien unsigned int line, \ 554130561Sobrien const char *format, ...) 55538889Sjdp 55638889Sjdp#endif /* __GNUC__ < 2 || defined(VMS) */ 55738889Sjdp 55838889Sjdp#else /* ! USE_STDARG */ 55938889Sjdp 56033965Sjdp#define PRINTF_LIKE(FCN) void FCN () 56133965Sjdp#define PRINTF_WHERE_LIKE(FCN) void FCN () 56233965Sjdp 56338889Sjdp#endif /* ! USE_STDARG */ 56438889Sjdp 56533965SjdpPRINTF_LIKE (as_bad); 56660484SobrienPRINTF_LIKE (as_fatal) ATTRIBUTE_NORETURN; 56733965SjdpPRINTF_LIKE (as_tsktsk); 56833965SjdpPRINTF_LIKE (as_warn); 56933965SjdpPRINTF_WHERE_LIKE (as_bad_where); 57033965SjdpPRINTF_WHERE_LIKE (as_warn_where); 57138889Sjdp 572130561Sobrienvoid as_assert (const char *, int, const char *); 573130561Sobrienvoid as_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; 57433965Sjdp 575130561Sobrienvoid fprint_value (FILE *file, addressT value); 576130561Sobrienvoid sprint_value (char *buf, addressT value); 57733965Sjdp 578130561Sobrienint had_errors (void); 579130561Sobrienint had_warnings (void); 58033965Sjdp 581130561Sobrienvoid print_version_id (void); 582130561Sobrienchar *app_push (void); 583130561Sobrienchar *atof_ieee (char *str, int what_kind, LITTLENUM_TYPE * words); 584130561Sobrienchar *input_scrub_include_file (char *filename, char *position); 585130561Sobrienextern void input_scrub_insert_line (const char *line); 586130561Sobrienextern void input_scrub_insert_file (char *path); 587130561Sobrienchar *input_scrub_new_file (char *filename); 588130561Sobrienchar *input_scrub_next_buffer (char **bufp); 589130561Sobrienint do_scrub_chars (int (*get) (char *, int), char *to, int tolen); 590130561Sobrienint gen_to_words (LITTLENUM_TYPE * words, int precision, 591130561Sobrien long exponent_bits); 592130561Sobrienint had_err (void); 593130561Sobrienint ignore_input (void); 594130561Sobrienvoid cond_finish_check (int); 595130561Sobrienvoid cond_exit_macro (int); 596130561Sobrienint seen_at_least_1_file (void); 597130561Sobrienvoid app_pop (char *arg); 598130561Sobrienvoid as_howmuch (FILE * stream); 599130561Sobrienvoid as_perror (const char *gripe, const char *filename); 600130561Sobrienvoid as_where (char **namep, unsigned int *linep); 601130561Sobrienvoid bump_line_counters (void); 602130561Sobrienvoid do_scrub_begin (int); 603130561Sobrienvoid input_scrub_begin (void); 604130561Sobrienvoid input_scrub_close (void); 605130561Sobrienvoid input_scrub_end (void); 606130561Sobrienint new_logical_line (char *fname, int line_number); 607130561Sobrienvoid subsegs_begin (void); 608130561Sobrienvoid subseg_change (segT seg, int subseg); 609130561SobriensegT subseg_new (const char *name, subsegT subseg); 610130561SobriensegT subseg_force_new (const char *name, subsegT subseg); 611130561Sobrienvoid subseg_set (segT seg, subsegT subseg); 61233965Sjdp#ifdef BFD_ASSEMBLER 613130561SobriensegT subseg_get (const char *, int); 61433965Sjdp#endif 615130561Sobrienint subseg_text_p (segT); 61633965Sjdp 617130561Sobrienvoid start_dependencies (char *); 618130561Sobrienvoid register_dependency (char *); 619130561Sobrienvoid print_dependencies (void); 62038889Sjdp 62133965Sjdpstruct expressionS; 62233965Sjdpstruct fix; 62360484Sobrientypedef struct symbol symbolS; 62433965Sjdpstruct relax_type; 62538889Sjdptypedef struct frag fragS; 62633965Sjdp 62733965Sjdp#ifdef BFD_ASSEMBLER 62833965Sjdp/* literal.c */ 629130561SobrienvalueT add_to_literal_pool (symbolS *, valueT, segT, int); 63033965Sjdp#endif 63133965Sjdp 632130561Sobrienint check_eh_frame (struct expressionS *, unsigned int *); 633130561Sobrienint eh_frame_estimate_size_before_relax (fragS *); 634130561Sobrienint eh_frame_relax_frag (fragS *); 635130561Sobrienvoid eh_frame_convert_frag (fragS *); 63638889Sjdp 637130561Sobrienint generic_force_reloc (struct fix *); 638130561Sobrien 63933965Sjdp#include "expr.h" /* Before targ-*.h */ 64033965Sjdp 64133965Sjdp/* this one starts the chain of target dependant headers */ 64233965Sjdp#include "targ-env.h" 64333965Sjdp 644130561Sobrien#ifdef OBJ_MAYBE_ELF 645130561Sobrien#define IS_ELF (OUTPUT_FLAVOR == bfd_target_elf_flavour) 646130561Sobrien#else 647130561Sobrien#ifdef OBJ_ELF 648130561Sobrien#define IS_ELF 1 649130561Sobrien#else 650130561Sobrien#define IS_ELF 0 65177298Sobrien#endif 652130561Sobrien#endif 65377298Sobrien 65433965Sjdp#include "write.h" 65533965Sjdp#include "frags.h" 65633965Sjdp#include "hash.h" 65733965Sjdp#include "read.h" 65833965Sjdp#include "symbols.h" 65933965Sjdp 66033965Sjdp#include "tc.h" 66133965Sjdp#include "obj.h" 66233965Sjdp 66333965Sjdp#ifdef USE_EMULATIONS 66433965Sjdp#include "emul.h" 66533965Sjdp#endif 66633965Sjdp#include "listing.h" 66733965Sjdp 66860484Sobrien#ifdef TC_M68K 66960484Sobrien/* True if we are assembling in m68k MRI mode. */ 67060484SobrienCOMMON int flag_m68k_mri; 67160484Sobrien#else 67260484Sobrien#define flag_m68k_mri 0 67360484Sobrien#endif 67460484Sobrien 67577298Sobrien#ifdef WARN_COMMENTS 67677298SobrienCOMMON int warn_comment; 67777298SobrienCOMMON unsigned int found_comment; 67877298SobrienCOMMON char *found_comment_file; 67977298Sobrien#endif 68077298Sobrien 68160484Sobrien#ifndef NUMBERS_WITH_SUFFIX 68260484Sobrien#define NUMBERS_WITH_SUFFIX 0 68360484Sobrien#endif 68460484Sobrien 68533965Sjdp#ifndef LOCAL_LABELS_DOLLAR 68633965Sjdp#define LOCAL_LABELS_DOLLAR 0 68733965Sjdp#endif 68833965Sjdp 68933965Sjdp#ifndef LOCAL_LABELS_FB 69033965Sjdp#define LOCAL_LABELS_FB 0 69133965Sjdp#endif 69233965Sjdp 69360484Sobrien#ifndef LABELS_WITHOUT_COLONS 69460484Sobrien#define LABELS_WITHOUT_COLONS 0 69560484Sobrien#endif 69660484Sobrien 69760484Sobrien#ifndef NO_PSEUDO_DOT 69860484Sobrien#define NO_PSEUDO_DOT 0 69960484Sobrien#endif 70060484Sobrien 70138889Sjdp#ifndef TEXT_SECTION_NAME 70238889Sjdp#define TEXT_SECTION_NAME ".text" 70338889Sjdp#define DATA_SECTION_NAME ".data" 70438889Sjdp#define BSS_SECTION_NAME ".bss" 70538889Sjdp#endif 70638889Sjdp 70760484Sobrien#ifndef OCTETS_PER_BYTE_POWER 70860484Sobrien#define OCTETS_PER_BYTE_POWER 0 70960484Sobrien#endif 71060484Sobrien#ifndef OCTETS_PER_BYTE 71160484Sobrien#define OCTETS_PER_BYTE (1<<OCTETS_PER_BYTE_POWER) 71260484Sobrien#endif 71360484Sobrien#if OCTETS_PER_BYTE != (1<<OCTETS_PER_BYTE_POWER) 71460484Sobrien #error "Octets per byte conflicts with its power-of-two definition!" 71560484Sobrien#endif 71660484Sobrien 71733965Sjdp#endif /* GAS */ 718