xref: /dflybsd-src/contrib/binutils-2.27/gas/subsegs.h (revision e656dc90e3d65d744d534af2f5ea88cf8101ebcf)
1*a9fa9459Szrj /* subsegs.h -> subsegs.c
2*a9fa9459Szrj    Copyright (C) 1987-2016 Free Software Foundation, Inc.
3*a9fa9459Szrj 
4*a9fa9459Szrj    This file is part of GAS, the GNU Assembler.
5*a9fa9459Szrj 
6*a9fa9459Szrj    GAS is free software; you can redistribute it and/or modify
7*a9fa9459Szrj    it under the terms of the GNU General Public License as published by
8*a9fa9459Szrj    the Free Software Foundation; either version 3, or (at your option)
9*a9fa9459Szrj    any later version.
10*a9fa9459Szrj 
11*a9fa9459Szrj    GAS is distributed in the hope that it will be useful,
12*a9fa9459Szrj    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*a9fa9459Szrj    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*a9fa9459Szrj    GNU General Public License for more details.
15*a9fa9459Szrj 
16*a9fa9459Szrj    You should have received a copy of the GNU General Public License
17*a9fa9459Szrj    along with GAS; see the file COPYING.  If not, write to the Free
18*a9fa9459Szrj    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
19*a9fa9459Szrj    02110-1301, USA.  */
20*a9fa9459Szrj 
21*a9fa9459Szrj /*
22*a9fa9459Szrj  * For every sub-segment the user mentions in the ASsembler program,
23*a9fa9459Szrj  * we make one struct frchain. Each sub-segment has exactly one struct frchain
24*a9fa9459Szrj  * and vice versa.
25*a9fa9459Szrj  *
26*a9fa9459Szrj  * Struct frchain's are forward chained (in ascending order of sub-segment
27*a9fa9459Szrj  * code number). The chain runs through frch_next of each subsegment.
28*a9fa9459Szrj  * This makes it hard to find a subsegment's frags
29*a9fa9459Szrj  * if programmer uses a lot of them. Most programs only use text0 and
30*a9fa9459Szrj  * data0, so they don't suffer. At least this way:
31*a9fa9459Szrj  * (1)	There are no "arbitrary" restrictions on how many subsegments
32*a9fa9459Szrj  *	can be programmed;
33*a9fa9459Szrj  * (2)	Subsegments' frchain-s are (later) chained together in the order in
34*a9fa9459Szrj  *	which they are emitted for object file viz text then data.
35*a9fa9459Szrj  *
36*a9fa9459Szrj  * From each struct frchain dangles a chain of struct frags. The frags
37*a9fa9459Szrj  * represent code fragments, for that sub-segment, forward chained.
38*a9fa9459Szrj  */
39*a9fa9459Szrj 
40*a9fa9459Szrj #include "obstack.h"
41*a9fa9459Szrj 
42*a9fa9459Szrj struct frch_cfi_data;
43*a9fa9459Szrj 
44*a9fa9459Szrj struct frchain			/* control building of a frag chain */
45*a9fa9459Szrj {				/* FRCH = FRagment CHain control */
46*a9fa9459Szrj   struct frag *frch_root;	/* 1st struct frag in chain, or NULL */
47*a9fa9459Szrj   struct frag *frch_last;	/* last struct frag in chain, or NULL */
48*a9fa9459Szrj   struct frchain *frch_next;	/* next in chain of struct frchain-s */
49*a9fa9459Szrj   subsegT frch_subseg;		/* subsegment number of this chain */
50*a9fa9459Szrj   fixS *fix_root;		/* Root of fixups for this subsegment.  */
51*a9fa9459Szrj   fixS *fix_tail;		/* Last fixup for this subsegment.  */
52*a9fa9459Szrj   struct obstack frch_obstack;	/* for objects in this frag chain */
53*a9fa9459Szrj   fragS *frch_frag_now;		/* frag_now for this subsegment */
54*a9fa9459Szrj   struct frch_cfi_data *frch_cfi_data;
55*a9fa9459Szrj };
56*a9fa9459Szrj 
57*a9fa9459Szrj typedef struct frchain frchainS;
58*a9fa9459Szrj 
59*a9fa9459Szrj /* Frchain we are assembling into now.  That is, the current segment's
60*a9fa9459Szrj    frag chain, even if it contains no (complete) frags.  */
61*a9fa9459Szrj extern frchainS *frchain_now;
62*a9fa9459Szrj 
63*a9fa9459Szrj typedef struct segment_info_struct {
64*a9fa9459Szrj   frchainS *frchainP;
65*a9fa9459Szrj   unsigned int hadone : 1;
66*a9fa9459Szrj 
67*a9fa9459Szrj   /* This field is set if this is a .bss section which does not really
68*a9fa9459Szrj      have any contents.  Once upon a time a .bss section did not have
69*a9fa9459Szrj      any frags, but that is no longer true.  This field prevent the
70*a9fa9459Szrj      SEC_HAS_CONTENTS flag from being set for the section even if
71*a9fa9459Szrj      there are frags.  */
72*a9fa9459Szrj   unsigned int bss : 1;
73*a9fa9459Szrj 
74*a9fa9459Szrj   int user_stuff;
75*a9fa9459Szrj 
76*a9fa9459Szrj   /* Fixups for this segment.  This is only valid after the frchains
77*a9fa9459Szrj      are run together.  */
78*a9fa9459Szrj   fixS *fix_root;
79*a9fa9459Szrj   fixS *fix_tail;
80*a9fa9459Szrj 
81*a9fa9459Szrj   symbolS *dot;
82*a9fa9459Szrj 
83*a9fa9459Szrj   struct lineno_list *lineno_list_head;
84*a9fa9459Szrj   struct lineno_list *lineno_list_tail;
85*a9fa9459Szrj 
86*a9fa9459Szrj   /* Which BFD section does this gas segment correspond to?  */
87*a9fa9459Szrj   asection *bfd_section;
88*a9fa9459Szrj 
89*a9fa9459Szrj   /* NULL, or pointer to the gas symbol that is the section symbol for
90*a9fa9459Szrj      this section.  sym->bsym and bfd_section->symbol should be the same.  */
91*a9fa9459Szrj   symbolS *sym;
92*a9fa9459Szrj 
93*a9fa9459Szrj   /* Used by dwarf2dbg.c for this section's line table entries.  */
94*a9fa9459Szrj   void *dwarf2_line_seg;
95*a9fa9459Szrj 
96*a9fa9459Szrj   union {
97*a9fa9459Szrj     /* Current size of section holding stabs strings.  */
98*a9fa9459Szrj     unsigned long stab_string_size;
99*a9fa9459Szrj     /* Initial frag for ELF.  */
100*a9fa9459Szrj     char *p;
101*a9fa9459Szrj   }
102*a9fa9459Szrj   stabu;
103*a9fa9459Szrj 
104*a9fa9459Szrj #ifdef NEED_LITERAL_POOL
105*a9fa9459Szrj   unsigned long literal_pool_size;
106*a9fa9459Szrj #endif
107*a9fa9459Szrj 
108*a9fa9459Szrj #ifdef TC_SEGMENT_INFO_TYPE
109*a9fa9459Szrj   TC_SEGMENT_INFO_TYPE tc_segment_info_data;
110*a9fa9459Szrj #endif
111*a9fa9459Szrj } segment_info_type;
112*a9fa9459Szrj 
113*a9fa9459Szrj 
114*a9fa9459Szrj #define seg_info(sec) \
115*a9fa9459Szrj   ((segment_info_type *) bfd_get_section_userdata (stdoutput, sec))
116*a9fa9459Szrj 
117*a9fa9459Szrj extern symbolS *section_symbol (segT);
118*a9fa9459Szrj 
119*a9fa9459Szrj extern void subsegs_print_statistics (FILE *);
120