Home | History | Annotate | Line # | Download | only in gas
frags.h revision 1.3
      1  1.1  christos /* frags.h - Header file for the frag concept.
      2  1.3  christos    Copyright (C) 1987-2015 Free Software Foundation, Inc.
      3  1.1  christos 
      4  1.1  christos    This file is part of GAS, the GNU Assembler.
      5  1.1  christos 
      6  1.1  christos    GAS is free software; you can redistribute it and/or modify
      7  1.1  christos    it under the terms of the GNU General Public License as published by
      8  1.1  christos    the Free Software Foundation; either version 3, or (at your option)
      9  1.1  christos    any later version.
     10  1.1  christos 
     11  1.1  christos    GAS is distributed in the hope that it will be useful,
     12  1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14  1.1  christos    GNU General Public License for more details.
     15  1.1  christos 
     16  1.1  christos    You should have received a copy of the GNU General Public License
     17  1.1  christos    along with GAS; see the file COPYING.  If not, write to the Free
     18  1.1  christos    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
     19  1.1  christos    02110-1301, USA.  */
     20  1.1  christos 
     21  1.1  christos #ifndef FRAGS_H
     22  1.1  christos #define FRAGS_H
     23  1.1  christos 
     24  1.1  christos struct obstack;
     25  1.1  christos 
     26  1.1  christos /* A code fragment (frag) is some known number of chars, followed by some
     27  1.1  christos    unknown number of chars. Typically the unknown number of chars is an
     28  1.1  christos    instruction address whose size is yet unknown. We always know the greatest
     29  1.1  christos    possible size the unknown number of chars may become, and reserve that
     30  1.1  christos    much room at the end of the frag.
     31  1.1  christos    Once created, frags do not change address during assembly.
     32  1.1  christos    We chain the frags in (a) forward-linked list(s). The object-file address
     33  1.1  christos    of the 1st char of a frag is generally not known until after relax().
     34  1.1  christos    Many things at assembly time describe an address by {object-file-address
     35  1.1  christos    of a particular frag}+offset.
     36  1.1  christos 
     37  1.1  christos    BUG: it may be smarter to have a single pointer off to various different
     38  1.1  christos    notes for different frag kinds.  See how code pans.  */
     39  1.1  christos 
     40  1.1  christos struct frag {
     41  1.1  christos   /* Object file address (as an octet offset).  */
     42  1.1  christos   addressT fr_address;
     43  1.1  christos   /* When relaxing multiple times, remember the address the frag had
     44  1.1  christos      in the last relax pass.  */
     45  1.1  christos   addressT last_fr_address;
     46  1.1  christos 
     47  1.1  christos   /* (Fixed) number of octets we know we have.  May be 0.  */
     48  1.1  christos   offsetT fr_fix;
     49  1.1  christos   /* May be used for (Variable) number of octets after above.
     50  1.1  christos      The generic frag handling code no longer makes any use of fr_var.  */
     51  1.1  christos   offsetT fr_var;
     52  1.1  christos   /* For variable-length tail.  */
     53  1.1  christos   offsetT fr_offset;
     54  1.1  christos   /* For variable-length tail.  */
     55  1.1  christos   symbolS *fr_symbol;
     56  1.1  christos   /* Points to opcode low addr byte, for relaxation.  */
     57  1.1  christos   char *fr_opcode;
     58  1.1  christos 
     59  1.1  christos   /* Chain forward; ascending address order.  Rooted in frch_root.  */
     60  1.1  christos   struct frag *fr_next;
     61  1.1  christos 
     62  1.1  christos   /* Where the frag was created, or where it became a variant frag.  */
     63  1.1  christos   char *fr_file;
     64  1.1  christos   unsigned int fr_line;
     65  1.1  christos 
     66  1.1  christos #ifndef NO_LISTING
     67  1.1  christos   struct list_info_struct *line;
     68  1.1  christos #endif
     69  1.1  christos 
     70  1.1  christos   /* A serial number for a sequence of frags having at most one alignment
     71  1.1  christos      or org frag, and that at the tail of the sequence.  */
     72  1.1  christos   unsigned int region:16;
     73  1.1  christos 
     74  1.1  christos   /* Flipped each relax pass so we can easily determine whether
     75  1.1  christos      fr_address has been adjusted.  */
     76  1.1  christos   unsigned int relax_marker:1;
     77  1.1  christos 
     78  1.1  christos   /* Used to ensure that all insns are emitted on proper address
     79  1.1  christos      boundaries.  */
     80  1.1  christos   unsigned int has_code:1;
     81  1.1  christos   unsigned int insn_addr:6;
     82  1.1  christos 
     83  1.1  christos   /* What state is my tail in? */
     84  1.1  christos   relax_stateT fr_type;
     85  1.1  christos   relax_substateT fr_subtype;
     86  1.1  christos 
     87  1.1  christos #ifdef USING_CGEN
     88  1.1  christos   /* Don't include this unless using CGEN to keep frag size down.  */
     89  1.1  christos   struct {
     90  1.1  christos     /* CGEN_INSN entry for this instruction.  */
     91  1.1  christos     const struct cgen_insn *insn;
     92  1.1  christos     /* Index into operand table.  */
     93  1.1  christos     int opindex;
     94  1.1  christos     /* Target specific data, usually reloc number.  */
     95  1.1  christos     int opinfo;
     96  1.1  christos   } fr_cgen;
     97  1.1  christos #endif
     98  1.1  christos 
     99  1.1  christos #ifdef TC_FRAG_TYPE
    100  1.1  christos   TC_FRAG_TYPE tc_frag_data;
    101  1.1  christos #endif
    102  1.1  christos #ifdef OBJ_FRAG_TYPE
    103  1.1  christos   OBJ_FRAG_TYPE obj_frag_data;
    104  1.1  christos #endif
    105  1.1  christos 
    106  1.1  christos   /* Data begins here.  */
    107  1.1  christos   char fr_literal[1];
    108  1.1  christos };
    109  1.1  christos 
    110  1.1  christos #define SIZEOF_STRUCT_FRAG \
    111  1.1  christos ((char *) zero_address_frag.fr_literal - (char *) &zero_address_frag)
    112  1.1  christos /* We want to say fr_literal[0] above.  */
    113  1.1  christos 
    114  1.1  christos /* Current frag we are building.  This frag is incomplete.  It is,
    115  1.1  christos    however, included in frchain_now.  The fr_fix field is bogus;
    116  1.1  christos    instead, use frag_now_fix ().  */
    117  1.1  christos COMMON fragS *frag_now;
    118  1.1  christos extern addressT frag_now_fix (void);
    119  1.1  christos extern addressT frag_now_fix_octets (void);
    120  1.1  christos 
    121  1.1  christos /* For foreign-segment symbol fixups.  */
    122  1.1  christos COMMON fragS zero_address_frag;
    123  1.1  christos COMMON fragS predefined_address_frag;
    124  1.1  christos 
    125  1.1  christos extern void frag_append_1_char (int);
    126  1.1  christos #define FRAG_APPEND_1_CHAR(X) frag_append_1_char (X)
    127  1.1  christos 
    128  1.1  christos void frag_init (void);
    129  1.1  christos fragS *frag_alloc (struct obstack *);
    130  1.3  christos void frag_grow (size_t nchars);
    131  1.3  christos char *frag_more (size_t nchars);
    132  1.1  christos void frag_align (int alignment, int fill_character, int max);
    133  1.1  christos void frag_align_pattern (int alignment, const char *fill_pattern,
    134  1.3  christos 			 size_t n_fill, int max);
    135  1.1  christos void frag_align_code (int alignment, int max);
    136  1.3  christos void frag_new (size_t old_frags_var_max_size);
    137  1.1  christos void frag_wane (fragS * fragP);
    138  1.3  christos size_t frag_room (void);
    139  1.1  christos 
    140  1.1  christos char *frag_variant (relax_stateT type,
    141  1.3  christos 		    size_t max_chars,
    142  1.3  christos 		    size_t var,
    143  1.1  christos 		    relax_substateT subtype,
    144  1.1  christos 		    symbolS * symbol,
    145  1.1  christos 		    offsetT offset,
    146  1.1  christos 		    char *opcode);
    147  1.1  christos 
    148  1.1  christos char *frag_var (relax_stateT type,
    149  1.3  christos 		size_t max_chars,
    150  1.3  christos 		size_t var,
    151  1.1  christos 		relax_substateT subtype,
    152  1.1  christos 		symbolS * symbol,
    153  1.1  christos 		offsetT offset,
    154  1.1  christos 		char *opcode);
    155  1.1  christos 
    156  1.1  christos bfd_boolean frag_offset_fixed_p (const fragS *, const fragS *, offsetT *);
    157  1.1  christos 
    158  1.3  christos int get_frag_count (void);
    159  1.3  christos void clear_frag_count (void);
    160  1.3  christos 
    161  1.1  christos #endif /* FRAGS_H */
    162