Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /* as.h - global header file
  2.    Copyright 1987-2013 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 3, or (at your option)
  9.    any later version.
  10.  
  11.    GAS is distributed in the hope that it will be useful, but WITHOUT
  12.    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  13.    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
  14.    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 the Free
  18.    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
  19.    02110-1301, USA.  */
  20.  
  21. #ifndef GAS
  22. #define GAS 1
  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. #include "alloca-conf.h"
  38.  
  39. /* Now, tend to the rest of the configuration.  */
  40.  
  41. /* System include files first...  */
  42. #include <stdio.h>
  43.  
  44. #ifdef STRING_WITH_STRINGS
  45. #include <string.h>
  46. #include <strings.h>
  47. #else
  48. #ifdef HAVE_STRING_H
  49. #include <string.h>
  50. #else
  51. #ifdef HAVE_STRINGS_H
  52. #include <strings.h>
  53. #endif
  54. #endif
  55. #endif
  56.  
  57. #ifdef HAVE_STDLIB_H
  58. #include <stdlib.h>
  59. #endif
  60. #ifdef HAVE_UNISTD_H
  61. #include <unistd.h>
  62. #endif
  63. #ifdef HAVE_SYS_TYPES_H
  64. /* for size_t, pid_t */
  65. #include <sys/types.h>
  66. #endif
  67.  
  68. #ifdef HAVE_ERRNO_H
  69. #include <errno.h>
  70. #endif
  71.  
  72. #include <stdarg.h>
  73.  
  74. #include "getopt.h"
  75. /* The first getopt value for machine-independent long options.
  76.    150 isn't special; it's just an arbitrary non-ASCII char value.  */
  77. #define OPTION_STD_BASE 150
  78. /* The first getopt value for machine-dependent long options.
  79.    190 gives the standard options room to grow.  */
  80. #define OPTION_MD_BASE 190
  81.  
  82. #ifdef DEBUG
  83. #undef NDEBUG
  84. #endif
  85. #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
  86. #define __PRETTY_FUNCTION__  ((char *) NULL)
  87. #endif
  88. #define gas_assert(P) \
  89.   ((void) ((P) ? 0 : (as_assert (__FILE__, __LINE__, __PRETTY_FUNCTION__), 0)))
  90. #undef abort
  91. #define abort()         as_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
  92.  
  93. /* Now GNU header files...  */
  94. #include "ansidecl.h"
  95. #include "bfd.h"
  96. #include "libiberty.h"
  97.  
  98. /* Define the standard progress macros.  */
  99. #include "progress.h"
  100.  
  101. /* This doesn't get taken care of anywhere.  */
  102. #ifndef __MWERKS__  /* Metrowerks C chokes on the "defined (inline)"  */
  103. #if !defined (__GNUC__) && !defined (inline)
  104. #define inline
  105. #endif
  106. #endif /* !__MWERKS__ */
  107.  
  108. /* Other stuff from config.h.  */
  109. #ifdef NEED_DECLARATION_ENVIRON
  110. extern char **environ;
  111. #endif
  112. #ifdef NEED_DECLARATION_ERRNO
  113. extern int errno;
  114. #endif
  115. #ifdef NEED_DECLARATION_FFS
  116. extern int ffs (int);
  117. #endif
  118. #ifdef NEED_DECLARATION_FREE
  119. extern void free ();
  120. #endif
  121. #ifdef NEED_DECLARATION_MALLOC
  122. extern void *malloc ();
  123. extern void *realloc ();
  124. #endif
  125. #ifdef NEED_DECLARATION_STRSTR
  126. extern char *strstr ();
  127. #endif
  128.  
  129. #if !HAVE_DECL_MEMPCPY
  130. void *mempcpy(void *, const void *, size_t);
  131. #endif
  132.  
  133. #if !HAVE_DECL_VSNPRINTF
  134. extern int vsnprintf(char *, size_t, const char *, va_list);
  135. #endif
  136.  
  137. /* This is needed for VMS.  */
  138. #if ! defined (HAVE_UNLINK) && defined (HAVE_REMOVE)
  139. #define unlink remove
  140. #endif
  141.  
  142. /* Hack to make "gcc -Wall" not complain about obstack macros.  */
  143. #if !defined (memcpy) && !defined (bcopy)
  144. #define bcopy(src,dest,size)    memcpy (dest, src, size)
  145. #endif
  146.  
  147. /* Make Saber happier on obstack.h.  */
  148. #ifdef SABER
  149. #undef  __PTR_TO_INT
  150. #define __PTR_TO_INT(P) ((int) (P))
  151. #undef  __INT_TO_PTR
  152. #define __INT_TO_PTR(P) ((char *) (P))
  153. #endif
  154.  
  155. #ifndef __LINE__
  156. #define __LINE__ "unknown"
  157. #endif /* __LINE__ */
  158.  
  159. #ifndef __FILE__
  160. #define __FILE__ "unknown"
  161. #endif /* __FILE__ */
  162.  
  163. #ifndef FOPEN_WB
  164. #ifdef USE_BINARY_FOPEN
  165. #include "fopen-bin.h"
  166. #else
  167. #include "fopen-same.h"
  168. #endif
  169. #endif
  170.  
  171. #ifndef EXIT_SUCCESS
  172. #define EXIT_SUCCESS 0
  173. #define EXIT_FAILURE 1
  174. #endif
  175.  
  176. #ifndef SEEK_SET
  177. #define SEEK_SET 0
  178. #endif
  179.  
  180. #define obstack_chunk_alloc xmalloc
  181. #define obstack_chunk_free xfree
  182.  
  183. #define xfree free
  184.  
  185. #include "asintl.h"
  186.  
  187. #define BAD_CASE(val)                                                       \
  188.   {                                                                         \
  189.     as_fatal (_("Case value %ld unexpected at line %d of file \"%s\"\n"),   \
  190.               (long) val, __LINE__, __FILE__);                              \
  191.   }
  192. #include "flonum.h"
  193.  
  194. /* These are assembler-wide concepts */
  195.  
  196. extern bfd *stdoutput;
  197. typedef bfd_vma addressT;
  198. typedef bfd_signed_vma offsetT;
  199.  
  200. /* Type of symbol value, etc.  For use in prototypes.  */
  201. typedef addressT valueT;
  202.  
  203. #ifndef COMMON
  204. #ifdef TEST
  205. #define COMMON                  /* Declare our COMMONs storage here.  */
  206. #else
  207. #define COMMON extern           /* Our commons live elsewhere.  */
  208. #endif
  209. #endif
  210. /* COMMON now defined */
  211.  
  212. #ifndef ENABLE_CHECKING
  213. #define ENABLE_CHECKING 0
  214. #endif
  215.  
  216. #if ENABLE_CHECKING || defined (DEBUG)
  217. #ifndef know
  218. #define know(p) gas_assert(p)   /* Verify our assumptions!  */
  219. #endif /* not yet defined */
  220. #else
  221. #define know(p) do {} while (0) /* know() checks are no-op.ed  */
  222. #endif
  223. /* input_scrub.c */
  224.  
  225. /* Supplies sanitised buffers to read.c.
  226.    Also understands printing line-number part of error messages.  */
  227. /* subsegs.c     Sub-segments. Also, segment(=expression type)s.*/
  228.  
  229. typedef asection *segT;
  230. #define SEG_NORMAL(SEG)         (   (SEG) != absolute_section   \
  231.                                  && (SEG) != undefined_section  \
  232.                                  && (SEG) != reg_section        \
  233.                                  && (SEG) != expr_section)
  234. typedef int subsegT;
  235.  
  236. /* What subseg we are accessing now?  */
  237. COMMON subsegT now_subseg;
  238.  
  239. /* Segment our instructions emit to.  */
  240. COMMON segT now_seg;
  241.  
  242. #define segment_name(SEG)       bfd_get_section_name (stdoutput, SEG)
  243.  
  244. extern segT reg_section, expr_section;
  245. /* Shouldn't these be eliminated someday?  */
  246. extern segT text_section, data_section, bss_section;
  247. #define absolute_section        bfd_abs_section_ptr
  248. #define undefined_section       bfd_und_section_ptr
  249.  
  250. enum _relax_state
  251. {
  252.   /* Dummy frag used by listing code.  */
  253.   rs_dummy = 0,
  254.  
  255.   /* Variable chars to be repeated fr_offset times.
  256.      Fr_symbol unused. Used with fr_offset == 0 for a
  257.      constant length frag.  */
  258.   rs_fill,
  259.  
  260.   /* Align.  The fr_offset field holds the power of 2 to which to
  261.      align.  The fr_var field holds the number of characters in the
  262.      fill pattern.  The fr_subtype field holds the maximum number of
  263.      bytes to skip when aligning, or 0 if there is no maximum.  */
  264.   rs_align,
  265.  
  266.   /* Align code.  The fr_offset field holds the power of 2 to which
  267.      to align.  This type is only generated by machine specific
  268.      code, which is normally responsible for handling the fill
  269.      pattern.  The fr_subtype field holds the maximum number of
  270.      bytes to skip when aligning, or 0 if there is no maximum.  */
  271.   rs_align_code,
  272.  
  273.   /* Test for alignment.  Like rs_align, but used by several targets
  274.      to warn if data is not properly aligned.  */
  275.   rs_align_test,
  276.  
  277.   /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill
  278.      character.  */
  279.   rs_org,
  280.  
  281. #ifndef WORKING_DOT_WORD
  282.   /* JF: gunpoint */
  283.   rs_broken_word,
  284. #endif
  285.  
  286.   /* Machine specific relaxable (or similarly alterable) instruction.  */
  287.   rs_machine_dependent,
  288.  
  289.   /* .space directive with expression operand that needs to be computed
  290.      later.  Similar to rs_org, but different.
  291.      fr_symbol: operand
  292.      1 variable char: fill character  */
  293.   rs_space,
  294.  
  295.   /* A DWARF leb128 value; only ELF uses this.  The subtype is 0 for
  296.      unsigned, 1 for signed.  */
  297.   rs_leb128,
  298.  
  299.   /* Exception frame information which we may be able to optimize.  */
  300.   rs_cfa,
  301.  
  302.   /* Cross-fragment dwarf2 line number optimization.  */
  303.   rs_dwarf2dbg
  304. };
  305.  
  306. typedef enum _relax_state relax_stateT;
  307.  
  308. /* This type is used in prototypes, so it can't be a type that will be
  309.    widened for argument passing.  */
  310. typedef unsigned int relax_substateT;
  311.  
  312. /* Enough bits for address, but still an integer type.
  313.    Could be a problem, cross-assembling for 64-bit machines.  */
  314. typedef addressT relax_addressT;
  315.  
  316. struct relax_type
  317. {
  318.   /* Forward reach. Signed number. > 0.  */
  319.   offsetT rlx_forward;
  320.   /* Backward reach. Signed number. < 0.  */
  321.   offsetT rlx_backward;
  322.  
  323.   /* Bytes length of this address.  */
  324.   unsigned char rlx_length;
  325.  
  326.   /* Next longer relax-state.  0 means there is no 'next' relax-state.  */
  327.   relax_substateT rlx_more;
  328. };
  329.  
  330. typedef struct relax_type relax_typeS;
  331. /* main program "as.c" (command arguments etc).  */
  332.  
  333. COMMON unsigned char flag_no_comments; /* -f */
  334. COMMON unsigned char flag_debug; /* -D */
  335. COMMON unsigned char flag_signed_overflow_ok; /* -J */
  336. #ifndef WORKING_DOT_WORD
  337. COMMON unsigned char flag_warn_displacement; /* -K */
  338. #endif
  339.  
  340. /* True if local symbols should be retained.  */
  341. COMMON int flag_keep_locals; /* -L */
  342.  
  343. /* True if we are assembling in MRI mode.  */
  344. COMMON int flag_mri;
  345.  
  346. /* Should the data section be made read-only and appended to the text
  347.    section?  */
  348. COMMON unsigned char flag_readonly_data_in_text; /* -R */
  349.  
  350. /* True if warnings should be inhibited.  */
  351. COMMON int flag_no_warnings; /* -W */
  352.  
  353. /* True if warnings count as errors.  */
  354. COMMON int flag_fatal_warnings; /* --fatal-warnings */
  355.  
  356. /* True if we should attempt to generate output even if non-fatal errors
  357.    are detected.  */
  358. COMMON unsigned char flag_always_generate_output; /* -Z */
  359.  
  360. /* This is true if the assembler should output time and space usage.  */
  361. COMMON unsigned char flag_print_statistics;
  362.  
  363. /* True if local absolute symbols are to be stripped.  */
  364. COMMON int flag_strip_local_absolute;
  365.  
  366. /* True if we should generate a traditional format object file.  */
  367. COMMON int flag_traditional_format;
  368.  
  369. /* TRUE if debug sections should be compressed.  */
  370. COMMON int flag_compress_debug;
  371.  
  372. /* TRUE if .note.GNU-stack section with SEC_CODE should be created */
  373. COMMON int flag_execstack;
  374.  
  375. /* TRUE if .note.GNU-stack section with SEC_CODE should be created */
  376. COMMON int flag_noexecstack;
  377.  
  378. /* name of emitted object file */
  379. COMMON char *out_file_name;
  380.  
  381. /* name of file defining extensions to the basic instruction set */
  382. COMMON char *insttbl_file_name;
  383.  
  384. /* TRUE if we need a second pass.  */
  385. COMMON int need_pass_2;
  386.  
  387. /* TRUE if we should do no relaxing, and
  388.    leave lots of padding.  */
  389. COMMON int linkrelax;
  390.  
  391. /* TRUE if we should produce a listing.  */
  392. extern int listing;
  393.  
  394. /* Type of debugging information we should generate.  We currently support
  395.    stabs, ECOFF, and DWARF2.
  396.  
  397.    NOTE!  This means debug information about the assembly source code itself
  398.    and _not_ about possible debug information from a high-level language.
  399.    This is especially relevant to DWARF2, since the compiler may emit line
  400.    number directives that the assembler resolves.  */
  401.  
  402. enum debug_info_type
  403. {
  404.   DEBUG_UNSPECIFIED,
  405.   DEBUG_NONE,
  406.   DEBUG_STABS,
  407.   DEBUG_ECOFF,
  408.   DEBUG_DWARF,
  409.   DEBUG_DWARF2
  410. };
  411.  
  412. extern enum debug_info_type debug_type;
  413. extern int use_gnu_debug_info_extensions;
  414. COMMON bfd_boolean flag_dwarf_sections;
  415. /* Maximum level of macro nesting.  */
  416. extern int max_macro_nest;
  417.  
  418. /* Verbosity level.  */
  419. extern int verbose;
  420.  
  421. /* Obstack chunk size.  Keep large for efficient space use, make small to
  422.    increase malloc calls for monitoring memory allocation.  */
  423. extern int chunksize;
  424.  
  425. struct _pseudo_type
  426. {
  427.   /* assembler mnemonic, lower case, no '.' */
  428.   const char *poc_name;
  429.   /* Do the work */
  430.   void (*poc_handler) (int);
  431.   /* Value to pass to handler */
  432.   int poc_val;
  433. };
  434.  
  435. typedef struct _pseudo_type pseudo_typeS;
  436.  
  437. #if (__GNUC__ >= 2) && !defined(VMS)
  438. /* for use with -Wformat */
  439.  
  440. #if __GNUC__ == 2 && __GNUC_MINOR__ < 6
  441. /* Support for double underscores in attribute names was added in gcc
  442.    2.6, so avoid them if we are using an earlier version.  */
  443. #define __printf__ printf
  444. #define __format__ format
  445. #endif
  446.  
  447. #define PRINTF_LIKE(FCN) \
  448.   void FCN (const char *format, ...) \
  449.     __attribute__ ((__format__ (__printf__, 1, 2)))
  450. #define PRINTF_WHERE_LIKE(FCN) \
  451.   void FCN (char *file, unsigned int line, const char *format, ...) \
  452.     __attribute__ ((__format__ (__printf__, 3, 4)))
  453.  
  454. #else /* __GNUC__ < 2 || defined(VMS) */
  455.  
  456. #define PRINTF_LIKE(FCN)        void FCN (const char *format, ...)
  457. #define PRINTF_WHERE_LIKE(FCN)  void FCN (char *file, \
  458.                                           unsigned int line, \
  459.                                           const char *format, ...)
  460.  
  461. #endif /* __GNUC__ < 2 || defined(VMS) */
  462.  
  463. PRINTF_LIKE (as_bad);
  464. PRINTF_LIKE (as_fatal) ATTRIBUTE_NORETURN;
  465. PRINTF_LIKE (as_tsktsk);
  466. PRINTF_LIKE (as_warn);
  467. PRINTF_WHERE_LIKE (as_bad_where);
  468. PRINTF_WHERE_LIKE (as_warn_where);
  469.  
  470. void   as_assert (const char *, int, const char *);
  471. void   as_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
  472. void   sprint_value (char *, addressT);
  473. int    had_errors (void);
  474. int    had_warnings (void);
  475. void   as_warn_value_out_of_range (char *, offsetT, offsetT, offsetT, char *, unsigned);
  476. void   as_bad_value_out_of_range (char *, offsetT, offsetT, offsetT, char *, unsigned);
  477. void   print_version_id (void);
  478. char * app_push (void);
  479. char * atof_ieee (char *, int, LITTLENUM_TYPE *);
  480. char * ieee_md_atof (int, char *, int *, bfd_boolean);
  481. char * vax_md_atof (int, char *, int *);
  482. char * input_scrub_include_file (char *, char *);
  483. void   input_scrub_insert_line (const char *);
  484. void   input_scrub_insert_file (char *);
  485. char * input_scrub_new_file (char *);
  486. char * input_scrub_next_buffer (char **bufp);
  487. size_t do_scrub_chars (size_t (*get) (char *, size_t), char *, size_t);
  488. int    gen_to_words (LITTLENUM_TYPE *, int, long);
  489. int    had_err (void);
  490. int    ignore_input (void);
  491. void   cond_finish_check (int);
  492. void   cond_exit_macro (int);
  493. int    seen_at_least_1_file (void);
  494. void   app_pop (char *);
  495. void   as_where (char **, unsigned int *);
  496. void   bump_line_counters (void);
  497. void   do_scrub_begin (int);
  498. void   input_scrub_begin (void);
  499. void   input_scrub_close (void);
  500. void   input_scrub_end (void);
  501. int    new_logical_line (char *, int);
  502. int    new_logical_line_flags (char *, int, int);
  503. void   subsegs_begin (void);
  504. void   subseg_change (segT, int);
  505. segT   subseg_new (const char *, subsegT);
  506. segT   subseg_force_new (const char *, subsegT);
  507. void   subseg_set (segT, subsegT);
  508. int    subseg_text_p (segT);
  509. int    seg_not_empty_p (segT);
  510. void   start_dependencies (char *);
  511. void   register_dependency (char *);
  512. void   print_dependencies (void);
  513. segT   subseg_get (const char *, int);
  514.  
  515. const char *remap_debug_filename (const char *);
  516. void add_debug_prefix_map (const char *);
  517.  
  518. struct expressionS;
  519. struct fix;
  520. typedef struct symbol symbolS;
  521. typedef struct frag fragS;
  522.  
  523. /* literal.c */
  524. valueT add_to_literal_pool (symbolS *, valueT, segT, int);
  525.  
  526. int check_eh_frame (struct expressionS *, unsigned int *);
  527. int eh_frame_estimate_size_before_relax (fragS *);
  528. int eh_frame_relax_frag (fragS *);
  529. void eh_frame_convert_frag (fragS *);
  530. int generic_force_reloc (struct fix *);
  531.  
  532. #include "expr.h"               /* Before targ-*.h */
  533.  
  534. /* This one starts the chain of target dependant headers.  */
  535. #include "targ-env.h"
  536.  
  537. #ifdef OBJ_MAYBE_ELF
  538. #define IS_ELF (OUTPUT_FLAVOR == bfd_target_elf_flavour)
  539. #else
  540. #ifdef OBJ_ELF
  541. #define IS_ELF 1
  542. #else
  543. #define IS_ELF 0
  544. #endif
  545. #endif
  546.  
  547. #include "write.h"
  548. #include "frags.h"
  549. #include "hash.h"
  550. #include "read.h"
  551. #include "symbols.h"
  552.  
  553. #include "tc.h"
  554. #include "obj.h"
  555.  
  556. #ifdef USE_EMULATIONS
  557. #include "emul.h"
  558. #endif
  559. #include "listing.h"
  560.  
  561. #ifdef H_TICK_HEX
  562. extern int enable_h_tick_hex;
  563. #endif
  564.  
  565. #ifdef TC_M68K
  566. /* True if we are assembling in m68k MRI mode.  */
  567. COMMON int flag_m68k_mri;
  568. #define DOLLAR_AMBIGU flag_m68k_mri
  569. #else
  570. #define flag_m68k_mri 0
  571. #endif
  572.  
  573. #ifdef WARN_COMMENTS
  574. COMMON int           warn_comment;
  575. COMMON unsigned int  found_comment;
  576. COMMON char *        found_comment_file;
  577. #endif
  578.  
  579. #if defined OBJ_ELF || defined OBJ_MAYBE_ELF
  580. /* If .size directive failure should be error or warning.  */
  581. COMMON enum
  582.   {
  583.     size_check_error = 0,
  584.     size_check_warning
  585.   }
  586. flag_size_check;
  587. #endif
  588.  
  589. #ifndef DOLLAR_AMBIGU
  590. #define DOLLAR_AMBIGU 0
  591. #endif
  592.  
  593. #ifndef NUMBERS_WITH_SUFFIX
  594. #define NUMBERS_WITH_SUFFIX 0
  595. #endif
  596.  
  597. #ifndef LOCAL_LABELS_DOLLAR
  598. #define LOCAL_LABELS_DOLLAR 0
  599. #endif
  600.  
  601. #ifndef LOCAL_LABELS_FB
  602. #define LOCAL_LABELS_FB 0
  603. #endif
  604.  
  605. #ifndef LABELS_WITHOUT_COLONS
  606. #define LABELS_WITHOUT_COLONS 0
  607. #endif
  608.  
  609. #ifndef NO_PSEUDO_DOT
  610. #define NO_PSEUDO_DOT 0
  611. #endif
  612.  
  613. #ifndef TEXT_SECTION_NAME
  614. #define TEXT_SECTION_NAME       ".text"
  615. #define DATA_SECTION_NAME       ".data"
  616. #define BSS_SECTION_NAME        ".bss"
  617. #endif
  618.  
  619. #ifndef OCTETS_PER_BYTE_POWER
  620. #define OCTETS_PER_BYTE_POWER 0
  621. #endif
  622. #ifndef OCTETS_PER_BYTE
  623. #define OCTETS_PER_BYTE (1<<OCTETS_PER_BYTE_POWER)
  624. #endif
  625. #if OCTETS_PER_BYTE != (1<<OCTETS_PER_BYTE_POWER)
  626.  #error "Octets per byte conflicts with its power-of-two definition!"
  627. #endif
  628.  
  629. #endif /* GAS */
  630.