Annotation of GNUtools/cctools/as/frags.h, revision 1.1.1.1

1.1       root        1: /* frags.h - Header file for the frag concept.
                      2:    Copyright (C) 1987 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 1, or (at your option)
                      9: any later version.
                     10: 
                     11: GAS is distributed in the hope that it will be useful,
                     12: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     14: GNU General Public 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
                     18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
                     19: 
                     20: #import "relax.h"
                     21: #import "struc-symbol.h"
                     22: 
                     23: /*
                     24:  * A code fragment (frag) is some known number of chars, followed by some
                     25:  * unknown number of chars. Typically the unknown number of chars is an
                     26:  * instruction address whose size is yet unknown. We always know the greatest
                     27:  * possible size the unknown number of chars may become, and reserve that
                     28:  * much room at the end of the frag.
                     29:  * Once created, frags do not change address during assembly.
                     30:  * We chain the frags in (a) forward-linked list(s). The object-file address
                     31:  * of the 1st char of a frag is generally not known until after relax().
                     32:  * Many things at assembly time describe an address by {object-file-address
                     33:  * of a particular frag}+offset.
                     34: 
                     35:  BUG: it may be smarter to have a single pointer off to various different
                     36: notes for different frag kinds. See how code pans out.
                     37: 
                     38:  */
                     39: struct frag                    /* a code fragment */
                     40: {
                     41:     unsigned long fr_address;  /* Object file address. */
                     42:     struct frag *fr_next;      /* Chain forward; ascending address order. */
                     43:                                /* Rooted in frch_root. */
                     44: 
                     45:     long fr_fix;               /* (Fixed) number of chars we know we have. */
                     46:                                /* May be 0. */
                     47:     long fr_var;               /* (Variable) number of chars after above. */
                     48:                                /* May be 0. */
                     49:     struct symbol *fr_symbol;  /* For variable-length tail. */
                     50:     long fr_offset;            /* For variable-length tail. */
                     51:     char *fr_opcode;           /* ->opcode low addr byte,for relax()ation*/
                     52:     relax_stateT fr_type;      /* What state is my tail in? */
                     53:     relax_substateT fr_subtype;        /* Used to index in to md_relax_table for */
                     54:                                /*  fr_type == rs_machine_dependent frags. */
                     55:     char fr_literal[1];                /* Chars begin here. */
                     56:                                /* One day we will compile fr_literal[0]. */
                     57: };
                     58: typedef struct frag fragS;
                     59: 
                     60: /* We want to say fr_literal[0] below */
                     61: #define SIZEOF_STRUCT_FRAG \
                     62:  ((int)zero_address_frag.fr_literal - (int)&zero_address_frag)
                     63: 
                     64: /*
                     65:  * frag_now points at the current frag we are building. This frag is incomplete.
                     66:  * It is, however, included in frchain_now. Frag_now->fr_fix is not the total
                     67:  * bytes in use for the frag.  For that use:
                     68:  * frag_now->fr_fix + obstack_next_free(&frags) - frag_now->fr_literal.
                     69:  */
                     70: extern fragS *frag_now;
                     71: 
                     72: /*
                     73:  * Frags ONLY live in this obstack.  We use obstack_next_free() macro 
                     74:  * so please don't put any other objects on this stack!
                     75:  */
                     76: extern struct obstack frags;
                     77: 
                     78: /* For foreign-segment symbol fixups. */
                     79: extern fragS zero_address_frag;
                     80: 
                     81: extern void frag_new(
                     82:     int old_frags_var_max_size);
                     83: extern char * frag_more(
                     84:     int nchars);
                     85: extern char *frag_var(
                     86:     relax_stateT type,
                     87:     int max_chars,
                     88:     int var,
                     89:     relax_substateT subtype,
                     90:     symbolS *symbol,
                     91:     long offset,
                     92:     char *opcode);
                     93: extern void frag_wane(
                     94:     fragS *fragP);
                     95: extern void frag_align(
                     96:     int alignment,
                     97:     int fill_character);
                     98: 
                     99: /*
                    100:  * A macro to speed up appending exactly 1 char
                    101:  * to current frag.
                    102:  */
                    103: /* JF changed < 1 to <= 1 to avoid a race conditon */
                    104: #define FRAG_APPEND_1_CHAR(datum)      \
                    105: {                                      \
                    106:        if (obstack_room( &frags ) <= 1) {\
                    107:                frag_wane (frag_now);   \
                    108:                frag_new (0);           \
                    109:        }                               \
                    110:        obstack_1grow( &frags, datum ); \
                    111: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.