1991-04-05 02:19:53 +08:00
|
|
|
|
/* subsegs.c - subsegments -
|
1994-04-13 10:02:48 +08:00
|
|
|
|
Copyright (C) 1987, 1990, 1991, 1992, 1993, 1994
|
|
|
|
|
Free Software Foundation, Inc.
|
1993-09-14 05:32:07 +08:00
|
|
|
|
|
1992-02-13 16:33:54 +08:00
|
|
|
|
This file is part of GAS, the GNU Assembler.
|
1993-09-14 05:32:07 +08:00
|
|
|
|
|
1992-02-13 16:33:54 +08:00
|
|
|
|
GAS is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
any later version.
|
1993-09-14 05:32:07 +08:00
|
|
|
|
|
1992-02-13 16:33:54 +08:00
|
|
|
|
GAS is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
1993-09-14 05:32:07 +08:00
|
|
|
|
|
1992-02-13 16:33:54 +08:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with GAS; see the file COPYING. If not, write to
|
1995-08-09 05:41:30 +08:00
|
|
|
|
the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
1991-04-05 02:19:53 +08:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Segments & sub-segments.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "as.h"
|
|
|
|
|
|
|
|
|
|
#include "subsegs.h"
|
|
|
|
|
#include "obstack.h"
|
|
|
|
|
|
1993-09-14 05:32:07 +08:00
|
|
|
|
frchainS *frchain_root, *frchain_now;
|
|
|
|
|
|
Use one active frag and one obstack per frag chain:
* frags.c (frags): Variable deleted.
(frag_alloc): New function.
(frag_grow, frag_more, frag_variant, frag_now_fix, frag_append_1_char): Refer
to frchain_now->frch_obstack instead of frags variable.
(frag_new): Ditto. Verify that frch_last and frag_now match on entry and exit,
and that old frag_now has non-zero type. Replace "know" uses with "assert".
Use frag_alloc instead of mucking with obstack alignment.
* frags.h (frags): Declaration deleted.
* subsegs.h (struct frchain): Add new field frch_frag_now.
* subsegs.c (frchains, dummy_frag, absolute_frchain): New static variables.
(subsegs_begin): Initialize frchains obstack. Under gcc, don't give it any
stricter alignment than frchainS structures need. Do not initialize frags
obstack. Set frag_now to point to dummy_obstack. Initialize absolute_frchain.
(subseg_set_rest): Save and restore frag_now in frch_frag_now field of
frchainS. Don't create new frags on section switch, and use frag_alloc when
creating a new frag chain. For absolute section, set frchain_now to
absolute_frchain. Verify that frch_last and frag_now match on entry and exit.
Initialize per-chain obstack, and under gcc, set required alignment to that
needed by fragS structure.
* write.c (chain_frchains_together_1): Verify fr_type is nonzero.
In one test case of Mike's (i386-linux, over 300K lines of .s code with lots
of stabs records), run time and memory use are reduced by about 1/3.
Might introduce some problems in cases that use the frag obstacks in unusual
ways. Test suite does pass for i386-linux and sparc-solaris targets though.
1995-10-19 05:21:38 +08:00
|
|
|
|
static struct obstack frchains;
|
|
|
|
|
|
1993-09-14 05:32:07 +08:00
|
|
|
|
#ifndef BFD_ASSEMBLER
|
1992-02-13 16:33:54 +08:00
|
|
|
|
#ifdef MANY_SEGMENTS
|
|
|
|
|
segment_info_type segment_info[SEG_MAXIMUM_ORDINAL];
|
|
|
|
|
|
|
|
|
|
#else
|
1993-09-14 05:32:07 +08:00
|
|
|
|
/* Commented in "subsegs.h". */
|
|
|
|
|
frchainS *data0_frchainP, *bss0_frchainP;
|
1991-04-05 02:19:53 +08:00
|
|
|
|
|
1993-09-14 05:32:07 +08:00
|
|
|
|
#endif /* MANY_SEGMENTS */
|
1995-08-09 05:41:30 +08:00
|
|
|
|
char const *const seg_name[] =
|
1993-09-14 05:32:07 +08:00
|
|
|
|
{
|
|
|
|
|
"absolute",
|
1992-02-13 16:33:54 +08:00
|
|
|
|
#ifdef MANY_SEGMENTS
|
1993-09-14 05:32:07 +08:00
|
|
|
|
"e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9",
|
1992-02-13 16:33:54 +08:00
|
|
|
|
#else
|
1993-09-14 05:32:07 +08:00
|
|
|
|
"text",
|
|
|
|
|
"data",
|
|
|
|
|
"bss",
|
|
|
|
|
#endif /* MANY_SEGMENTS */
|
|
|
|
|
"unknown",
|
|
|
|
|
"ASSEMBLER-INTERNAL-LOGIC-ERROR!",
|
|
|
|
|
"expr",
|
|
|
|
|
"debug",
|
|
|
|
|
"transfert vector preload",
|
|
|
|
|
"transfert vector postload",
|
|
|
|
|
"register",
|
|
|
|
|
"",
|
|
|
|
|
}; /* Used by error reporters, dumpers etc. */
|
1994-06-22 00:45:09 +08:00
|
|
|
|
#else /* BFD_ASSEMBLER */
|
|
|
|
|
|
|
|
|
|
/* Gas segment information for bfd_abs_section_ptr and
|
|
|
|
|
bfd_und_section_ptr. */
|
|
|
|
|
static segment_info_type *abs_seg_info;
|
|
|
|
|
static segment_info_type *und_seg_info;
|
|
|
|
|
|
1993-09-14 05:32:07 +08:00
|
|
|
|
#endif /* BFD_ASSEMBLER */
|
1991-04-05 02:19:53 +08:00
|
|
|
|
|
1993-09-14 05:32:07 +08:00
|
|
|
|
static void subseg_set_rest PARAMS ((segT, subsegT));
|
Use one active frag and one obstack per frag chain:
* frags.c (frags): Variable deleted.
(frag_alloc): New function.
(frag_grow, frag_more, frag_variant, frag_now_fix, frag_append_1_char): Refer
to frchain_now->frch_obstack instead of frags variable.
(frag_new): Ditto. Verify that frch_last and frag_now match on entry and exit,
and that old frag_now has non-zero type. Replace "know" uses with "assert".
Use frag_alloc instead of mucking with obstack alignment.
* frags.h (frags): Declaration deleted.
* subsegs.h (struct frchain): Add new field frch_frag_now.
* subsegs.c (frchains, dummy_frag, absolute_frchain): New static variables.
(subsegs_begin): Initialize frchains obstack. Under gcc, don't give it any
stricter alignment than frchainS structures need. Do not initialize frags
obstack. Set frag_now to point to dummy_obstack. Initialize absolute_frchain.
(subseg_set_rest): Save and restore frag_now in frch_frag_now field of
frchainS. Don't create new frags on section switch, and use frag_alloc when
creating a new frag chain. For absolute section, set frchain_now to
absolute_frchain. Verify that frch_last and frag_now match on entry and exit.
Initialize per-chain obstack, and under gcc, set required alignment to that
needed by fragS structure.
* write.c (chain_frchains_together_1): Verify fr_type is nonzero.
In one test case of Mike's (i386-linux, over 300K lines of .s code with lots
of stabs records), run time and memory use are reduced by about 1/3.
Might introduce some problems in cases that use the frag obstacks in unusual
ways. Test suite does pass for i386-linux and sparc-solaris targets though.
1995-10-19 05:21:38 +08:00
|
|
|
|
|
|
|
|
|
static fragS dummy_frag;
|
|
|
|
|
|
|
|
|
|
static frchainS absolute_frchain;
|
1991-04-05 02:19:53 +08:00
|
|
|
|
|
|
|
|
|
void
|
1993-09-14 05:32:07 +08:00
|
|
|
|
subsegs_begin ()
|
1991-04-05 02:19:53 +08:00
|
|
|
|
{
|
1993-09-14 05:32:07 +08:00
|
|
|
|
/* Check table(s) seg_name[], seg_N_TYPE[] is in correct order */
|
|
|
|
|
#if !defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
|
|
|
|
|
know (SEG_ABSOLUTE == 0);
|
|
|
|
|
know (SEG_TEXT == 1);
|
|
|
|
|
know (SEG_DATA == 2);
|
|
|
|
|
know (SEG_BSS == 3);
|
|
|
|
|
know (SEG_UNKNOWN == 4);
|
|
|
|
|
know (SEG_GOOF == 5);
|
|
|
|
|
know (SEG_EXPR == 6);
|
|
|
|
|
know (SEG_DEBUG == 7);
|
|
|
|
|
know (SEG_NTV == 8);
|
|
|
|
|
know (SEG_PTV == 9);
|
|
|
|
|
know (SEG_REGISTER == 10);
|
|
|
|
|
know (SEG_MAXIMUM_ORDINAL == SEG_REGISTER);
|
1992-02-13 16:33:54 +08:00
|
|
|
|
#endif
|
1993-09-14 05:32:07 +08:00
|
|
|
|
|
Use one active frag and one obstack per frag chain:
* frags.c (frags): Variable deleted.
(frag_alloc): New function.
(frag_grow, frag_more, frag_variant, frag_now_fix, frag_append_1_char): Refer
to frchain_now->frch_obstack instead of frags variable.
(frag_new): Ditto. Verify that frch_last and frag_now match on entry and exit,
and that old frag_now has non-zero type. Replace "know" uses with "assert".
Use frag_alloc instead of mucking with obstack alignment.
* frags.h (frags): Declaration deleted.
* subsegs.h (struct frchain): Add new field frch_frag_now.
* subsegs.c (frchains, dummy_frag, absolute_frchain): New static variables.
(subsegs_begin): Initialize frchains obstack. Under gcc, don't give it any
stricter alignment than frchainS structures need. Do not initialize frags
obstack. Set frag_now to point to dummy_obstack. Initialize absolute_frchain.
(subseg_set_rest): Save and restore frag_now in frch_frag_now field of
frchainS. Don't create new frags on section switch, and use frag_alloc when
creating a new frag chain. For absolute section, set frchain_now to
absolute_frchain. Verify that frch_last and frag_now match on entry and exit.
Initialize per-chain obstack, and under gcc, set required alignment to that
needed by fragS structure.
* write.c (chain_frchains_together_1): Verify fr_type is nonzero.
In one test case of Mike's (i386-linux, over 300K lines of .s code with lots
of stabs records), run time and memory use are reduced by about 1/3.
Might introduce some problems in cases that use the frag obstacks in unusual
ways. Test suite does pass for i386-linux and sparc-solaris targets though.
1995-10-19 05:21:38 +08:00
|
|
|
|
obstack_begin (&frchains, chunksize);
|
|
|
|
|
#if __GNUC__ >= 2
|
|
|
|
|
obstack_alignment_mask (&frchains) = __alignof__ (frchainS) - 1;
|
|
|
|
|
#endif
|
|
|
|
|
|
1993-09-14 05:32:07 +08:00
|
|
|
|
frchain_root = NULL;
|
|
|
|
|
frchain_now = NULL; /* Warn new_subseg() that we are booting. */
|
Use one active frag and one obstack per frag chain:
* frags.c (frags): Variable deleted.
(frag_alloc): New function.
(frag_grow, frag_more, frag_variant, frag_now_fix, frag_append_1_char): Refer
to frchain_now->frch_obstack instead of frags variable.
(frag_new): Ditto. Verify that frch_last and frag_now match on entry and exit,
and that old frag_now has non-zero type. Replace "know" uses with "assert".
Use frag_alloc instead of mucking with obstack alignment.
* frags.h (frags): Declaration deleted.
* subsegs.h (struct frchain): Add new field frch_frag_now.
* subsegs.c (frchains, dummy_frag, absolute_frchain): New static variables.
(subsegs_begin): Initialize frchains obstack. Under gcc, don't give it any
stricter alignment than frchainS structures need. Do not initialize frags
obstack. Set frag_now to point to dummy_obstack. Initialize absolute_frchain.
(subseg_set_rest): Save and restore frag_now in frch_frag_now field of
frchainS. Don't create new frags on section switch, and use frag_alloc when
creating a new frag chain. For absolute section, set frchain_now to
absolute_frchain. Verify that frch_last and frag_now match on entry and exit.
Initialize per-chain obstack, and under gcc, set required alignment to that
needed by fragS structure.
* write.c (chain_frchains_together_1): Verify fr_type is nonzero.
In one test case of Mike's (i386-linux, over 300K lines of .s code with lots
of stabs records), run time and memory use are reduced by about 1/3.
Might introduce some problems in cases that use the frag obstacks in unusual
ways. Test suite does pass for i386-linux and sparc-solaris targets though.
1995-10-19 05:21:38 +08:00
|
|
|
|
|
|
|
|
|
frag_now = &dummy_frag;
|
1993-09-14 05:32:07 +08:00
|
|
|
|
|
|
|
|
|
#ifndef BFD_ASSEMBLER
|
|
|
|
|
now_subseg = 42; /* Lie for 1st call to subseg_new. */
|
1992-02-13 16:33:54 +08:00
|
|
|
|
#ifdef MANY_SEGMENTS
|
1993-09-14 05:32:07 +08:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for (i = SEG_E0; i < SEG_UNKNOWN; i++)
|
|
|
|
|
{
|
|
|
|
|
subseg_set (i, 0);
|
|
|
|
|
segment_info[i].frchainP = frchain_now;
|
|
|
|
|
}
|
|
|
|
|
}
|
1992-02-13 16:33:54 +08:00
|
|
|
|
#else
|
1993-09-14 05:32:07 +08:00
|
|
|
|
subseg_set (SEG_DATA, 0); /* .data 0 */
|
|
|
|
|
data0_frchainP = frchain_now;
|
1992-06-10 03:36:49 +08:00
|
|
|
|
|
1993-09-14 05:32:07 +08:00
|
|
|
|
subseg_set (SEG_BSS, 0);
|
|
|
|
|
bss0_frchainP = frchain_now;
|
|
|
|
|
|
|
|
|
|
#endif /* ! MANY_SEGMENTS */
|
|
|
|
|
#endif /* ! BFD_ASSEMBLER */
|
1992-06-10 03:36:49 +08:00
|
|
|
|
|
Use one active frag and one obstack per frag chain:
* frags.c (frags): Variable deleted.
(frag_alloc): New function.
(frag_grow, frag_more, frag_variant, frag_now_fix, frag_append_1_char): Refer
to frchain_now->frch_obstack instead of frags variable.
(frag_new): Ditto. Verify that frch_last and frag_now match on entry and exit,
and that old frag_now has non-zero type. Replace "know" uses with "assert".
Use frag_alloc instead of mucking with obstack alignment.
* frags.h (frags): Declaration deleted.
* subsegs.h (struct frchain): Add new field frch_frag_now.
* subsegs.c (frchains, dummy_frag, absolute_frchain): New static variables.
(subsegs_begin): Initialize frchains obstack. Under gcc, don't give it any
stricter alignment than frchainS structures need. Do not initialize frags
obstack. Set frag_now to point to dummy_obstack. Initialize absolute_frchain.
(subseg_set_rest): Save and restore frag_now in frch_frag_now field of
frchainS. Don't create new frags on section switch, and use frag_alloc when
creating a new frag chain. For absolute section, set frchain_now to
absolute_frchain. Verify that frch_last and frag_now match on entry and exit.
Initialize per-chain obstack, and under gcc, set required alignment to that
needed by fragS structure.
* write.c (chain_frchains_together_1): Verify fr_type is nonzero.
In one test case of Mike's (i386-linux, over 300K lines of .s code with lots
of stabs records), run time and memory use are reduced by about 1/3.
Might introduce some problems in cases that use the frag obstacks in unusual
ways. Test suite does pass for i386-linux and sparc-solaris targets though.
1995-10-19 05:21:38 +08:00
|
|
|
|
absolute_frchain.frch_seg = absolute_section;
|
|
|
|
|
absolute_frchain.frch_subseg = 0;
|
|
|
|
|
absolute_frchain.fix_root = absolute_frchain.fix_tail = 0;
|
|
|
|
|
absolute_frchain.frch_frag_now = &zero_address_frag;
|
|
|
|
|
absolute_frchain.frch_root = absolute_frchain.frch_last = &zero_address_frag;
|
1991-04-05 02:19:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* subseg_change()
|
|
|
|
|
*
|
|
|
|
|
* Change the subsegment we are in, BUT DO NOT MAKE A NEW FRAG for the
|
|
|
|
|
* subsegment. If we are already in the correct subsegment, change nothing.
|
1993-09-14 05:32:07 +08:00
|
|
|
|
* This is used eg as a worker for subseg_set [which does make a new frag_now]
|
1991-04-05 02:19:53 +08:00
|
|
|
|
* and for changing segments after we have read the source. We construct eg
|
|
|
|
|
* fixSs even after the source file is read, so we do have to keep the
|
|
|
|
|
* segment context correct.
|
|
|
|
|
*/
|
|
|
|
|
void
|
1993-09-14 05:32:07 +08:00
|
|
|
|
subseg_change (seg, subseg)
|
|
|
|
|
register segT seg;
|
|
|
|
|
register int subseg;
|
1991-04-05 02:19:53 +08:00
|
|
|
|
{
|
1993-09-14 05:32:07 +08:00
|
|
|
|
now_seg = seg;
|
|
|
|
|
now_subseg = subseg;
|
|
|
|
|
|
Use one active frag and one obstack per frag chain:
* frags.c (frags): Variable deleted.
(frag_alloc): New function.
(frag_grow, frag_more, frag_variant, frag_now_fix, frag_append_1_char): Refer
to frchain_now->frch_obstack instead of frags variable.
(frag_new): Ditto. Verify that frch_last and frag_now match on entry and exit,
and that old frag_now has non-zero type. Replace "know" uses with "assert".
Use frag_alloc instead of mucking with obstack alignment.
* frags.h (frags): Declaration deleted.
* subsegs.h (struct frchain): Add new field frch_frag_now.
* subsegs.c (frchains, dummy_frag, absolute_frchain): New static variables.
(subsegs_begin): Initialize frchains obstack. Under gcc, don't give it any
stricter alignment than frchainS structures need. Do not initialize frags
obstack. Set frag_now to point to dummy_obstack. Initialize absolute_frchain.
(subseg_set_rest): Save and restore frag_now in frch_frag_now field of
frchainS. Don't create new frags on section switch, and use frag_alloc when
creating a new frag chain. For absolute section, set frchain_now to
absolute_frchain. Verify that frch_last and frag_now match on entry and exit.
Initialize per-chain obstack, and under gcc, set required alignment to that
needed by fragS structure.
* write.c (chain_frchains_together_1): Verify fr_type is nonzero.
In one test case of Mike's (i386-linux, over 300K lines of .s code with lots
of stabs records), run time and memory use are reduced by about 1/3.
Might introduce some problems in cases that use the frag obstacks in unusual
ways. Test suite does pass for i386-linux and sparc-solaris targets though.
1995-10-19 05:21:38 +08:00
|
|
|
|
if (now_seg == absolute_section)
|
|
|
|
|
return;
|
|
|
|
|
|
1993-09-14 05:32:07 +08:00
|
|
|
|
#ifdef BFD_ASSEMBLER
|
|
|
|
|
{
|
|
|
|
|
segment_info_type *seginfo;
|
|
|
|
|
seginfo = (segment_info_type *) bfd_get_section_userdata (stdoutput, seg);
|
|
|
|
|
if (! seginfo)
|
|
|
|
|
{
|
|
|
|
|
seginfo = (segment_info_type *) xmalloc (sizeof (*seginfo));
|
Updated some copyrights, cleaned up some header-file comments, and:
* symbols.c (symbol_create): New function, most of the guts of the old
symbol_new function.
(symbol_new): Now just checks symbol_table_frozen, calls symbol_create, and
enters the symbol into the symbol table.
* subsegs.c (section_symbol): If EMIT_SECTION_SYMBOLS is not true, and the
symbol table is frozen, call symbol_create instead of symbol_new.
* symbols.h (symbol_create, symbol_table_frozen): Declare.
* symbols.c (symbol_clear_list_pointers): Always a function now.
* struc-symbol.h (symbol_clear_list_pointers): Deleted macro version.
* symbols.c (debug_verify_symchain): New macro, defined to be
verify_symbol_chain or a cast to void, depending on DEBUG_SYMS.
(many functions): Invoke debug_verify_symchain unconditionally.
1994-07-13 09:48:15 +08:00
|
|
|
|
memset ((PTR) seginfo, 0, sizeof (*seginfo));
|
1994-06-22 00:45:09 +08:00
|
|
|
|
seginfo->fix_root = NULL;
|
|
|
|
|
seginfo->fix_tail = NULL;
|
1993-09-14 05:32:07 +08:00
|
|
|
|
seginfo->bfd_section = seg;
|
|
|
|
|
seginfo->sym = 0;
|
1994-06-22 00:45:09 +08:00
|
|
|
|
if (seg == bfd_abs_section_ptr)
|
|
|
|
|
abs_seg_info = seginfo;
|
|
|
|
|
else if (seg == bfd_und_section_ptr)
|
|
|
|
|
und_seg_info = seginfo;
|
|
|
|
|
else
|
|
|
|
|
bfd_set_section_userdata (stdoutput, seg, (PTR) seginfo);
|
1993-09-14 05:32:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#else
|
1992-02-13 16:33:54 +08:00
|
|
|
|
#ifdef MANY_SEGMENTS
|
1993-09-14 05:32:07 +08:00
|
|
|
|
seg_fix_rootP = &segment_info[seg].fix_root;
|
|
|
|
|
seg_fix_tailP = &segment_info[seg].fix_tail;
|
1992-02-13 16:33:54 +08:00
|
|
|
|
#else
|
1993-09-14 05:32:07 +08:00
|
|
|
|
if (seg == SEG_DATA)
|
|
|
|
|
{
|
|
|
|
|
seg_fix_rootP = &data_fix_root;
|
|
|
|
|
seg_fix_tailP = &data_fix_tail;
|
|
|
|
|
}
|
|
|
|
|
else if (seg == SEG_TEXT)
|
|
|
|
|
{
|
|
|
|
|
seg_fix_rootP = &text_fix_root;
|
|
|
|
|
seg_fix_tailP = &text_fix_tail;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
know (seg == SEG_BSS);
|
|
|
|
|
seg_fix_rootP = &bss_fix_root;
|
|
|
|
|
seg_fix_tailP = &bss_fix_tail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
1992-02-13 16:33:54 +08:00
|
|
|
|
#endif
|
1991-04-05 02:19:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
1993-09-14 05:32:07 +08:00
|
|
|
|
static void
|
|
|
|
|
subseg_set_rest (seg, subseg)
|
|
|
|
|
segT seg;
|
|
|
|
|
subsegT subseg;
|
|
|
|
|
{
|
|
|
|
|
long tmp; /* JF for obstack alignment hacking */
|
|
|
|
|
register frchainS *frcP; /* crawl frchain chain */
|
|
|
|
|
register frchainS **lastPP; /* address of last pointer */
|
|
|
|
|
frchainS *newP; /* address of new frchain */
|
|
|
|
|
register fragS *former_last_fragP;
|
|
|
|
|
register fragS *new_fragP;
|
|
|
|
|
|
Use one active frag and one obstack per frag chain:
* frags.c (frags): Variable deleted.
(frag_alloc): New function.
(frag_grow, frag_more, frag_variant, frag_now_fix, frag_append_1_char): Refer
to frchain_now->frch_obstack instead of frags variable.
(frag_new): Ditto. Verify that frch_last and frag_now match on entry and exit,
and that old frag_now has non-zero type. Replace "know" uses with "assert".
Use frag_alloc instead of mucking with obstack alignment.
* frags.h (frags): Declaration deleted.
* subsegs.h (struct frchain): Add new field frch_frag_now.
* subsegs.c (frchains, dummy_frag, absolute_frchain): New static variables.
(subsegs_begin): Initialize frchains obstack. Under gcc, don't give it any
stricter alignment than frchainS structures need. Do not initialize frags
obstack. Set frag_now to point to dummy_obstack. Initialize absolute_frchain.
(subseg_set_rest): Save and restore frag_now in frch_frag_now field of
frchainS. Don't create new frags on section switch, and use frag_alloc when
creating a new frag chain. For absolute section, set frchain_now to
absolute_frchain. Verify that frch_last and frag_now match on entry and exit.
Initialize per-chain obstack, and under gcc, set required alignment to that
needed by fragS structure.
* write.c (chain_frchains_together_1): Verify fr_type is nonzero.
In one test case of Mike's (i386-linux, over 300K lines of .s code with lots
of stabs records), run time and memory use are reduced by about 1/3.
Might introduce some problems in cases that use the frag obstacks in unusual
ways. Test suite does pass for i386-linux and sparc-solaris targets though.
1995-10-19 05:21:38 +08:00
|
|
|
|
mri_common_symbol = NULL;
|
|
|
|
|
|
|
|
|
|
if (frag_now && frchain_now)
|
|
|
|
|
frchain_now->frch_frag_now = frag_now;
|
|
|
|
|
|
|
|
|
|
assert (frchain_now == 0
|
|
|
|
|
|| now_seg == undefined_section
|
|
|
|
|
|| now_seg == absolute_section
|
|
|
|
|
|| frchain_now->frch_last == frag_now);
|
|
|
|
|
|
|
|
|
|
subseg_change (seg, (int) subseg);
|
|
|
|
|
|
|
|
|
|
if (seg == absolute_section)
|
1993-09-14 05:32:07 +08:00
|
|
|
|
{
|
Use one active frag and one obstack per frag chain:
* frags.c (frags): Variable deleted.
(frag_alloc): New function.
(frag_grow, frag_more, frag_variant, frag_now_fix, frag_append_1_char): Refer
to frchain_now->frch_obstack instead of frags variable.
(frag_new): Ditto. Verify that frch_last and frag_now match on entry and exit,
and that old frag_now has non-zero type. Replace "know" uses with "assert".
Use frag_alloc instead of mucking with obstack alignment.
* frags.h (frags): Declaration deleted.
* subsegs.h (struct frchain): Add new field frch_frag_now.
* subsegs.c (frchains, dummy_frag, absolute_frchain): New static variables.
(subsegs_begin): Initialize frchains obstack. Under gcc, don't give it any
stricter alignment than frchainS structures need. Do not initialize frags
obstack. Set frag_now to point to dummy_obstack. Initialize absolute_frchain.
(subseg_set_rest): Save and restore frag_now in frch_frag_now field of
frchainS. Don't create new frags on section switch, and use frag_alloc when
creating a new frag chain. For absolute section, set frchain_now to
absolute_frchain. Verify that frch_last and frag_now match on entry and exit.
Initialize per-chain obstack, and under gcc, set required alignment to that
needed by fragS structure.
* write.c (chain_frchains_together_1): Verify fr_type is nonzero.
In one test case of Mike's (i386-linux, over 300K lines of .s code with lots
of stabs records), run time and memory use are reduced by about 1/3.
Might introduce some problems in cases that use the frag obstacks in unusual
ways. Test suite does pass for i386-linux and sparc-solaris targets though.
1995-10-19 05:21:38 +08:00
|
|
|
|
frchain_now = &absolute_frchain;
|
|
|
|
|
frag_now = &zero_address_frag;
|
|
|
|
|
return;
|
1993-09-14 05:32:07 +08:00
|
|
|
|
}
|
Use one active frag and one obstack per frag chain:
* frags.c (frags): Variable deleted.
(frag_alloc): New function.
(frag_grow, frag_more, frag_variant, frag_now_fix, frag_append_1_char): Refer
to frchain_now->frch_obstack instead of frags variable.
(frag_new): Ditto. Verify that frch_last and frag_now match on entry and exit,
and that old frag_now has non-zero type. Replace "know" uses with "assert".
Use frag_alloc instead of mucking with obstack alignment.
* frags.h (frags): Declaration deleted.
* subsegs.h (struct frchain): Add new field frch_frag_now.
* subsegs.c (frchains, dummy_frag, absolute_frchain): New static variables.
(subsegs_begin): Initialize frchains obstack. Under gcc, don't give it any
stricter alignment than frchainS structures need. Do not initialize frags
obstack. Set frag_now to point to dummy_obstack. Initialize absolute_frchain.
(subseg_set_rest): Save and restore frag_now in frch_frag_now field of
frchainS. Don't create new frags on section switch, and use frag_alloc when
creating a new frag chain. For absolute section, set frchain_now to
absolute_frchain. Verify that frch_last and frag_now match on entry and exit.
Initialize per-chain obstack, and under gcc, set required alignment to that
needed by fragS structure.
* write.c (chain_frchains_together_1): Verify fr_type is nonzero.
In one test case of Mike's (i386-linux, over 300K lines of .s code with lots
of stabs records), run time and memory use are reduced by about 1/3.
Might introduce some problems in cases that use the frag obstacks in unusual
ways. Test suite does pass for i386-linux and sparc-solaris targets though.
1995-10-19 05:21:38 +08:00
|
|
|
|
|
|
|
|
|
assert (frchain_now == 0
|
|
|
|
|
|| now_seg == undefined_section
|
|
|
|
|
|| frchain_now->frch_last == frag_now);
|
|
|
|
|
|
1993-09-14 05:32:07 +08:00
|
|
|
|
/*
|
|
|
|
|
* Attempt to find or make a frchain for that sub seg.
|
|
|
|
|
* Crawl along chain of frchainSs, begins @ frchain_root.
|
|
|
|
|
* If we need to make a frchainS, link it into correct
|
|
|
|
|
* position of chain rooted in frchain_root.
|
|
|
|
|
*/
|
|
|
|
|
for (frcP = *(lastPP = &frchain_root);
|
1994-07-15 02:40:36 +08:00
|
|
|
|
frcP && frcP->frch_seg <= seg;
|
1993-09-14 05:32:07 +08:00
|
|
|
|
frcP = *(lastPP = &frcP->frch_next))
|
|
|
|
|
{
|
1994-07-15 02:40:36 +08:00
|
|
|
|
if (frcP->frch_seg == seg
|
1993-09-14 05:32:07 +08:00
|
|
|
|
&& frcP->frch_subseg >= subseg)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* frcP: Address of the 1st frchainS in correct segment with
|
|
|
|
|
* frch_subseg >= subseg.
|
|
|
|
|
* We want to either use this frchainS, or we want
|
|
|
|
|
* to insert a new frchainS just before it.
|
|
|
|
|
*
|
|
|
|
|
* If frcP==NULL, then we are at the end of the chain
|
|
|
|
|
* of frchainS-s. A NULL frcP means we fell off the end
|
|
|
|
|
* of the chain looking for a
|
|
|
|
|
* frch_subseg >= subseg, so we
|
|
|
|
|
* must make a new frchainS.
|
|
|
|
|
*
|
|
|
|
|
* If we ever maintain a pointer to
|
|
|
|
|
* the last frchainS in the chain, we change that pointer
|
|
|
|
|
* ONLY when frcP==NULL.
|
|
|
|
|
*
|
|
|
|
|
* lastPP: Address of the pointer with value frcP;
|
|
|
|
|
* Never NULL.
|
|
|
|
|
* May point to frchain_root.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
if (!frcP
|
1994-07-15 02:40:36 +08:00
|
|
|
|
|| (frcP->frch_seg > seg
|
1993-09-14 05:32:07 +08:00
|
|
|
|
|| frcP->frch_subseg > subseg)) /* Kinky logic only works with 2 segments. */
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* This should be the only code that creates a frchainS.
|
|
|
|
|
*/
|
Use one active frag and one obstack per frag chain:
* frags.c (frags): Variable deleted.
(frag_alloc): New function.
(frag_grow, frag_more, frag_variant, frag_now_fix, frag_append_1_char): Refer
to frchain_now->frch_obstack instead of frags variable.
(frag_new): Ditto. Verify that frch_last and frag_now match on entry and exit,
and that old frag_now has non-zero type. Replace "know" uses with "assert".
Use frag_alloc instead of mucking with obstack alignment.
* frags.h (frags): Declaration deleted.
* subsegs.h (struct frchain): Add new field frch_frag_now.
* subsegs.c (frchains, dummy_frag, absolute_frchain): New static variables.
(subsegs_begin): Initialize frchains obstack. Under gcc, don't give it any
stricter alignment than frchainS structures need. Do not initialize frags
obstack. Set frag_now to point to dummy_obstack. Initialize absolute_frchain.
(subseg_set_rest): Save and restore frag_now in frch_frag_now field of
frchainS. Don't create new frags on section switch, and use frag_alloc when
creating a new frag chain. For absolute section, set frchain_now to
absolute_frchain. Verify that frch_last and frag_now match on entry and exit.
Initialize per-chain obstack, and under gcc, set required alignment to that
needed by fragS structure.
* write.c (chain_frchains_together_1): Verify fr_type is nonzero.
In one test case of Mike's (i386-linux, over 300K lines of .s code with lots
of stabs records), run time and memory use are reduced by about 1/3.
Might introduce some problems in cases that use the frag obstacks in unusual
ways. Test suite does pass for i386-linux and sparc-solaris targets though.
1995-10-19 05:21:38 +08:00
|
|
|
|
extern fragS *frag_alloc ();
|
|
|
|
|
newP = (frchainS *) obstack_alloc (&frchains, sizeof (frchainS));
|
1995-08-09 05:41:30 +08:00
|
|
|
|
newP->frch_subseg = subseg;
|
1993-09-14 05:32:07 +08:00
|
|
|
|
newP->frch_seg = seg;
|
1994-04-13 10:02:48 +08:00
|
|
|
|
#ifdef BFD_ASSEMBLER
|
|
|
|
|
newP->fix_root = NULL;
|
|
|
|
|
newP->fix_tail = NULL;
|
|
|
|
|
#endif
|
1995-08-09 05:41:30 +08:00
|
|
|
|
obstack_begin (&newP->frch_obstack, 5000);
|
Use one active frag and one obstack per frag chain:
* frags.c (frags): Variable deleted.
(frag_alloc): New function.
(frag_grow, frag_more, frag_variant, frag_now_fix, frag_append_1_char): Refer
to frchain_now->frch_obstack instead of frags variable.
(frag_new): Ditto. Verify that frch_last and frag_now match on entry and exit,
and that old frag_now has non-zero type. Replace "know" uses with "assert".
Use frag_alloc instead of mucking with obstack alignment.
* frags.h (frags): Declaration deleted.
* subsegs.h (struct frchain): Add new field frch_frag_now.
* subsegs.c (frchains, dummy_frag, absolute_frchain): New static variables.
(subsegs_begin): Initialize frchains obstack. Under gcc, don't give it any
stricter alignment than frchainS structures need. Do not initialize frags
obstack. Set frag_now to point to dummy_obstack. Initialize absolute_frchain.
(subseg_set_rest): Save and restore frag_now in frch_frag_now field of
frchainS. Don't create new frags on section switch, and use frag_alloc when
creating a new frag chain. For absolute section, set frchain_now to
absolute_frchain. Verify that frch_last and frag_now match on entry and exit.
Initialize per-chain obstack, and under gcc, set required alignment to that
needed by fragS structure.
* write.c (chain_frchains_together_1): Verify fr_type is nonzero.
In one test case of Mike's (i386-linux, over 300K lines of .s code with lots
of stabs records), run time and memory use are reduced by about 1/3.
Might introduce some problems in cases that use the frag obstacks in unusual
ways. Test suite does pass for i386-linux and sparc-solaris targets though.
1995-10-19 05:21:38 +08:00
|
|
|
|
#if __GNUC__ >= 2
|
|
|
|
|
obstack_alignment_mask (&newP->frch_obstack) = __alignof__ (fragS) - 1;
|
|
|
|
|
#endif
|
|
|
|
|
newP->frch_frag_now = frag_alloc (&newP->frch_obstack);
|
|
|
|
|
newP->frch_frag_now->fr_type = rs_fill;
|
|
|
|
|
|
|
|
|
|
newP->frch_root = newP->frch_last = newP->frch_frag_now;
|
1995-08-09 05:41:30 +08:00
|
|
|
|
|
|
|
|
|
*lastPP = newP;
|
|
|
|
|
newP->frch_next = frcP; /* perhaps NULL */
|
|
|
|
|
frcP = newP;
|
1993-09-14 05:32:07 +08:00
|
|
|
|
}
|
|
|
|
|
/*
|
1995-08-09 05:41:30 +08:00
|
|
|
|
* Here with frcP pointing to the frchainS for subseg.
|
1993-09-14 05:32:07 +08:00
|
|
|
|
*/
|
|
|
|
|
frchain_now = frcP;
|
Use one active frag and one obstack per frag chain:
* frags.c (frags): Variable deleted.
(frag_alloc): New function.
(frag_grow, frag_more, frag_variant, frag_now_fix, frag_append_1_char): Refer
to frchain_now->frch_obstack instead of frags variable.
(frag_new): Ditto. Verify that frch_last and frag_now match on entry and exit,
and that old frag_now has non-zero type. Replace "know" uses with "assert".
Use frag_alloc instead of mucking with obstack alignment.
* frags.h (frags): Declaration deleted.
* subsegs.h (struct frchain): Add new field frch_frag_now.
* subsegs.c (frchains, dummy_frag, absolute_frchain): New static variables.
(subsegs_begin): Initialize frchains obstack. Under gcc, don't give it any
stricter alignment than frchainS structures need. Do not initialize frags
obstack. Set frag_now to point to dummy_obstack. Initialize absolute_frchain.
(subseg_set_rest): Save and restore frag_now in frch_frag_now field of
frchainS. Don't create new frags on section switch, and use frag_alloc when
creating a new frag chain. For absolute section, set frchain_now to
absolute_frchain. Verify that frch_last and frag_now match on entry and exit.
Initialize per-chain obstack, and under gcc, set required alignment to that
needed by fragS structure.
* write.c (chain_frchains_together_1): Verify fr_type is nonzero.
In one test case of Mike's (i386-linux, over 300K lines of .s code with lots
of stabs records), run time and memory use are reduced by about 1/3.
Might introduce some problems in cases that use the frag obstacks in unusual
ways. Test suite does pass for i386-linux and sparc-solaris targets though.
1995-10-19 05:21:38 +08:00
|
|
|
|
frag_now = frcP->frch_frag_now;
|
1995-08-09 05:41:30 +08:00
|
|
|
|
|
Use one active frag and one obstack per frag chain:
* frags.c (frags): Variable deleted.
(frag_alloc): New function.
(frag_grow, frag_more, frag_variant, frag_now_fix, frag_append_1_char): Refer
to frchain_now->frch_obstack instead of frags variable.
(frag_new): Ditto. Verify that frch_last and frag_now match on entry and exit,
and that old frag_now has non-zero type. Replace "know" uses with "assert".
Use frag_alloc instead of mucking with obstack alignment.
* frags.h (frags): Declaration deleted.
* subsegs.h (struct frchain): Add new field frch_frag_now.
* subsegs.c (frchains, dummy_frag, absolute_frchain): New static variables.
(subsegs_begin): Initialize frchains obstack. Under gcc, don't give it any
stricter alignment than frchainS structures need. Do not initialize frags
obstack. Set frag_now to point to dummy_obstack. Initialize absolute_frchain.
(subseg_set_rest): Save and restore frag_now in frch_frag_now field of
frchainS. Don't create new frags on section switch, and use frag_alloc when
creating a new frag chain. For absolute section, set frchain_now to
absolute_frchain. Verify that frch_last and frag_now match on entry and exit.
Initialize per-chain obstack, and under gcc, set required alignment to that
needed by fragS structure.
* write.c (chain_frchains_together_1): Verify fr_type is nonzero.
In one test case of Mike's (i386-linux, over 300K lines of .s code with lots
of stabs records), run time and memory use are reduced by about 1/3.
Might introduce some problems in cases that use the frag obstacks in unusual
ways. Test suite does pass for i386-linux and sparc-solaris targets though.
1995-10-19 05:21:38 +08:00
|
|
|
|
assert (frchain_now->frch_last == frag_now);
|
1993-09-14 05:32:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
1991-04-05 02:19:53 +08:00
|
|
|
|
/*
|
1993-09-14 05:32:07 +08:00
|
|
|
|
* subseg_set(segT, subsegT)
|
1991-04-05 02:19:53 +08:00
|
|
|
|
*
|
|
|
|
|
* If you attempt to change to the current subsegment, nothing happens.
|
|
|
|
|
*
|
|
|
|
|
* In: segT, subsegT code for new subsegment.
|
|
|
|
|
* frag_now -> incomplete frag for current subsegment.
|
|
|
|
|
* If frag_now==NULL, then there is no old, incomplete frag, so
|
|
|
|
|
* the old frag is not closed off.
|
|
|
|
|
*
|
|
|
|
|
* Out: now_subseg, now_seg updated.
|
|
|
|
|
* Frchain_now points to the (possibly new) struct frchain for this
|
|
|
|
|
* sub-segment.
|
|
|
|
|
* Frchain_root updated if needed.
|
|
|
|
|
*/
|
|
|
|
|
|
1993-09-14 05:32:07 +08:00
|
|
|
|
#ifndef BFD_ASSEMBLER
|
|
|
|
|
|
|
|
|
|
segT
|
|
|
|
|
subseg_new (segname, subseg)
|
|
|
|
|
const char *segname;
|
|
|
|
|
subsegT subseg;
|
1991-04-05 02:19:53 +08:00
|
|
|
|
{
|
1993-09-14 05:32:07 +08:00
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < (int) SEG_MAXIMUM_ORDINAL; i++)
|
|
|
|
|
{
|
|
|
|
|
const char *s;
|
|
|
|
|
|
|
|
|
|
s = segment_name ((segT) i);
|
|
|
|
|
if (strcmp (segname, s) == 0
|
|
|
|
|
|| (segname[0] == '.'
|
|
|
|
|
&& strcmp (segname + 1, s) == 0))
|
1992-06-05 03:21:58 +08:00
|
|
|
|
{
|
1993-09-14 05:32:07 +08:00
|
|
|
|
subseg_set ((segT) i, subseg);
|
|
|
|
|
return (segT) i;
|
|
|
|
|
}
|
|
|
|
|
#ifdef obj_segment_name
|
|
|
|
|
s = obj_segment_name ((segT) i);
|
|
|
|
|
if (strcmp (segname, s) == 0
|
|
|
|
|
|| (segname[0] == '.'
|
|
|
|
|
&& strcmp (segname + 1, s) == 0))
|
|
|
|
|
{
|
|
|
|
|
subseg_set ((segT) i, subseg);
|
|
|
|
|
return (segT) i;
|
1992-06-05 03:21:58 +08:00
|
|
|
|
}
|
1992-02-13 16:33:54 +08:00
|
|
|
|
#endif
|
1993-09-14 05:32:07 +08:00
|
|
|
|
}
|
1991-04-05 02:19:53 +08:00
|
|
|
|
|
1993-09-14 05:32:07 +08:00
|
|
|
|
#ifdef obj_add_segment
|
|
|
|
|
{
|
|
|
|
|
segT new_seg;
|
|
|
|
|
new_seg = obj_add_segment (segname);
|
|
|
|
|
subseg_set (new_seg, subseg);
|
|
|
|
|
return new_seg;
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
as_bad ("Attempt to switch to nonexistent segment \"%s\"", segname);
|
|
|
|
|
return now_seg;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
subseg_set (seg, subseg) /* begin assembly for a new sub-segment */
|
|
|
|
|
register segT seg; /* SEG_DATA or SEG_TEXT */
|
|
|
|
|
register subsegT subseg;
|
|
|
|
|
{
|
|
|
|
|
#ifndef MANY_SEGMENTS
|
Use one active frag and one obstack per frag chain:
* frags.c (frags): Variable deleted.
(frag_alloc): New function.
(frag_grow, frag_more, frag_variant, frag_now_fix, frag_append_1_char): Refer
to frchain_now->frch_obstack instead of frags variable.
(frag_new): Ditto. Verify that frch_last and frag_now match on entry and exit,
and that old frag_now has non-zero type. Replace "know" uses with "assert".
Use frag_alloc instead of mucking with obstack alignment.
* frags.h (frags): Declaration deleted.
* subsegs.h (struct frchain): Add new field frch_frag_now.
* subsegs.c (frchains, dummy_frag, absolute_frchain): New static variables.
(subsegs_begin): Initialize frchains obstack. Under gcc, don't give it any
stricter alignment than frchainS structures need. Do not initialize frags
obstack. Set frag_now to point to dummy_obstack. Initialize absolute_frchain.
(subseg_set_rest): Save and restore frag_now in frch_frag_now field of
frchainS. Don't create new frags on section switch, and use frag_alloc when
creating a new frag chain. For absolute section, set frchain_now to
absolute_frchain. Verify that frch_last and frag_now match on entry and exit.
Initialize per-chain obstack, and under gcc, set required alignment to that
needed by fragS structure.
* write.c (chain_frchains_together_1): Verify fr_type is nonzero.
In one test case of Mike's (i386-linux, over 300K lines of .s code with lots
of stabs records), run time and memory use are reduced by about 1/3.
Might introduce some problems in cases that use the frag obstacks in unusual
ways. Test suite does pass for i386-linux and sparc-solaris targets though.
1995-10-19 05:21:38 +08:00
|
|
|
|
know (seg == SEG_DATA
|
|
|
|
|
|| seg == SEG_TEXT
|
|
|
|
|
|| seg == SEG_BSS
|
|
|
|
|
|| seg == SEG_ABSOLUTE);
|
1993-09-14 05:32:07 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (seg != now_seg || subseg != now_subseg)
|
|
|
|
|
{ /* we just changed sub-segments */
|
|
|
|
|
subseg_set_rest (seg, subseg);
|
|
|
|
|
}
|
1995-08-09 05:41:30 +08:00
|
|
|
|
mri_common_symbol = NULL;
|
1993-09-14 05:32:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else /* BFD_ASSEMBLER */
|
|
|
|
|
|
|
|
|
|
segT
|
1994-01-14 04:16:44 +08:00
|
|
|
|
subseg_get (segname, force_new)
|
1993-09-14 05:32:07 +08:00
|
|
|
|
const char *segname;
|
1994-01-14 04:16:44 +08:00
|
|
|
|
int force_new;
|
1993-09-14 05:32:07 +08:00
|
|
|
|
{
|
|
|
|
|
segT secptr;
|
|
|
|
|
segment_info_type *seginfo;
|
|
|
|
|
const char *now_seg_name = (now_seg
|
|
|
|
|
? bfd_get_section_name (stdoutput, now_seg)
|
|
|
|
|
: 0);
|
|
|
|
|
|
1994-01-14 04:16:44 +08:00
|
|
|
|
if (!force_new
|
|
|
|
|
&& now_seg_name
|
1993-09-14 05:32:07 +08:00
|
|
|
|
&& (now_seg_name == segname
|
1994-01-14 04:16:44 +08:00
|
|
|
|
|| !strcmp (now_seg_name, segname)))
|
1993-09-14 05:32:07 +08:00
|
|
|
|
return now_seg;
|
|
|
|
|
|
1994-01-14 04:16:44 +08:00
|
|
|
|
if (!force_new)
|
|
|
|
|
secptr = bfd_make_section_old_way (stdoutput, segname);
|
|
|
|
|
else
|
|
|
|
|
secptr = bfd_make_section_anyway (stdoutput, segname);
|
|
|
|
|
|
1993-09-14 05:32:07 +08:00
|
|
|
|
seginfo = seg_info (secptr);
|
|
|
|
|
if (! seginfo)
|
|
|
|
|
{
|
1994-06-22 00:45:09 +08:00
|
|
|
|
/* Check whether output_section is set first because secptr may
|
|
|
|
|
be bfd_abs_section_ptr. */
|
|
|
|
|
if (secptr->output_section != secptr)
|
|
|
|
|
secptr->output_section = secptr;
|
1993-09-14 05:32:07 +08:00
|
|
|
|
seginfo = (segment_info_type *) xmalloc (sizeof (*seginfo));
|
Updated some copyrights, cleaned up some header-file comments, and:
* symbols.c (symbol_create): New function, most of the guts of the old
symbol_new function.
(symbol_new): Now just checks symbol_table_frozen, calls symbol_create, and
enters the symbol into the symbol table.
* subsegs.c (section_symbol): If EMIT_SECTION_SYMBOLS is not true, and the
symbol table is frozen, call symbol_create instead of symbol_new.
* symbols.h (symbol_create, symbol_table_frozen): Declare.
* symbols.c (symbol_clear_list_pointers): Always a function now.
* struc-symbol.h (symbol_clear_list_pointers): Deleted macro version.
* symbols.c (debug_verify_symchain): New macro, defined to be
verify_symbol_chain or a cast to void, depending on DEBUG_SYMS.
(many functions): Invoke debug_verify_symchain unconditionally.
1994-07-13 09:48:15 +08:00
|
|
|
|
memset ((PTR) seginfo, 0, sizeof (*seginfo));
|
1994-04-13 10:02:48 +08:00
|
|
|
|
seginfo->fix_root = NULL;
|
1994-06-22 00:45:09 +08:00
|
|
|
|
seginfo->fix_tail = NULL;
|
1993-09-14 05:32:07 +08:00
|
|
|
|
seginfo->bfd_section = secptr;
|
1994-06-22 00:45:09 +08:00
|
|
|
|
if (secptr == bfd_abs_section_ptr)
|
|
|
|
|
abs_seg_info = seginfo;
|
|
|
|
|
else if (secptr == bfd_und_section_ptr)
|
|
|
|
|
und_seg_info = seginfo;
|
|
|
|
|
else
|
|
|
|
|
bfd_set_section_userdata (stdoutput, secptr, (PTR) seginfo);
|
1994-04-13 10:02:48 +08:00
|
|
|
|
seginfo->frchainP = NULL;
|
|
|
|
|
seginfo->lineno_list_head = seginfo->lineno_list_tail = NULL;
|
|
|
|
|
seginfo->sym = NULL;
|
|
|
|
|
seginfo->dot = NULL;
|
1993-09-14 05:32:07 +08:00
|
|
|
|
}
|
1994-01-14 04:16:44 +08:00
|
|
|
|
return secptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
segT
|
|
|
|
|
subseg_new (segname, subseg)
|
|
|
|
|
const char *segname;
|
|
|
|
|
subsegT subseg;
|
|
|
|
|
{
|
|
|
|
|
segT secptr;
|
|
|
|
|
segment_info_type *seginfo;
|
|
|
|
|
|
|
|
|
|
secptr = subseg_get (segname, 0);
|
|
|
|
|
subseg_set_rest (secptr, subseg);
|
|
|
|
|
seginfo = seg_info (secptr);
|
|
|
|
|
if (! seginfo->frchainP)
|
|
|
|
|
seginfo->frchainP = frchain_now;
|
|
|
|
|
return secptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Like subseg_new, except a new section is always created, even if
|
|
|
|
|
a section with that name already exists. */
|
|
|
|
|
segT
|
|
|
|
|
subseg_force_new (segname, subseg)
|
|
|
|
|
const char *segname;
|
|
|
|
|
subsegT subseg;
|
|
|
|
|
{
|
|
|
|
|
segT secptr;
|
|
|
|
|
segment_info_type *seginfo;
|
|
|
|
|
|
|
|
|
|
secptr = subseg_get (segname, 1);
|
|
|
|
|
subseg_set_rest (secptr, subseg);
|
|
|
|
|
seginfo = seg_info (secptr);
|
|
|
|
|
if (! seginfo->frchainP)
|
|
|
|
|
seginfo->frchainP = frchain_now;
|
1993-09-14 05:32:07 +08:00
|
|
|
|
return secptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
subseg_set (secptr, subseg)
|
|
|
|
|
segT secptr;
|
|
|
|
|
subsegT subseg;
|
|
|
|
|
{
|
|
|
|
|
if (! (secptr == now_seg && subseg == now_subseg))
|
|
|
|
|
subseg_set_rest (secptr, subseg);
|
1995-08-09 05:41:30 +08:00
|
|
|
|
mri_common_symbol = NULL;
|
1993-09-14 05:32:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
1994-04-13 10:02:48 +08:00
|
|
|
|
#ifndef obj_sec_sym_ok_for_reloc
|
|
|
|
|
#define obj_sec_sym_ok_for_reloc(SEC) 0
|
|
|
|
|
#endif
|
|
|
|
|
|
1994-06-22 00:45:09 +08:00
|
|
|
|
/* Get the gas information we are storing for a section. */
|
|
|
|
|
|
|
|
|
|
segment_info_type *
|
|
|
|
|
seg_info (sec)
|
|
|
|
|
segT sec;
|
|
|
|
|
{
|
|
|
|
|
if (sec == bfd_abs_section_ptr)
|
|
|
|
|
return abs_seg_info;
|
|
|
|
|
else if (sec == bfd_und_section_ptr)
|
|
|
|
|
return und_seg_info;
|
|
|
|
|
else
|
|
|
|
|
return (segment_info_type *) bfd_get_section_userdata (stdoutput, sec);
|
|
|
|
|
}
|
|
|
|
|
|
1994-01-14 04:16:44 +08:00
|
|
|
|
symbolS *
|
|
|
|
|
section_symbol (sec)
|
|
|
|
|
segT sec;
|
|
|
|
|
{
|
|
|
|
|
segment_info_type *seginfo = seg_info (sec);
|
1994-04-13 10:02:48 +08:00
|
|
|
|
symbolS *s;
|
1994-01-14 04:16:44 +08:00
|
|
|
|
|
|
|
|
|
if (seginfo == 0)
|
|
|
|
|
abort ();
|
|
|
|
|
if (seginfo->sym)
|
|
|
|
|
return seginfo->sym;
|
1994-04-13 10:02:48 +08:00
|
|
|
|
s = symbol_find (sec->name);
|
|
|
|
|
if (!s)
|
1994-01-14 04:16:44 +08:00
|
|
|
|
{
|
Updated some copyrights, cleaned up some header-file comments, and:
* symbols.c (symbol_create): New function, most of the guts of the old
symbol_new function.
(symbol_new): Now just checks symbol_table_frozen, calls symbol_create, and
enters the symbol into the symbol table.
* subsegs.c (section_symbol): If EMIT_SECTION_SYMBOLS is not true, and the
symbol table is frozen, call symbol_create instead of symbol_new.
* symbols.h (symbol_create, symbol_table_frozen): Declare.
* symbols.c (symbol_clear_list_pointers): Always a function now.
* struc-symbol.h (symbol_clear_list_pointers): Deleted macro version.
* symbols.c (debug_verify_symchain): New macro, defined to be
verify_symbol_chain or a cast to void, depending on DEBUG_SYMS.
(many functions): Invoke debug_verify_symchain unconditionally.
1994-07-13 09:48:15 +08:00
|
|
|
|
#ifndef EMIT_SECTION_SYMBOLS
|
|
|
|
|
#define EMIT_SECTION_SYMBOLS 1
|
|
|
|
|
#endif
|
|
|
|
|
|
1995-08-09 05:41:30 +08:00
|
|
|
|
if (! EMIT_SECTION_SYMBOLS
|
Updated some copyrights, cleaned up some header-file comments, and:
* symbols.c (symbol_create): New function, most of the guts of the old
symbol_new function.
(symbol_new): Now just checks symbol_table_frozen, calls symbol_create, and
enters the symbol into the symbol table.
* subsegs.c (section_symbol): If EMIT_SECTION_SYMBOLS is not true, and the
symbol table is frozen, call symbol_create instead of symbol_new.
* symbols.h (symbol_create, symbol_table_frozen): Declare.
* symbols.c (symbol_clear_list_pointers): Always a function now.
* struc-symbol.h (symbol_clear_list_pointers): Deleted macro version.
* symbols.c (debug_verify_symchain): New macro, defined to be
verify_symbol_chain or a cast to void, depending on DEBUG_SYMS.
(many functions): Invoke debug_verify_symchain unconditionally.
1994-07-13 09:48:15 +08:00
|
|
|
|
#ifdef BFD_ASSEMBLER
|
|
|
|
|
&& symbol_table_frozen
|
|
|
|
|
#endif
|
|
|
|
|
)
|
1995-08-09 05:41:30 +08:00
|
|
|
|
/* Here we know it won't be going into the symbol table. */
|
Updated some copyrights, cleaned up some header-file comments, and:
* symbols.c (symbol_create): New function, most of the guts of the old
symbol_new function.
(symbol_new): Now just checks symbol_table_frozen, calls symbol_create, and
enters the symbol into the symbol table.
* subsegs.c (section_symbol): If EMIT_SECTION_SYMBOLS is not true, and the
symbol table is frozen, call symbol_create instead of symbol_new.
* symbols.h (symbol_create, symbol_table_frozen): Declare.
* symbols.c (symbol_clear_list_pointers): Always a function now.
* struc-symbol.h (symbol_clear_list_pointers): Deleted macro version.
* symbols.c (debug_verify_symchain): New macro, defined to be
verify_symbol_chain or a cast to void, depending on DEBUG_SYMS.
(many functions): Invoke debug_verify_symchain unconditionally.
1994-07-13 09:48:15 +08:00
|
|
|
|
s = symbol_create (sec->name, sec, 0, &zero_address_frag);
|
1995-08-09 05:41:30 +08:00
|
|
|
|
else
|
|
|
|
|
s = symbol_new (sec->name, sec, 0, &zero_address_frag);
|
1994-04-13 10:02:48 +08:00
|
|
|
|
S_CLEAR_EXTERNAL (s);
|
|
|
|
|
|
|
|
|
|
/* Use the BFD section symbol, if possible. */
|
|
|
|
|
if (obj_sec_sym_ok_for_reloc (sec))
|
|
|
|
|
s->bsym = sec->symbol;
|
1994-01-14 04:16:44 +08:00
|
|
|
|
}
|
1994-04-13 10:02:48 +08:00
|
|
|
|
seginfo->sym = s;
|
|
|
|
|
return s;
|
1994-01-14 04:16:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
1993-09-14 05:32:07 +08:00
|
|
|
|
#endif /* BFD_ASSEMBLER */
|
1991-04-05 02:19:53 +08:00
|
|
|
|
|
1992-02-13 17:13:54 +08:00
|
|
|
|
/* end of subsegs.c */
|