Back to index

cell-binutils  2.17cvs20070401
frags.h
Go to the documentation of this file.
00001 /* frags.h - Header file for the frag concept.
00002    Copyright 1987, 1992, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
00003    2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
00004 
00005    This file is part of GAS, the GNU Assembler.
00006 
00007    GAS is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2, or (at your option)
00010    any later version.
00011 
00012    GAS is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with GAS; see the file COPYING.  If not, write to the Free
00019    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
00020    02110-1301, USA.  */
00021 
00022 #ifndef FRAGS_H
00023 #define FRAGS_H
00024 
00025 struct obstack;
00026 
00027 /* A code fragment (frag) is some known number of chars, followed by some
00028    unknown number of chars. Typically the unknown number of chars is an
00029    instruction address whose size is yet unknown. We always know the greatest
00030    possible size the unknown number of chars may become, and reserve that
00031    much room at the end of the frag.
00032    Once created, frags do not change address during assembly.
00033    We chain the frags in (a) forward-linked list(s). The object-file address
00034    of the 1st char of a frag is generally not known until after relax().
00035    Many things at assembly time describe an address by {object-file-address
00036    of a particular frag}+offset.
00037 
00038    BUG: it may be smarter to have a single pointer off to various different
00039    notes for different frag kinds.  See how code pans.  */
00040 
00041 struct frag {
00042   /* Object file address (as an octet offset).  */
00043   addressT fr_address;
00044   /* When relaxing multiple times, remember the address the frag had
00045      in the last relax pass.  */
00046   addressT last_fr_address;
00047 
00048   /* (Fixed) number of octets we know we have.  May be 0.  */
00049   offsetT fr_fix;
00050   /* May be used for (Variable) number of octets after above.
00051      The generic frag handling code no longer makes any use of fr_var.  */
00052   offsetT fr_var;
00053   /* For variable-length tail.  */
00054   offsetT fr_offset;
00055   /* For variable-length tail.  */
00056   symbolS *fr_symbol;
00057   /* Points to opcode low addr byte, for relaxation.  */
00058   char *fr_opcode;
00059 
00060   /* Chain forward; ascending address order.  Rooted in frch_root.  */
00061   struct frag *fr_next;
00062 
00063   /* Where the frag was created, or where it became a variant frag.  */
00064   char *fr_file;
00065   unsigned int fr_line;
00066 
00067 #ifndef NO_LISTING
00068   struct list_info_struct *line;
00069 #endif
00070 
00071   /* Flipped each relax pass so we can easily determine whether
00072      fr_address has been adjusted.  */
00073   unsigned int relax_marker:1;
00074 
00075   /* Used to ensure that all insns are emitted on proper address
00076      boundaries.  */
00077   unsigned int has_code:1;
00078   unsigned int insn_addr:6;
00079 
00080   /* What state is my tail in? */
00081   relax_stateT fr_type;
00082   relax_substateT fr_subtype;
00083 
00084 #ifdef USING_CGEN
00085   /* Don't include this unless using CGEN to keep frag size down.  */
00086   struct {
00087     /* CGEN_INSN entry for this instruction.  */
00088     const struct cgen_insn *insn;
00089     /* Index into operand table.  */
00090     int opindex;
00091     /* Target specific data, usually reloc number.  */
00092     int opinfo;
00093   } fr_cgen;
00094 #endif
00095 
00096 #ifdef TC_FRAG_TYPE
00097   TC_FRAG_TYPE tc_frag_data;
00098 #endif
00099 
00100   /* Data begins here.  */
00101   char fr_literal[1];
00102 };
00103 
00104 #define SIZEOF_STRUCT_FRAG \
00105 ((char *) zero_address_frag.fr_literal - (char *) &zero_address_frag)
00106 /* We want to say fr_literal[0] above.  */
00107 
00108 /* Current frag we are building.  This frag is incomplete.  It is,
00109    however, included in frchain_now.  The fr_fix field is bogus;
00110    instead, use frag_now_fix ().  */
00111 COMMON fragS *frag_now;
00112 extern addressT frag_now_fix (void);
00113 extern addressT frag_now_fix_octets (void);
00114 
00115 /* For foreign-segment symbol fixups.  */
00116 COMMON fragS zero_address_frag;
00117 /* For local common (N_BSS segment) fixups.  */
00118 COMMON fragS bss_address_frag;
00119 
00120 extern void frag_append_1_char (int);
00121 #define FRAG_APPEND_1_CHAR(X) frag_append_1_char (X)
00122 
00123 void frag_init (void);
00124 fragS *frag_alloc (struct obstack *);
00125 void frag_grow (unsigned int nchars);
00126 char *frag_more (int nchars);
00127 void frag_align (int alignment, int fill_character, int max);
00128 void frag_align_pattern (int alignment, const char *fill_pattern,
00129                       int n_fill, int max);
00130 void frag_align_code (int alignment, int max);
00131 void frag_new (int old_frags_var_max_size);
00132 void frag_wane (fragS * fragP);
00133 int frag_room (void);
00134 
00135 char *frag_variant (relax_stateT type,
00136                   int max_chars,
00137                   int var,
00138                   relax_substateT subtype,
00139                   symbolS * symbol,
00140                   offsetT offset,
00141                   char *opcode);
00142 
00143 char *frag_var (relax_stateT type,
00144               int max_chars,
00145               int var,
00146               relax_substateT subtype,
00147               symbolS * symbol,
00148               offsetT offset,
00149               char *opcode);
00150 
00151 bfd_boolean frag_offset_fixed_p (const fragS *, const fragS *, bfd_vma *);
00152 
00153 #endif /* FRAGS_H */