3 /* frags.h - Header file for the frag concept.
4 Copyright (C) 1987 Free Software Foundation, Inc.
6 This file is part of GAS, the GNU Assembler.
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 1, or (at your option)
13 GAS is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GAS; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
24 #import "struc-symbol.h"
27 * A code fragment (frag) is some known number of chars, followed by some
28 * unknown number of chars. Typically the unknown number of chars is an
29 * instruction address whose size is yet unknown. We always know the greatest
30 * possible size the unknown number of chars may become, and reserve that
31 * much room at the end of the frag.
32 * Once created, frags do not change address during assembly.
33 * We chain the frags in (a) forward-linked list(s). The object-file address
34 * of the 1st char of a frag is generally not known until after relax().
35 * Many things at assembly time describe an address by {object-file-address
36 * of a particular frag}+offset.
38 BUG: it may be smarter to have a single pointer off to various different
39 notes for different frag kinds. See how code pans out.
42 struct frag
/* a code fragment */
44 uint64_t fr_address
; /* Object file address. */
45 uint64_t last_fr_address
; /* When relaxing multiple times, remember the */
46 /* address the frag had in the last relax pass*/
47 struct frag
*fr_next
; /* Chain forward; ascending address order. */
48 /* Rooted in frch_root. */
50 int32_t fr_fix
; /* (Fixed) number of chars we know we have. */
52 int32_t fr_var
; /* (Variable) number of chars after above. */
54 struct symbol
*fr_symbol
; /* For variable-length tail. */
55 int32_t fr_offset
; /* For variable-length tail. */
56 char *fr_opcode
; /* ->opcode low addr byte,for relax()ation*/
57 relax_stateT fr_type
; /* What state is my tail in? */
58 relax_substateT fr_subtype
; /* Used to index in to md_relax_table for */
59 /* fr_type == rs_machine_dependent frags. */
61 /* Where the frag was created, or where it became a variant frag. */
64 /* Flipped each relax pass so we can easily determine whether
65 fr_address has been adjusted. */
66 unsigned int relax_marker
:1,
69 char fr_literal
[1]; /* Chars begin here. */
70 /* One day we will compile fr_literal[0]. */
73 /* We want to say fr_literal[0] below */
74 #define SIZEOF_STRUCT_FRAG \
75 ((uintptr_t)zero_address_frag.fr_literal - (uintptr_t)&zero_address_frag)
78 * frag_now points at the current frag we are building. This frag is incomplete.
79 * It is, however, included in frchain_now. Frag_now->fr_fix is not the total
80 * bytes in use for the frag. For that use:
81 * frag_now->fr_fix + obstack_next_free(&frags) - frag_now->fr_literal.
83 extern fragS
*frag_now
;
84 extern addressT
frag_now_fix (void);
85 extern addressT
frag_now_fix_octets (void);
88 * Frags ONLY live in this obstack. We use obstack_next_free() macro
89 * so please don't put any other objects on this stack!
91 extern struct obstack frags
;
93 /* For foreign-segment symbol fixups. */
94 extern fragS zero_address_frag
;
96 void frag_grow (unsigned int nchars
);
98 int old_frags_var_max_size
);
99 extern char * frag_more(
101 extern char *frag_var(
105 relax_substateT subtype
,
109 extern void frag_wane(
111 extern void frag_align(
112 int power_of_2_alignment
,
115 int max_bytes_to_fill
);
118 * A macro to speed up appending exactly 1 char
121 /* JF changed < 1 to <= 1 to avoid a race conditon */
122 #define FRAG_APPEND_1_CHAR(datum) \
124 if (obstack_room( &frags ) <= 1) {\
125 frag_wane (frag_now); \
128 (void)obstack_1grow( &frags, datum ); \
130 #endif /* _FRAGS_H_ */