133965Sjdp/* subsegs.h -> subsegs.c
2218822Sdim   Copyright 1987, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2003, 2005,
3218822Sdim   2006 Free Software Foundation, Inc.
433965Sjdp
533965Sjdp   This file is part of GAS, the GNU Assembler.
633965Sjdp
733965Sjdp   GAS is free software; you can redistribute it and/or modify
833965Sjdp   it under the terms of the GNU General Public License as published by
933965Sjdp   the Free Software Foundation; either version 2, or (at your option)
1033965Sjdp   any later version.
1133965Sjdp
1233965Sjdp   GAS is distributed in the hope that it will be useful,
1333965Sjdp   but WITHOUT ANY WARRANTY; without even the implied warranty of
1433965Sjdp   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1533965Sjdp   GNU General Public License for more details.
1633965Sjdp
1733965Sjdp   You should have received a copy of the GNU General Public License
1860484Sobrien   along with GAS; see the file COPYING.  If not, write to the Free
19218822Sdim   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20218822Sdim   02110-1301, USA.  */
2133965Sjdp
2233965Sjdp/*
2333965Sjdp * For every sub-segment the user mentions in the ASsembler program,
2433965Sjdp * we make one struct frchain. Each sub-segment has exactly one struct frchain
2533965Sjdp * and vice versa.
2633965Sjdp *
2733965Sjdp * Struct frchain's are forward chained (in ascending order of sub-segment
2833965Sjdp * code number). The chain runs through frch_next of each subsegment.
2933965Sjdp * This makes it hard to find a subsegment's frags
3033965Sjdp * if programmer uses a lot of them. Most programs only use text0 and
3133965Sjdp * data0, so they don't suffer. At least this way:
3233965Sjdp * (1)	There are no "arbitrary" restrictions on how many subsegments
3333965Sjdp *	can be programmed;
3433965Sjdp * (2)	Subsegments' frchain-s are (later) chained together in the order in
3533965Sjdp *	which they are emitted for object file viz text then data.
3633965Sjdp *
3733965Sjdp * From each struct frchain dangles a chain of struct frags. The frags
3833965Sjdp * represent code fragments, for that sub-segment, forward chained.
3933965Sjdp */
4033965Sjdp
4133965Sjdp#include "obstack.h"
4233965Sjdp
43218822Sdimstruct frch_cfi_data;
44218822Sdim
4533965Sjdpstruct frchain			/* control building of a frag chain */
4633965Sjdp{				/* FRCH = FRagment CHain control */
4733965Sjdp  struct frag *frch_root;	/* 1st struct frag in chain, or NULL */
4833965Sjdp  struct frag *frch_last;	/* last struct frag in chain, or NULL */
4933965Sjdp  struct frchain *frch_next;	/* next in chain of struct frchain-s */
5033965Sjdp  subsegT frch_subseg;		/* subsegment number of this chain */
5133965Sjdp  fixS *fix_root;		/* Root of fixups for this subsegment.  */
5233965Sjdp  fixS *fix_tail;		/* Last fixup for this subsegment.  */
5333965Sjdp  struct obstack frch_obstack;	/* for objects in this frag chain */
5433965Sjdp  fragS *frch_frag_now;		/* frag_now for this subsegment */
55218822Sdim  struct frch_cfi_data *frch_cfi_data;
5633965Sjdp};
5733965Sjdp
5833965Sjdptypedef struct frchain frchainS;
5933965Sjdp
6033965Sjdp/* Frchain we are assembling into now.  That is, the current segment's
6177298Sobrien   frag chain, even if it contains no (complete) frags.  */
6233965Sjdpextern frchainS *frchain_now;
6333965Sjdp
6477298Sobrientypedef struct segment_info_struct {
6533965Sjdp  frchainS *frchainP;
6633965Sjdp  unsigned int hadone : 1;
6733965Sjdp
6833965Sjdp  /* This field is set if this is a .bss section which does not really
6933965Sjdp     have any contents.  Once upon a time a .bss section did not have
7033965Sjdp     any frags, but that is no longer true.  This field prevent the
7133965Sjdp     SEC_HAS_CONTENTS flag from being set for the section even if
7233965Sjdp     there are frags.  */
7333965Sjdp  unsigned int bss : 1;
7433965Sjdp
7533965Sjdp  int user_stuff;
7633965Sjdp
77218822Sdim  /* Fixups for this segment.  This is only valid after the frchains
78218822Sdim     are run together.  */
7933965Sjdp  fixS *fix_root;
8033965Sjdp  fixS *fix_tail;
8133965Sjdp
8233965Sjdp  symbolS *dot;
8333965Sjdp
8433965Sjdp  struct lineno_list *lineno_list_head;
8533965Sjdp  struct lineno_list *lineno_list_tail;
8633965Sjdp
8733965Sjdp  /* Which BFD section does this gas segment correspond to?  */
8833965Sjdp  asection *bfd_section;
8933965Sjdp
9033965Sjdp  /* NULL, or pointer to the gas symbol that is the section symbol for
9133965Sjdp     this section.  sym->bsym and bfd_section->symbol should be the same.  */
9233965Sjdp  symbolS *sym;
9333965Sjdp
9477298Sobrien  union {
9577298Sobrien    /* Current size of section holding stabs strings.  */
9677298Sobrien    unsigned long stab_string_size;
9777298Sobrien    /* Initial frag for ELF.  */
9877298Sobrien    char *p;
9977298Sobrien  }
10033965Sjdp  stabu;
10133965Sjdp
10233965Sjdp#ifdef NEED_LITERAL_POOL
10333965Sjdp  unsigned long literal_pool_size;
10433965Sjdp#endif
10533965Sjdp
10633965Sjdp#ifdef TC_SEGMENT_INFO_TYPE
10733965Sjdp  TC_SEGMENT_INFO_TYPE tc_segment_info_data;
10833965Sjdp#endif
10933965Sjdp} segment_info_type;
11033965Sjdp
11133965Sjdp
112218822Sdim#define seg_info(sec) \
113218822Sdim  ((segment_info_type *) bfd_get_section_userdata (stdoutput, sec))
114218822Sdim
115130561Sobrienextern symbolS *section_symbol (segT);
11633965Sjdp
117130561Sobrienextern void subsegs_print_statistics (FILE *);
118