aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2001-08-09 15:33:35 -0700
committerRichard Henderson <rth@gcc.gnu.org>2001-08-09 15:33:35 -0700
commit2cc07db4b089b8b3df05261f1d7acbc96d2e720a (patch)
treeddb2d5519f49bc33648c25225b8b8ba84df590b9 /gcc
parentef8d8b8922a034dfac5cff9d5fa781dc57c49ed0 (diff)
downloadgcc-2cc07db4b089b8b3df05261f1d7acbc96d2e720a.zip
gcc-2cc07db4b089b8b3df05261f1d7acbc96d2e720a.tar.gz
gcc-2cc07db4b089b8b3df05261f1d7acbc96d2e720a.tar.bz2
Move constructor/destructor handling into target hooks.
From-SVN: r44747
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog160
-rw-r--r--gcc/Makefile.in20
-rw-r--r--gcc/c-decl.c20
-rw-r--r--gcc/ch/ChangeLog5
-rw-r--r--gcc/ch/grant.c10
-rw-r--r--gcc/config.gcc19
-rw-r--r--gcc/config/1750a/1750a.h8
-rw-r--r--gcc/config/a29k/a29k.c2
-rw-r--r--gcc/config/a29k/udi.h94
-rw-r--r--gcc/config/alpha/alpha-interix.h48
-rw-r--r--gcc/config/alpha/alpha.c27
-rw-r--r--gcc/config/alpha/elf.h47
-rw-r--r--gcc/config/alpha/vms.h44
-rw-r--r--gcc/config/arc/arc.h22
-rw-r--r--gcc/config/arm/aof.h58
-rw-r--r--gcc/config/arm/coff.h52
-rw-r--r--gcc/config/arm/elf.h84
-rw-r--r--gcc/config/c4x/c4x.c4
-rw-r--r--gcc/config/c4x/c4x.h87
-rw-r--r--gcc/config/clipper/clipper.c22
-rw-r--r--gcc/config/clipper/clix.h25
-rw-r--r--gcc/config/d30v/d30v.h23
-rw-r--r--gcc/config/darwin-protos.h2
-rw-r--r--gcc/config/darwin.c30
-rw-r--r--gcc/config/darwin.h29
-rw-r--r--gcc/config/elfos.h73
-rw-r--r--gcc/config/h8300/h8300.h43
-rw-r--r--gcc/config/i386/aix386.h9
-rw-r--r--gcc/config/i386/aix386ng.h4
-rw-r--r--gcc/config/i386/cygwin.h46
-rw-r--r--gcc/config/i386/djgpp.h54
-rw-r--r--gcc/config/i386/i386-coff.h62
-rw-r--r--gcc/config/i386/i386-interix.h71
-rw-r--r--gcc/config/i386/i386.c28
-rw-r--r--gcc/config/i386/sco5.h63
-rw-r--r--gcc/config/i386/svr3gas.h94
-rw-r--r--gcc/config/i386/sysv3.h13
-rw-r--r--gcc/config/i386/vsta.h48
-rw-r--r--gcc/config/i386/win32.h46
-rw-r--r--gcc/config/i960/i960-coff.h55
-rw-r--r--gcc/config/ia64/sysv4.h44
-rw-r--r--gcc/config/lynx.h26
-rw-r--r--gcc/config/m68hc11/m68hc11.c20
-rw-r--r--gcc/config/m68hc11/m68hc11.h30
-rw-r--r--gcc/config/m68k/auxgas.h2
-rw-r--r--gcc/config/m68k/coff.h60
-rw-r--r--gcc/config/m68k/dpx2.h34
-rw-r--r--gcc/config/m68k/dpx2g.h50
-rw-r--r--gcc/config/m68k/m68k.c20
-rw-r--r--gcc/config/m68k/mot3300.h55
-rw-r--r--gcc/config/m68k/tower-as.h17
-rw-r--r--gcc/config/m88k/m88k.c46
-rw-r--r--gcc/config/m88k/m88k.h9
-rw-r--r--gcc/config/m88k/sysv3.h35
-rw-r--r--gcc/config/mcore/mcore-pe.h30
-rw-r--r--gcc/config/mcore/mcore.h30
-rw-r--r--gcc/config/mips/elf.h69
-rw-r--r--gcc/config/mips/elf64.h70
-rw-r--r--gcc/config/mips/iris6.h77
-rw-r--r--gcc/config/mips/mips.h13
-rw-r--r--gcc/config/mips/rtems64.h15
-rw-r--r--gcc/config/mips/vxworks.h17
-rw-r--r--gcc/config/netware.h50
-rw-r--r--gcc/config/nextstep.c21
-rw-r--r--gcc/config/nextstep.h23
-rw-r--r--gcc/config/nextstep21.h4
-rw-r--r--gcc/config/pa/pa64-hpux.h70
-rw-r--r--gcc/config/psos.h71
-rw-r--r--gcc/config/rs6000/aix.h4
-rw-r--r--gcc/config/rs6000/lynx.h4
-rw-r--r--gcc/config/rs6000/sysv4.h51
-rw-r--r--gcc/config/sh/elf.h4
-rw-r--r--gcc/config/sh/sh.h47
-rw-r--r--gcc/config/sparc/linux64.h28
-rw-r--r--gcc/config/sparc/litecoff.h57
-rw-r--r--gcc/config/sparc/sol2-sld-64.h28
-rw-r--r--gcc/config/svr3.h42
-rw-r--r--gcc/config/vax/vax.c35
-rw-r--r--gcc/config/vax/vms.h23
-rwxr-xr-xgcc/configure51
-rw-r--r--gcc/configure.in19
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl2.c18
-rw-r--r--gcc/crtstuff.c81
-rw-r--r--gcc/defaults.h6
-rw-r--r--gcc/doc/tm.texi178
-rw-r--r--gcc/java/ChangeLog6
-rw-r--r--gcc/java/Make-lang.in2
-rw-r--r--gcc/java/class.c36
-rw-r--r--gcc/objc/Make-lang.in2
-rw-r--r--gcc/objc/objc-act.c66
-rw-r--r--gcc/output.h19
-rw-r--r--gcc/profile.c13
-rw-r--r--gcc/target-def.h39
-rw-r--r--gcc/target.h10
-rw-r--r--gcc/varasm.c133
96 files changed, 910 insertions, 2756 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 92b4352..2ebe5cd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,165 @@
2001-08-09 Richard Henderson <rth@redhat.com>
+ * Makefile.in (MAYBE_USE_COLLECT2): Remove; purge all uses.
+ (USE_COLLECT2): Remove duplicate definition.
+ * config.gcc (a29k-udi, a29k-wrs-vxworks) [tm_file]: Remove a29k/udi.h.
+ (use_collect2): Remove dead code.
+ * configure.in (use_collect2): Remove will_use_collect2 and
+ maybe_use_collect2; add USE_COLLECT2 to host_xm_defines and xm_defines.
+ * configure: Rebuild.
+
+ * target.h (targetm.asm_out.constructor): New.
+ (targetm.asm_out.destructor, targetm.have_ctors_dtors): New.
+ * target-def.h (TARGET_ASM_CONSTRUCTOR): New.
+ (TARGET_ASM_DESTRUCTOR, TARGET_HAVE_CTORS_DTORS): New.
+ * varasm.c (in_ctors, in_dtors): New.
+ (assemble_constructor, assemble_destructor): Remove.
+ (default_stabs_asm_out_destructor): New.
+ (default_named_section_asm_out_destructor): New.
+ (dtors_section, default_dtor_section_asm_out_destructor): New.
+ (default_stabs_asm_out_constructor): New.
+ (default_named_section_asm_out_constructor): New.
+ (ctors_section, default_ctor_section_asm_out_constructor): New.
+ * output.h: Update declarations.
+ * c-decl.c (c_expand_body): Use target hooks instead of
+ assemble_constructor and assemble_destructor.
+ * profile.c (output_func_start_profiler): Likewise.
+ * objc/objc-act.c (finish_objc): Likewise.
+ (build_module_descriptor): Tidy. Set TREE_PUBLIC properly
+ for the constructor.
+ * objc/Make-lang.in (objc-act.o): Depend on TARGET_H.
+
+ * crtstuff.c (CTORS_SECTION_ASM_OP): Don't define.
+ (DTORS_SECTION_ASM_OP): Likewise.
+ (__CTOR_LIST__): Use attribute section when possible.
+ (__DTOR_LIST__, __CTOR_END__, __DTOR_END__): Likewise.
+
+ * defaults.h (EH_FRAME_SECTION_NAME): Don't depend on
+ ASM_OUTPUT_CONSTRUCTOR.
+
+ * config/darwin.c (machopic_asm_out_constructor): New.
+ (machopic_asm_out_destructor): New.
+ * config/darwin-protos.h: Update declarations.
+ * config/darwin.h (ASM_OUTPUT_CONSTRUCTOR): Remove.
+ (ASM_OUTPUT_DESTRUCTOR): Remove.
+ (TARGET_ASM_CONSTRUCTOR, TARGET_ASM_DESTRUCTOR): New.
+ * config/nextstep.c (nextstep_asm_out_constructor): New.
+ (nextstep_asm_out_destructor): New.
+ * config/nextstep.h (ASM_OUTPUT_CONSTRUCTOR): Remove.
+ (ASM_OUTPUT_DESTRUCTOR): Remove.
+ (TARGET_ASM_CONSTRUCTOR, TARGET_ASM_DESTRUCTOR): New.
+ * config/nextstep21.h: Undef TARGET_ASM_*STRUCTOR instead of
+ ASM_OUTPUT_*STRUCTOR.
+ * config/i386/aix386ng.h: Likewise.
+
+ * config/elfos.h (CTORS_SECTION_ASM_OP, DTORS_SECTION_ASM_OP): Remove.
+ (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): No ctors/dtors.
+ (CTORS_SECTION_FUNCTION, DTORS_SECTION_FUNCTION): Remove.
+ (ASM_OUTPUT_CONSTRUCTOR, ASM_OUTPUT_DESTRUCTOR): Remove.
+ * config/lynx.h: Likewise.
+ * config/netware.h: Likewise.
+ * config/psos.h: Likewise.
+ * config/alpha/alpha-interix.h: Likewise.
+ * config/alpha/elf.h: Likewise.
+ * config/arc/arc.h: Likewise.
+ * config/arm/aof.h: Likewise.
+ * config/arm/coff.h: Likewise.
+ * config/arm/elf.h: Likewise.
+ * config/c4x/c4x.h: Likewise.
+ * config/h8300/h8300.h: Likewise.
+ * config/i386/cygwin.h: Likewise.
+ * config/i386/djgpp.h: Likewise.
+ * config/i386/i386-coff.h: Likewise.
+ * config/i386/i386-interix.h: Likewise.
+ * config/i386/sco5.h: Likewise.
+ * config/i386/vsta.h: Likewise.
+ * config/i386/win32.h: Likewise.
+ * config/i960/i960-coff.h: Likewise.
+ * config/ia64/sysv4.h: Likewise.
+ * config/m68hc11/m68hc11.h: Likewise.
+ * config/m68k/coff.h: Likewise.
+ * config/m68k/mot3300.h: Likewise.
+ * config/m88k/m88k.h: Likewise.
+ * config/mcore/mcore-pe.h: Likewise.
+ * config/mcore/mcore.h: Likewise.
+ * config/mips/elf.h: Likewise.
+ * config/mips/elf64.h: Likewise.
+ * config/mips/iris6.h: Likewise.
+ * config/pa/pa64-hpux.h: Likewise.
+ * config/rs6000/sysv4.h: Likewise.
+ * config/sh/sh.h: Likewise.
+ * config/sparc/litecoff.h: Likewise.
+
+ * config/svr3.h (CTORS_SECTION_ASM_OP): Remove.
+ (CTORS_SECTION_FUNCTION, DTORS_SECTION_FUNCTION): Remove.
+ (ASM_OUTPUT_CONSTRUCTOR, ASM_OUTPUT_DESTRUCTOR): Remove.
+ * config/1750a/1750a.h (ASM_OUTPUT_CONSTRUCTOR): Remove.
+ (ASM_OUTPUT_DESTRUCTOR): Remove.
+ * config/a29k/a29k.c: Move include of tree.h.
+ * config/a29k/udi.h: Delete file.
+ * config/alpha/alpha.c (vms_asm_out_constructor): New.
+ (vms_asm_out_destructor): New.
+ * config/alpha/vms.h (EXTRA_SECTIONS): No ctors/dtors.
+ (EXTRA_SECTION_FUNCTIONS): Likewise.
+ (ASM_OUTPUT_CONSTRUCTOR, ASM_OUTPUT_DESTRUCTOR): Remove.
+ (TARGET_ASM_CONSTRUCTOR, TARGET_ASM_DESTRUCTOR): New.
+ * config/c4x/c4x.c: Move include of tree.h.
+ * config/clipper/clipper.c (clix_asm_out_constructor): New.
+ (clix_asm_out_destructor): New.
+ * config/clipper/clix.h (ASM_OUTPUT_CONSTRUCTOR): Remove.
+ (ASM_OUTPUT_DESTRUCTOR): Remove.
+ (TARGET_ASM_CONSTRUCTOR, TARGET_ASM_DESTRUCTOR): New.
+ * config/i386/aix386.h (ASM_OUTPUT_CONSTRUCTOR): Remove.
+ (TARGET_ASM_CONSTRUCTOR): New.
+ * config/i386/i386.c (ix86_svr3_asm_out_constructor): New.
+ (sco_asm_out_constructor): New.
+ * config/i386/sco5.h (TARGET_ASM_CONSTRUCTOR): New.
+ * config/i386/svr3gas.h: Remove stack grows up code.
+ Remove code duplicated from i386/sysv3.h.
+ (TARGET_ASM_CONSTRUCTOR): New.
+ (ASM_OUTPUT_CONSTRUCTOR, ASM_OUTPUT_DESTRUCTOR): Remove.
+ (DTORS_SECTION_FUNCTION, CTORS_SECTION_FUNCTION): Remove.
+ * config/i386/sysv3.h (ASM_OUTPUT_CONSTRUCTOR): Remove.
+ (TARGET_ASM_CONSTRUCTOR): New.
+ * config/m68hc11/m68hc11.c (m68hc11_asm_out_constructor): New.
+ (m68hc11_asm_out_destructor): New.
+ * config/m68hc11/m68hc11.h (TARGET_ASM_CONSTRUCTOR): New.
+ (TARGET_ASM_DESTRUCTOR): New.
+ * config/m68k/auxgas.h: Don't undef ASM_OUTPUT_*STRUCTOR.
+ * config/m68k/dpx2.h: Properly undef all the bits inherited from
+ config/svr3.h pertaining to section manipulation.
+ * config/m68k/dpx2g.h: Remove #if 0 code.
+ * config/m68k/m68k.c (m68k_svr3_asm_out_constructor): New.
+ * config/m68k/tower-as.h (ASM_OUTPUT_SOURCE_LINE): Fix typo.
+ (ASM_OUTPUT_CONSTRUCTOR): Remove.
+ (TARGET_ASM_CONSTRUCTOR): New.
+ * config/m88k/m88k.c (m88k_layout_frame): Don't use assign_stack_local.
+ (m88k_svr3_asm_out_constructor): New.
+ (m88k_svr3_asm_out_destructor): New.
+ * config/m88k/sysv3.h (ASM_OUTPUT_CONSTRUCTOR): Remove.
+ (ASM_OUTPUT_DESTRUCTOR): Remove.
+ (TARGET_ASM_CONSTRUCTOR, TARGET_ASM_DESTRUCTOR): New.
+ * config/mips/mips.h: Remove #if 0 ASM_OUTPUT_*STRUCTOR code.
+ * config/rs6000/aix.h: Likewise.
+ * config/mips/rtems64.h: Don't undef removed constructor related bits.
+ * config/mips/vxworks.h: Likewise.
+ * config/rs6000/lynx.h: Likewise.
+ * config/sh/elf.h: Likewise.
+ * config/rs6000/sysv4.h (CTORS_SECTION_ASM_OP): New.
+ (DTORS_SECTION_ASM_OP): New.
+ * config/sparc/linux64.h (ASM_OUTPUT_CONSTRUCTOR): Remove.
+ (ASM_OUTPUT_DESTRUCTOR): Remove.
+ * config/sparc/sol2-sld-64.h: Likewise.
+ * config/vax/vax.c (vms_asm_out_constructor): New.
+ (vms_asm_out_destructor): New.
+ * config/vax/vms.h (ASM_OUTPUT_CONSTRUCTOR): Remove.
+ (ASM_OUTPUT_DESTRUCTOR): Remove.
+ (TARGET_ASM_CONSTRUCTOR, TARGET_ASM_DESTRUCTOR): New.
+
+ * doc/tm.texi (@node Initialization): Update.
+
+2001-08-09 Richard Henderson <rth@redhat.com>
+
* config/alpha/crtbegin.asm (__JCR_LIST__): New.
(__do_global_dtors_aux): Use gp-relative static data to avoid
one dynamic relocation.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index bfa3a84..fb490f9 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -409,12 +409,6 @@ EXTRA_GCC_OBJS =@host_extra_gcc_objs@
# Often this is edited directly by `configure'.
EXTRA_HEADERS =@extra_headers_list@
-# Set this to `collect2' to enable use of collect2.
-USE_COLLECT2 = @will_use_collect2@
-# If we might be using collect2, then this variable will be set to
-# -DUSE_COLLECT2. toplev.c, collect2.c and libgcc2.c all need to
-# know if we may be using collect2.
-MAYBE_USE_COLLECT2 = @maybe_use_collect2@
# It is convenient for configure to add the assignment at the beginning,
# so don't override it here.
USE_COLLECT2 = collect2$(exeext)
@@ -1058,7 +1052,7 @@ libgcc.a: $(LIBGCC_DEPS)
RANLIB_TEST_FOR_TARGET="$(RANLIB_TEST_FOR_TARGET)" \
NM_FOR_TARGET="$(NM_FOR_TARGET)" AWK="$(AWK)" \
LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)" \
- INCLUDES="$(INCLUDES)" MAYBE_USE_COLLECT2="$(MAYBE_USE_COLLECT2)" \
+ INCLUDES="$(INCLUDES)" \
CONFIG_H="$(TCONFIG_H)" MACHMODE_H="$(MACHMODE_H)" \
LIB1ASMSRC='$(LIB1ASMSRC)' \
MAKEOVERRIDES= \
@@ -1092,7 +1086,7 @@ stmp-multilib: $(LIBGCC_DEPS)
RANLIB_TEST_FOR_TARGET="$(RANLIB_TEST_FOR_TARGET)" \
NM_FOR_TARGET="$(NM_FOR_TARGET)" AWK="$(AWK)" \
LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)" \
- INCLUDES="$(INCLUDES)" MAYBE_USE_COLLECT2="$(MAYBE_USE_COLLECT2)" \
+ INCLUDES="$(INCLUDES)" \
CONFIG_H="$(CONFIG_H)" MACHMODE_H="$(MACHMODE_H)" \
LIB1ASMSRC='$(LIB1ASMSRC)' \
MAKEOVERRIDES= \
@@ -1203,7 +1197,7 @@ collect2$(exeext): $(COLLECT2_OBJS) $(LIBDEPS)
collect2.o : collect2.c $(CONFIG_H) $(SYSTEM_H) gstab.h intl.h \
$(OBSTACK_H) $(DEMANGLE_H) collect2.h version.h
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
- -DTARGET_MACHINE=\"$(target_alias)\" $(MAYBE_USE_COLLECT2) \
+ -DTARGET_MACHINE=\"$(target_alias)\" \
-c $(srcdir)/collect2.c
tlink.o: tlink.c $(DEMANGLE_H) hash.h $(CONFIG_H) $(SYSTEM_H) collect2.h intl.h
@@ -1361,7 +1355,7 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) function.h \
dwarf2out.h sdbout.h dbxout.h $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) \
graph.h $(LOOP_H) except.h $(REGS_H) $(TIMEVAR_H) $(lang_options_files) \
ssa.h $(PARAMS_H) $(TM_P_H) reload.h dwarf2asm.h $(TARGET_H)
- $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(MAYBE_USE_COLLECT2) \
+ $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
-DTARGET_NAME=\"$(target_alias)\" \
-c $(srcdir)/toplev.c
main.o : main.c toplev.h
@@ -1476,7 +1470,7 @@ conflict.o : conflict.c $(CONFIG_H) $(SYSTEM_H) $(OBSTACK_H) $(HASHTAB_H) \
$(RTL_H) hard-reg-set.h $(BASIC_BLOCK_H)
profile.o : profile.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h \
insn-config.h output.h $(REGS_H) $(EXPR_H) function.h \
- gcov-io.h toplev.h $(GGC_H) hard-reg-set.h $(BASIC_BLOCK_H)
+ gcov-io.h toplev.h $(GGC_H) hard-reg-set.h $(BASIC_BLOCK_H) $(TARGET_H)
loop.o : loop.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) flags.h $(LOOP_H) insn-config.h \
$(REGS_H) hard-reg-set.h $(RECOG_H) $(EXPR_H) real.h $(PREDICT_H) \
$(BASIC_BLOCK_H) function.h toplev.h varray.h except.h cselib.h $(TM_P_H)
@@ -2679,7 +2673,7 @@ install-libgcc: libgcc.mk libgcc.a installdirs
RANLIB_TEST_FOR_TARGET="$(RANLIB_TEST_FOR_TARGET)" \
NM_FOR_TARGET="$(NM_FOR_TARGET)" AWK="$(AWK)" \
LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)" \
- INCLUDES="$(INCLUDES)" MAYBE_USE_COLLECT2="$(MAYBE_USE_COLLECT2)" \
+ INCLUDES="$(INCLUDES)" \
CONFIG_H="$(TCONFIG_H)" MACHMODE_H="$(MACHMODE_H)" \
LIB1ASMSRC='$(LIB1ASMSRC)' \
MAKEOVERRIDES= \
@@ -2705,7 +2699,7 @@ install-multilib: stmp-multilib installdirs
RANLIB_TEST_FOR_TARGET="$(RANLIB_TEST_FOR_TARGET)" \
NM_FOR_TARGET="$(NM_FOR_TARGET)" AWK="$(AWK)" \
LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)" \
- INCLUDES="$(INCLUDES)" MAYBE_USE_COLLECT2="$(MAYBE_USE_COLLECT2)" \
+ INCLUDES="$(INCLUDES)" \
CONFIG_H="$(CONFIG_H)" MACHMODE_H="$(MACHMODE_H)" \
LIB1ASMSRC='$(LIB1ASMSRC)' \
MAKEOVERRIDES= \
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 6c5056f..490d96c 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -6776,24 +6776,20 @@ c_expand_body (fndecl, nested_p)
if (DECL_STATIC_CONSTRUCTOR (fndecl))
{
-#ifndef ASM_OUTPUT_CONSTRUCTOR
- if (! flag_gnu_linker)
- static_ctors = tree_cons (NULL_TREE, fndecl, static_ctors);
+ if (targetm.have_ctors_dtors)
+ (* targetm.asm_out.constructor) (XEXP (DECL_RTL (fndecl), 0),
+ DEFAULT_INIT_PRIORITY);
else
-#endif
- assemble_constructor (XEXP (DECL_RTL (fndecl), 0),
- DEFAULT_INIT_PRIORITY);
+ static_ctors = tree_cons (NULL_TREE, fndecl, static_ctors);
}
if (DECL_STATIC_DESTRUCTOR (fndecl))
{
-#ifndef ASM_OUTPUT_DESTRUCTOR
- if (! flag_gnu_linker)
- static_dtors = tree_cons (NULL_TREE, fndecl, static_dtors);
+ if (targetm.have_ctors_dtors)
+ (* targetm.asm_out.destructor) (XEXP (DECL_RTL (fndecl), 0),
+ DEFAULT_INIT_PRIORITY);
else
-#endif
- assemble_destructor (XEXP (DECL_RTL (fndecl), 0),
- DEFAULT_INIT_PRIORITY);
+ static_dtors = tree_cons (NULL_TREE, fndecl, static_dtors);
}
if (nested_p)
diff --git a/gcc/ch/ChangeLog b/gcc/ch/ChangeLog
index b1c048b..f8fe135 100644
--- a/gcc/ch/ChangeLog
+++ b/gcc/ch/ChangeLog
@@ -1,3 +1,8 @@
+2001-08-09 Richard Henderson <rth@redhat.com>
+
+ * grant.c (chill_finish_compile): Use target hooks instead of
+ assemble_constructor.
+
2001-08-06 Richard Henderson <rth@redhat.com>
* grant.c (chill_finish_compile): Pass a symbol_ref and priority
diff --git a/gcc/ch/grant.c b/gcc/ch/grant.c
index c10eb99..806c944 100644
--- a/gcc/ch/grant.c
+++ b/gcc/ch/grant.c
@@ -31,6 +31,7 @@ Boston, MA 02111-1307, USA. */
#include "tasking.h"
#include "toplev.h"
#include "output.h"
+#include "target.h"
#define APPEND(X,Y) X = append (X, Y)
#define PREPEND(X,Y) X = prepend (X, Y);
@@ -3046,12 +3047,9 @@ chill_finish_compile ()
finish_chill_function ();
- if (pass == 2)
- {
- assemble_constructor (XEXP (DECL_RTL (chill_init_function), 0),
- DEFAULT_INIT_PRIORITY);
- globalize_decl (chill_init_function);
- }
+ if (pass == 2 && targetm.have_ctors_dtors)
+ (* targetm.asm_out.constructor)
+ (XEXP (DECL_RTL (chill_init_function), 0), DEFAULT_INIT_PRIORITY);
/* ready now to link decls onto this list in pass 2. */
module_init_list = NULL_TREE;
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 087101d..433e77c5 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -379,7 +379,7 @@ a29k-*-bsd* | a29k-*-sym1*)
use_collect2=yes
;;
a29k-*-udi | a29k-*-coff)
- tm_file="${tm_file} dbxcoff.h a29k/udi.h"
+ tm_file="${tm_file} dbxcoff.h"
tmake_file=a29k/t-a29kbare
;;
a29k*-*-rtems*)
@@ -390,7 +390,7 @@ a29k*-*-rtems*)
fi
;;
a29k-wrs-vxworks*)
- tm_file="${tm_file} dbxcoff.h a29k/udi.h a29k/vx29k.h"
+ tm_file="${tm_file} dbxcoff.h a29k/vx29k.h"
tmake_file=a29k/t-vx29k
extra_parts="crtbegin.o crtend.o"
thread_file='vxworks'
@@ -519,6 +519,9 @@ alpha*-dec-vms*)
xm_file=alpha/xm-vms.h
tmake_file="alpha/t-alpha alpha/t-vms alpha/t-ieee"
;;
+arc-*-elf*)
+ extra_parts="crtinit.o crtfini.o"
+ ;;
arm*-*-rtems*)
tm_file=arm/rtems-elf.h
tmake_file="arm/t-arm-elf t-rtems"
@@ -526,9 +529,6 @@ arm*-*-rtems*)
thread_file='rtems'
fi
;;
-arc-*-elf*)
- extra_parts="crtinit.o crtfini.o"
- ;;
arm-*-coff* | armel-*-coff*)
tm_file=arm/coff.h
tmake_file=arm/t-arm-coff
@@ -3378,15 +3378,6 @@ then
fi
fi
-# No need for collect2 if we have the GNU linker.
-# Actually, there is now; GNU ld doesn't handle the EH info or
-# collecting for shared libraries.
-#case x$gnu_ld in
-#xyes)
-# use_collect2=
-# ;;
-#esac
-
# Save data on machine being used to compile GCC in build_xm_file.
# Save data on host machine in vars host_xm_file and host_xmake_file.
if test x$pass1done = x
diff --git a/gcc/config/1750a/1750a.h b/gcc/config/1750a/1750a.h
index 72ee543..ac6e7ee 100644
--- a/gcc/config/1750a/1750a.h
+++ b/gcc/config/1750a/1750a.h
@@ -1220,14 +1220,6 @@ enum reg_class { NO_REGS, R2, R0_1, INDEX_REGS, BASE_REGS, ALL_REGS, LIM_REG_CLA
( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
-#define ASM_OUTPUT_CONSTRUCTOR(FILE, NAME) do { \
- fprintf(FILE, "\tinit\n\t"); assemble_name(FILE, NAME); \
- fprintf(FILE," ;constructor\n"); } while (0)
-
-#define ASM_OUTPUT_DESTRUCTOR(FILE, NAME) do { \
- fprintf(FILE, "\tinit\n\t"); assemble_name(FILE, NAME); \
- fprintf(FILE," ;destructor\n"); } while (0)
-
/* Print operand X (an rtx) in assembler syntax to file FILE.
CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
For `%' followed by punctuation, CODE is the punctuation and X is null.
diff --git a/gcc/config/a29k/a29k.c b/gcc/config/a29k/a29k.c
index a4905e6..8d816b2 100644
--- a/gcc/config/a29k/a29k.c
+++ b/gcc/config/a29k/a29k.c
@@ -24,6 +24,7 @@ Boston, MA 02111-1307, USA. */
#include "config.h"
#include "system.h"
#include "rtl.h"
+#include "tree.h"
#include "regs.h"
#include "hard-reg-set.h"
#include "real.h"
@@ -36,7 +37,6 @@ Boston, MA 02111-1307, USA. */
#include "function.h"
#include "expr.h"
#include "obstack.h"
-#include "tree.h"
#include "reload.h"
#include "tm_p.h"
#include "target.h"
diff --git a/gcc/config/a29k/udi.h b/gcc/config/a29k/udi.h
deleted file mode 100644
index 1b35bb2..0000000
--- a/gcc/config/a29k/udi.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Definitions of target machine for GNU compiler, for AMD Am29000 CPU
- running over UDI using COFF.
- Copyright (C) 1994, 1996, 2000 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC 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.
-
-GNU CC 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.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* Support the ctors and dtors sections for g++. */
-
-#define CTORS_SECTION_ASM_OP "\t.use .ctors"
-#define DTORS_SECTION_ASM_OP "\t.use .dtors"
-
-/* A list of other sections which the compiler might be "in" at any
- given time. */
-
-#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS readonly_data, in_ctors, in_dtors
-
-/* A list of extra section function definitions. */
-
-#undef EXTRA_SECTION_FUNCTIONS
-#define EXTRA_SECTION_FUNCTIONS \
- READONLY_DATA_FUNCTION \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
-
-#define READONLY_DATA_FUNCTION \
-void \
-literal_section () \
-{ \
- if (in_section != readonly_data) \
- { \
- fprintf (asm_out_file, "%s\n", READONLY_DATA_SECTION_ASM_OP); \
- in_section = readonly_data; \
- } \
-} \
-
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
-#define INT_ASM_OP "\t.word\t"
-
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
diff --git a/gcc/config/alpha/alpha-interix.h b/gcc/config/alpha/alpha-interix.h
index 4bbd988..b396c86 100644
--- a/gcc/config/alpha/alpha-interix.h
+++ b/gcc/config/alpha/alpha-interix.h
@@ -100,7 +100,7 @@ Boston, MA 02111-1307, USA. */
includes this file. */
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_const, in_ctors, in_dtors
+#define EXTRA_SECTIONS in_const
/* A default list of extra section function definitions. For targets
that use additional sections (e.g. .tdesc) you should override this
@@ -108,9 +108,7 @@ Boston, MA 02111-1307, USA. */
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
- CONST_SECTION_FUNCTION \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
+ CONST_SECTION_FUNCTION
#undef READONLY_DATA_SECTION
#define READONLY_DATA_SECTION() const_section ()
@@ -128,50 +126,8 @@ const_section () \
} \
}
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
#define INT_ASM_OP "\t.long\t"
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
/* The linker will take care of this, and having them causes problems with
ld -r (specifically -rU). */
#define CTOR_LISTS_DEFINED_EXTERNALLY 1
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 345d95e..ef65d72 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -152,6 +152,8 @@ static int vms_valid_decl_attribute_p PARAMS ((tree, tree, tree, tree));
static unsigned int vms_section_type_flags PARAMS ((tree, const char *, int));
static void vms_asm_named_section PARAMS ((const char *, unsigned int,
unsigned int));
+static void vms_asm_out_constructor PARAMS ((rtx, int));
+static void vms_asm_out_destructor PARAMS ((rtx, int));
# undef TARGET_VALID_DECL_ATTRIBUTE
# define TARGET_VALID_DECL_ATTRIBUTE vms_valid_decl_attribute_p
# undef TARGET_SECTION_TYPE_FLAGS
@@ -6585,6 +6587,31 @@ vms_asm_named_section (name, flags, align)
ASM_OUTPUT_ALIGN (asm_out_file, 0);
}
+/* Record an element in the table of global constructors. SYMBOL is
+ a SYMBOL_REF of the function to be called; PRIORITY is a number
+ between 0 and MAX_INIT_PRIORITY.
+
+ Differs from default_ctors_section_asm_out_constructor in that the
+ width of the .ctors entry is always 64 bits, rather than the 32 bits
+ used by a normal pointer. */
+
+static void
+vms_asm_out_constructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ ctors_section ();
+ assemble_integer (symbol, UNITS_PER_WORD, 1);
+}
+
+static void
+vms_asm_out_destructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ dtors_section ();
+ assemble_integer (symbol, UNITS_PER_WORD, 1);
+}
#else
rtx
diff --git a/gcc/config/alpha/elf.h b/gcc/config/alpha/elf.h
index a8e8900..c8e7667 100644
--- a/gcc/config/alpha/elf.h
+++ b/gcc/config/alpha/elf.h
@@ -202,27 +202,6 @@ do { \
#undef CONST_SECTION_ASM_OP
#define CONST_SECTION_ASM_OP "\t.section\t.rodata"
-/* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
-
- Note that we want to give these sections the SHF_WRITE attribute
- because these sections will actually contain data (i.e. tables of
- addresses of functions in the current root executable or shared library
- file) and, in the case of a shared library, the relocatable addresses
- will have to be properly resolved/relocated (and then written into) by
- the dynamic linker when it actually attaches the given shared library
- to the executing process. (Note that on SVR4, you may wish to use the
- `-z text' option to the ELF linker, when building a shared library, as
- an additional check that you are doing everything right. But if you do
- use the `-z text' option when building a shared library, you will get
- errors unless the .ctors and .dtors sections are marked as writable
- via the SHF_WRITE attribute.) */
-
-#undef CTORS_SECTION_ASM_OP
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
-#undef DTORS_SECTION_ASM_OP
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
-
-/* Handle the small data sections. */
#undef BSS_SECTION_ASM_OP
#define BSS_SECTION_ASM_OP "\t.section\t.bss"
#undef SBSS_SECTION_ASM_OP
@@ -247,7 +226,7 @@ do { \
includes this file. */
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_sbss, in_sdata
+#define EXTRA_SECTIONS in_const, in_sbss, in_sdata
/* A default list of extra section function definitions. For targets
that use additional sections (e.g. .tdesc) you should override this
@@ -256,8 +235,6 @@ do { \
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
CONST_SECTION_FUNCTION \
- SECTION_FUNCTION_TEMPLATE(ctors_section, in_ctors, CTORS_SECTION_ASM_OP) \
- SECTION_FUNCTION_TEMPLATE(dtors_section, in_dtors, DTORS_SECTION_ASM_OP) \
SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) \
SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP)
@@ -297,28 +274,6 @@ void FN () \
/* Switch into a generic section. */
#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE, NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE, NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
/* A C statement or statements to switch to the appropriate
section for output of DECL. DECL is either a `VAR_DECL' node
or a constant of some sort. RELOC indicates whether forming
diff --git a/gcc/config/alpha/vms.h b/gcc/config/alpha/vms.h
index bc7e1e6..506223c 100644
--- a/gcc/config/alpha/vms.h
+++ b/gcc/config/alpha/vms.h
@@ -253,7 +253,7 @@ typedef struct {int num_args; enum avms_arg_type atypes[6];} avms_arg_info;
#define DTORS_SECTION_ASM_OP "\t.dtors"
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_link, in_rdata, in_literals, in_ctors, in_dtors
+#define EXTRA_SECTIONS in_link, in_rdata, in_literals
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
@@ -283,31 +283,11 @@ literals_section () \
fprintf (asm_out_file, "%s\n", LITERALS_SECTION_ASM_OP); \
in_section = in_literals; \
} \
-} \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-} \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
}
extern void readonly_section PARAMS ((void));
extern void link_section PARAMS ((void));
extern void literals_section PARAMS ((void));
-extern void ctors_section PARAMS ((void));
-extern void dtors_section PARAMS ((void));
#undef ASM_OUTPUT_ADDR_DIFF_ELT
#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) abort ()
@@ -373,25 +353,9 @@ do { \
#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
alpha_initialize_trampoline (TRAMP, FNADDR, CXT, 16, 24, -1)
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "\t.quad "); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "\t.quad "); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
+/* Control how constructors and destructors are emitted. */
+#define TARGET_ASM_CONSTRUCTOR vms_asm_out_constructor
+#define TARGET_ASM_DESTRUCTOR vms_asm_out_destructor
#undef SDB_DEBUGGING_INFO
#undef MIPS_DEBUGGING_INFO
diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
index 9a7b270..07507a1 100644
--- a/gcc/config/arc/arc.h
+++ b/gcc/config/arc/arc.h
@@ -1373,28 +1373,6 @@ do { \
that we use). */
#define SET_ASM_OP "\t.set\t"
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE, NAME) \
-do { \
- ctors_section (); \
- fprintf (FILE, "\t.word\t%%st("); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, ")\n"); \
-} while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE, NAME) \
-do { \
- dtors_section (); \
- fprintf (FILE, "\t.word\t%%st("); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, ")\n"); \
-} while (0)
-
/* How to refer to registers in assembler output.
This sequence is indexed by compiler's hard-register-number (see above). */
#define REGISTER_NAMES \
diff --git a/gcc/config/arm/aof.h b/gcc/config/arm/aof.h
index 3b0baf5..2721b8b 100644
--- a/gcc/config/arm/aof.h
+++ b/gcc/config/arm/aof.h
@@ -60,12 +60,10 @@ char *aof_text_section ();
char *aof_data_section ();
#define DATA_SECTION_ASM_OP aof_data_section ()
-#define EXTRA_SECTIONS in_zero_init, in_ctor, in_dtor, in_common
+#define EXTRA_SECTIONS in_zero_init, in_common
#define EXTRA_SECTION_FUNCTIONS \
ZERO_INIT_SECTION \
-CTOR_SECTION \
-DTOR_SECTION \
COMMON_SECTION
#define ZERO_INIT_SECTION \
@@ -81,44 +79,6 @@ zero_init_section () \
} \
}
-#define CTOR_SECTION \
-void \
-ctor_section () \
-{ \
- static int ctors_once = 0; \
- if (in_section != in_ctor) \
- { \
- if (ctors_once) \
- { \
- fprintf (stderr, \
- "Attempt to output more than one ctor section\n"); \
- abort (); \
- } \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctor; \
- ctors_once = 1; \
- } \
-}
-
-#define DTOR_SECTION \
-void \
-dtor_section () \
-{ \
- static int dtors_once = 0; \
- if (in_section != in_dtor) \
- { \
- if (dtors_once) \
- { \
- fprintf (stderr, \
- "Attempt to output more than one dtor section\n"); \
- abort (); \
- } \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtor; \
- dtors_once = 1; \
- } \
-}
-
/* Used by ASM_OUTPUT_COMMON (below) to tell varasm.c that we've
changed areas. */
#define COMMON_SECTION \
@@ -364,22 +324,6 @@ do { \
#define CTORS_SECTION_ASM_OP "\tAREA\t|C$$gnu_ctorsvec|, DATA, READONLY"
#define DTORS_SECTION_ASM_OP "\tAREA\t|C$$gnu_dtorsvec|, DATA, READONLY"
-#define ASM_OUTPUT_CONSTRUCTOR(STREAM,NAME) \
-do { \
- ctor_section (); \
- fprintf ((STREAM), "\tDCD\t"); \
- assemble_name ((STREAM), (NAME)); \
- fputc ('\n', (STREAM)); \
-} while (0);
-
-#define ASM_OUTPUT_DESTRUCTOR(STREAM,NAME) \
-do { \
- dtor_section (); \
- fprintf ((STREAM), "\tDCD\t"); \
- assemble_name ((STREAM), (NAME)); \
- fputc ('\n', (STREAM)); \
-} while (0);
-
/* Output of Assembler Instructions */
#define REGISTER_NAMES \
diff --git a/gcc/config/arm/coff.h b/gcc/config/arm/coff.h
index 11cb9bb..db057b9 100644
--- a/gcc/config/arm/coff.h
+++ b/gcc/config/arm/coff.h
@@ -89,7 +89,7 @@ Boston, MA 02111-1307, USA. */
given time. */
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS SUBTARGET_EXTRA_SECTIONS in_rdata, in_ctors, in_dtors
+#define EXTRA_SECTIONS SUBTARGET_EXTRA_SECTIONS in_rdata
#define SUBTARGET_EXTRA_SECTIONS
@@ -98,8 +98,6 @@ Boston, MA 02111-1307, USA. */
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
RDATA_SECTION_FUNCTION \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION \
SUBTARGET_EXTRA_SECTION_FUNCTIONS
#define SUBTARGET_EXTRA_SECTION_FUNCTIONS
@@ -114,59 +112,11 @@ rdata_section () \
in_section = in_rdata; \
} \
}
-
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
/* Support the ctors/dtors sections for g++. */
#define INT_ASM_OP "\t.word\t"
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(STREAM, NAME) \
- do \
- { \
- ctors_section (); \
- fprintf (STREAM, "%s", INT_ASM_OP); \
- assemble_name (STREAM, NAME); \
- fprintf (STREAM, "\n"); \
- } \
- while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(STREAM, NAME) \
- do \
- { \
- dtors_section (); \
- fprintf (STREAM, "%s", INT_ASM_OP); \
- assemble_name (STREAM, NAME); \
- fprintf (STREAM, "\n"); \
- } \
- while (0)
-
/* __CTOR_LIST__ and __DTOR_LIST__ must be defined by the linker script. */
#define CTOR_LISTS_DEFINED_EXTERNALLY
diff --git a/gcc/config/arm/elf.h b/gcc/config/arm/elf.h
index 102b53a..0c8cd03 100644
--- a/gcc/config/arm/elf.h
+++ b/gcc/config/arm/elf.h
@@ -227,30 +227,6 @@ Boston, MA 02111-1307, USA. */
while (0)
#endif
-/* Support the ctors/dtors and other sections. */
-
-/* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
-
- Note that we want to give these sections the SHF_WRITE attribute
- because these sections will actually contain data (i.e. tables of
- addresses of functions in the current root executable or shared library
- file) and, in the case of a shared library, the relocatable addresses
- will have to be properly resolved/relocated (and then written into) by
- the dynamic linker when it actually attaches the given shared library
- to the executing process. (Note that on SVR4, you may wish to use the
- `-z text' option to the ELF linker, when building a shared library, as
- an additional check that you are doing everything right. But if you do
- use the `-z text' option when building a shared library, you will get
- errors unless the .ctors and .dtors sections are marked as writable
- via the SHF_WRITE attribute.) */
-#ifndef CTORS_SECTION_ASM_OP
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
-#endif
-
-#ifndef DTORS_SECTION_ASM_OP
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
-#endif
-
/* A list of other sections which the compiler might be "in" at any
given time. */
#ifndef SUBTARGET_EXTRA_SECTIONS
@@ -258,7 +234,7 @@ Boston, MA 02111-1307, USA. */
#endif
#ifndef EXTRA_SECTIONS
-#define EXTRA_SECTIONS SUBTARGET_EXTRA_SECTIONS in_ctors, in_dtors
+#define EXTRA_SECTIONS SUBTARGET_EXTRA_SECTIONS
#endif
/* A list of extra section function definitions. */
@@ -268,35 +244,7 @@ Boston, MA 02111-1307, USA. */
#ifndef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
- SUBTARGET_EXTRA_SECTION_FUNCTIONS \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
-#endif
-
-#ifndef CTORS_SECTION_FUNCTION
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-#endif
-
-#ifndef DTORS_SECTION_FUNCTION
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
+ SUBTARGET_EXTRA_SECTION_FUNCTIONS
#endif
/* Switch into a generic section. */
@@ -308,34 +256,6 @@ dtors_section () \
#define INT_ASM_OP "\t.word\t"
#endif
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#ifndef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(STREAM, NAME) \
- do \
- { \
- ctors_section (); \
- fprintf (STREAM, "%s", INT_ASM_OP); \
- assemble_name (STREAM, NAME); \
- fprintf (STREAM, "\n"); \
- } \
- while (0)
-#endif
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#ifndef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(STREAM, NAME) \
- do \
- { \
- dtors_section (); \
- fprintf (STREAM, "%s", INT_ASM_OP); \
- assemble_name (STREAM, NAME); \
- fprintf (STREAM, "\n"); \
- } \
- while (0)
-#endif
-
/* This is how we tell the assembler that a symbol is weak. */
#define ASM_WEAKEN_LABEL(FILE, NAME) \
diff --git a/gcc/config/c4x/c4x.c b/gcc/config/c4x/c4x.c
index da2f90d..add05c7 100644
--- a/gcc/config/c4x/c4x.c
+++ b/gcc/config/c4x/c4x.c
@@ -25,8 +25,8 @@ Boston, MA 02111-1307, USA. */
/* Some output-actions in c4x.md need these. */
#include "config.h"
#include "system.h"
-#include "toplev.h"
#include "rtl.h"
+#include "tree.h"
#include "regs.h"
#include "hard-reg-set.h"
#include "basic-block.h"
@@ -35,7 +35,6 @@ Boston, MA 02111-1307, USA. */
#include "insn-attr.h"
#include "conditions.h"
#include "output.h"
-#include "tree.h"
#include "function.h"
#include "expr.h"
#include "flags.h"
@@ -46,6 +45,7 @@ Boston, MA 02111-1307, USA. */
#include "cpplib.h"
#include "c-lex.h"
#include "c-pragma.h"
+#include "toplev.h"
#include "c4x-protos.h"
#include "target.h"
#include "target-def.h"
diff --git a/gcc/config/c4x/c4x.h b/gcc/config/c4x/c4x.h
index dba5e47..607bc48 100644
--- a/gcc/config/c4x/c4x.h
+++ b/gcc/config/c4x/c4x.h
@@ -1979,48 +1979,14 @@ if (REG_P (OP1) && ! REG_P (OP0)) \
#define FINI_SECTION_ASM_OP "\t.sect\t\".fini\""
-/* Support const sections and the ctors and dtors sections for g++.
- Note that there appears to be two different ways to support const
- sections at the moment. You can either #define the symbol
- READONLY_DATA_SECTION (giving it some code which switches to the
- readonly data section) or else you can #define the symbols
- EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
- SELECT_RTX_SECTION. We do both here just to be on the safe side. */
-
-/* Define a few machine-specific details of the implementation of
- constructors.
-
- The __CTORS_LIST__ goes in the .ctors section. Define CTOR_LIST_BEGIN
- and CTOR_LIST_END to contribute to the .ctors section an instruction to
- push a word containing 0 (or some equivalent of that).
-
- Define ASM_OUTPUT_CONSTRUCTOR to push the address of the constructor. */
-
-#define CTORS_SECTION_ASM_OP "\t.sect\t\".ctors\""
-#define DTORS_SECTION_ASM_OP "\t.sect\t\".dtors\""
-
-/* Constructor list on stack is in reverse order. Go to the end of the
- list and go backwards to call constructors in the right order. */
-
-#define DO_GLOBAL_CTORS_BODY \
-do { \
- extern func_ptr __CTOR_LIST__[]; \
- func_ptr *p, *beg = __CTOR_LIST__ + 1; \
- for (p = beg; *p ; p++) ; \
- while (p != beg) \
- (*--p) (); \
-} while (0)
-
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_const, in_init, in_fini, in_ctors, in_dtors
+#define EXTRA_SECTIONS in_const, in_init, in_fini
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
CONST_SECTION_FUNCTION \
INIT_SECTION_FUNCTION \
- FINI_SECTION_FUNCTION \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
+ FINI_SECTION_FUNCTION
#define INIT_SECTION_FUNCTION \
void \
@@ -2061,58 +2027,9 @@ const_section () \
#define ASM_STABS_OP "\t.stabs\t"
-/* The ctors and dtors sections are not normally put into use
- by EXTRA_SECTIONS and EXTRA_SECTION_FUNCTIONS as defined in svr3.h,
- but it can't hurt to define these macros for whatever systems use them. */
-
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
/* Switch into a generic section. */
#define TARGET_ASM_NAMED_SECTION c4x_asm_named_section
-/* This is machine-dependent because it needs to push something
- on the stack. */
-
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "\t.word\t "); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "\t.word\t "); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
/* A C statement or statements to switch to the appropriate
section for output of DECL. DECL is either a `VAR_DECL' node
or a constant of some sort. RELOC indicates whether forming
diff --git a/gcc/config/clipper/clipper.c b/gcc/config/clipper/clipper.c
index 1e3118e..d92030d 100644
--- a/gcc/config/clipper/clipper.c
+++ b/gcc/config/clipper/clipper.c
@@ -42,6 +42,8 @@ Boston, MA 02111-1307, USA. */
static void clipper_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
static void clipper_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
+static void clix_asm_out_constructor PARAMS ((rtx, int));
+static void clix_asm_out_destructor PARAMS ((rtx, int));
extern char regs_ever_live[];
@@ -691,3 +693,23 @@ fp_reg_operand (op, mode)
GET_MODE_CLASS (GET_MODE (SUBREG_REG (op))) == MODE_FLOAT));
}
+static void
+clix_asm_out_constructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ init_section ();
+ fputs ("\tloada ", asm_out_file);
+ assemble_name (asm_out_file, XSTR (symbol, 0));
+ fputs (",r0\n\tsubq $8,sp\n\tstorw r0,(sp)\n", asm_out_file);
+}
+
+static void
+clix_asm_out_destructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ fini_section ();
+ assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1);
+ assemble_integer (const0_rtx, POINTER_SIZE / BITS_PER_UNIT, 1);
+}
diff --git a/gcc/config/clipper/clix.h b/gcc/config/clipper/clix.h
index 6aedd6e..bce6979 100644
--- a/gcc/config/clipper/clix.h
+++ b/gcc/config/clipper/clix.h
@@ -96,33 +96,16 @@ do { \
#undef CTOR_LIST_END
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- init_section (); \
- fputs ("\tloada ", FILE); \
- assemble_name (FILE, NAME); \
- fputs (",r0\n\tsubq $8,sp\n\tstorw r0,(sp)\n", FILE); \
- } while (0)
-
-
/* fini psect is 8 aligned */
#define DTOR_LIST_BEGIN \
asm (DTORS_SECTION_ASM_OP); \
func_ptr __DTOR_LIST__[2] = { (func_ptr) (-1), 0 };
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- fini_section (); \
- fprintf (FILE, "%s\t ", ASM_LONG); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, ",0\n"); \
- } while (0)
-
+#undef TARGET_ASM_CONSTRUCTOR
+#define TARGET_ASM_CONSTRUCTOR clix_asm_out_constructor
+#undef TARGET_ASM_DESTRUCTOR
+#define TARGET_ASM_DESTRUCTOR clix_asm_out_destructor
/* On clix crt1.o first calls init code and then sets environ and a valid
chrclass. Unfortunately stdio routines bomb with unset chrclass.
diff --git a/gcc/config/d30v/d30v.h b/gcc/config/d30v/d30v.h
index 44e2e27..e39f37c 100644
--- a/gcc/config/d30v/d30v.h
+++ b/gcc/config/d30v/d30v.h
@@ -4463,29 +4463,6 @@ do { \
collecting the lists of constructors and destructors. */
#define INVOKE__main
-/* Define this macro as a C statement to output on the stream STREAM the
- assembler code to arrange to call the function named NAME at initialization
- time.
-
- Assume that NAME is the name of a C function generated automatically by the
- compiler. This function takes no arguments. Use the function
- `assemble_name' to output the name NAME; this performs any system-specific
- syntactic transformations such as adding an underscore.
-
- If you don't define this macro, nothing special is output to arrange to call
- the function. This is correct when the function will be called in some
- other manner--for example, by means of the `collect2' program, which looks
- through the symbol table to find these functions by their names.
-
- Defined in svr4.h. */
-/* #define ASM_OUTPUT_CONSTRUCTOR(STREAM, NAME) */
-
-/* This is like `ASM_OUTPUT_CONSTRUCTOR' but used for termination functions
- rather than initialization functions.
-
- Defined in svr4.h. */
-/* #define ASM_OUTPUT_DESTRUCTOR(STREAM, NAME) */
-
/* If your system uses `collect2' as the means of processing constructors, then
that program normally uses `nm' to scan an object file for constructor
functions to be called. On certain kinds of systems, you can define these
diff --git a/gcc/config/darwin-protos.h b/gcc/config/darwin-protos.h
index 6eb5bfd..f911076 100644
--- a/gcc/config/darwin-protos.h
+++ b/gcc/config/darwin-protos.h
@@ -42,6 +42,8 @@ extern rtx machopic_indirect_data_reference PARAMS ((rtx, rtx));
extern rtx machopic_indirect_call_target PARAMS ((rtx));
extern rtx machopic_legitimize_pic_address PARAMS ((rtx, enum machine_mode, rtx));
+extern void machopic_asm_out_constructor PARAMS ((rtx, int));
+extern void machopic_asm_out_destructor PARAMS ((rtx, int));
#endif /* RTX_CODE */
#ifdef TREE_CODE
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 65311a3..f2bd5bd 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -1107,3 +1107,33 @@ update_stubs (name)
}
}
}
+
+void
+machopic_asm_out_constructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ if (flag_pic)
+ mod_init_section ();
+ else
+ constructor_section ();
+ assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1);
+
+ if (!flag_pic)
+ fprintf (asm_out_file, ".reference .constructors_used\n");
+}
+
+void
+machopic_asm_out_destructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ if (flag_pic)
+ mod_term_section ();
+ else
+ destructor_section ();
+ assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1);
+
+ if (!flag_pic)
+ fprintf (asm_out_file, ".reference .destructors_used\n");
+}
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 5cebd58..193a523 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -158,33 +158,8 @@ do { text_section (); \
#undef INVOKE__main
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { if (flag_pic) \
- mod_init_section (); \
- else \
- constructor_section (); \
- ASM_OUTPUT_ALIGN (FILE, 1); \
- fprintf (FILE, "\t.long "); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- if (!flag_pic) \
- fprintf (FILE, ".reference .constructors_used\n"); \
- } while (0)
-
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { if (flag_pic) \
- mod_term_section (); \
- else \
- destructor_section (); \
- ASM_OUTPUT_ALIGN (FILE, 1); \
- fprintf (FILE, "\t.long "); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- if (!flag_pic) \
- fprintf (FILE, ".reference .destructors_used\n"); \
- } while (0)
+#define TARGET_ASM_CONSTRUCTOR machopic_asm_out_constructor
+#define TARGET_ASM_DESTRUCTOR machopic_asm_out_destructor
/* Don't output a .file directive. That is only used by the assembler for
diff --git a/gcc/config/elfos.h b/gcc/config/elfos.h
index 82dde08..d813678 100644
--- a/gcc/config/elfos.h
+++ b/gcc/config/elfos.h
@@ -225,8 +225,7 @@ Boston, MA 02111-1307, USA. */
/* This is the pseudo-op used to generate a reference to a specific
symbol in some section. It is only used in machine-specific
- configuration files, typically only in ASM_OUTPUT_CONSTRUCTOR and
- ASM_OUTPUT_DESTRUCTOR. This is the same for all known svr4
+ configuration files. This is the same for all known svr4
assemblers, except those in targets that don't use 32-bit pointers.
Those should override INT_ASM_OP. Yes, the name of the macro is
misleading. */
@@ -254,24 +253,6 @@ Boston, MA 02111-1307, USA. */
#define CONST_SECTION_ASM_OP "\t.section\t.rodata"
-/* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
-
- Note that we want to give these sections the SHF_WRITE attribute
- because these sections will actually contain data (i.e. tables of
- addresses of functions in the current root executable or shared library
- file) and, in the case of a shared library, the relocatable addresses
- will have to be properly resolved/relocated (and then written into) by
- the dynamic linker when it actually attaches the given shared library
- to the executing process. (Note that on SVR4, you may wish to use the
- `-z text' option to the ELF linker, when building a shared library, as
- an additional check that you are doing everything right. But if you do
- use the `-z text' option when building a shared library, you will get
- errors unless the .ctors and .dtors sections are marked as writable
- via the SHF_WRITE attribute.) */
-
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
-
/* On svr4, we *do* have support for the .init and .fini sections, and we
can put stuff in there to be executed before and after `main'. We let
crtstuff.c and other files know this by defining the following symbols.
@@ -287,7 +268,7 @@ Boston, MA 02111-1307, USA. */
includes this file. */
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_const, in_ctors, in_dtors
+#define EXTRA_SECTIONS in_const
/* A default list of extra section function definitions. For targets
that use additional sections (e.g. .tdesc) you should override this
@@ -295,9 +276,7 @@ Boston, MA 02111-1307, USA. */
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
- CONST_SECTION_FUNCTION \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
+ CONST_SECTION_FUNCTION
#define READONLY_DATA_SECTION() const_section ()
@@ -314,28 +293,6 @@ const_section () \
} \
}
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
#define UNIQUE_SECTION(DECL, RELOC) \
@@ -377,30 +334,6 @@ dtors_section () \
} \
while (0)
-/* A C statement (sans semicolon) to output an
- element in the table of global constructors. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE, NAME) \
- do \
- { \
- ctors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } \
- while (0)
-
-/* A C statement (sans semicolon) to output an
- element in the table of global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do \
- { \
- dtors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } \
- while (0)
-
/* Switch into a generic section. */
#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
diff --git a/gcc/config/h8300/h8300.h b/gcc/config/h8300/h8300.h
index f419ba4..735a423 100644
--- a/gcc/config/h8300/h8300.h
+++ b/gcc/config/h8300/h8300.h
@@ -1088,34 +1088,11 @@ struct cum_arg
#define DATA_SECTION_ASM_OP "\t.section .data"
#define BSS_SECTION_ASM_OP "\t.section .bss"
#define INIT_SECTION_ASM_OP "\t.section .init"
-#define CTORS_SECTION_ASM_OP "\t.section .ctors"
-#define DTORS_SECTION_ASM_OP "\t.section .dtors"
#define READONLY_DATA_SECTION_ASM_OP "\t.section .rodata"
-#define EXTRA_SECTIONS in_ctors, in_dtors, in_readonly_data
+#define EXTRA_SECTIONS in_readonly_data
#define EXTRA_SECTION_FUNCTIONS \
- \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-} \
- \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-} \
- \
void \
readonly_data () \
{ \
@@ -1126,22 +1103,6 @@ readonly_data () \
} \
}
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do \
- { \
- ctors_section (); \
- fprintf (FILE, "%s_%s\n", ASM_WORD_OP, NAME); \
- } \
- while (0)
-
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do \
- { \
- dtors_section (); \
- fprintf (FILE, "%s_%s\n", ASM_WORD_OP, NAME); \
- } \
- while (0)
-
#undef DO_GLOBAL_CTORS_BODY
#define DO_GLOBAL_CTORS_BODY \
{ \
@@ -1156,7 +1117,7 @@ readonly_data () \
}
#undef DO_GLOBAL_DTORS_BODY
-#define DO_GLOBAL_DTORS_BODY \
+#define DO_GLOBAL_DTORS_BODY \
{ \
typedef (*pfunc)(); \
extern pfunc __dtors[]; \
diff --git a/gcc/config/i386/aix386.h b/gcc/config/i386/aix386.h
index a9115ad..f085c42 100644
--- a/gcc/config/i386/aix386.h
+++ b/gcc/config/i386/aix386.h
@@ -60,10 +60,5 @@ Boston, MA 02111-1307, USA. */
asm ("pushl $0")
#define CTOR_LIST_END CTOR_LIST_BEGIN
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- init_section (); \
- fprintf (FILE, "\tpushl $"); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
+#undef TARGET_ASM_CONSTRUCTOR
+#define TARGET_ASM_CONSTRUCTOR ix86_svr3_asm_out_constructor
diff --git a/gcc/config/i386/aix386ng.h b/gcc/config/i386/aix386ng.h
index 02f9502..445d333 100644
--- a/gcc/config/i386/aix386ng.h
+++ b/gcc/config/i386/aix386ng.h
@@ -106,8 +106,8 @@ Boston, MA 02111-1307, USA. */
# undef FINI_SECTION_ASM_OP
# undef CTORS_SECTION_ASM_OP
# undef DTORS_SECTION_ASM_OP
-# undef ASM_OUTPUT_CONSTRUCTOR
-# undef ASM_OUTPUT_DESTRUCTOR
+# undef TARGET_ASM_CONSTRUCTOR
+# undef TARGET_ASM_DESTRUCTOR
# undef DO_GLOBAL_CTORS_BODY
# undef CTOR_LIST_BEGIN
diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h
index 9ea367f..71b8468 100644
--- a/gcc/config/i386/cygwin.h
+++ b/gcc/config/i386/cygwin.h
@@ -199,39 +199,13 @@ union tree_node;
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_ctor, in_dtor, in_drectve
+#define EXTRA_SECTIONS in_drectve
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
- CTOR_SECTION_FUNCTION \
- DTOR_SECTION_FUNCTION \
DRECTVE_SECTION_FUNCTION \
SWITCH_TO_SECTION_FUNCTION
-#define CTOR_SECTION_FUNCTION \
-void \
-ctor_section () \
-{ \
- if (in_section != in_ctor) \
- { \
- fprintf (asm_out_file, "\t.section .ctor\n"); \
- in_section = in_ctor; \
- } \
-}
-void ctor_section PARAMS ((void));
-
-#define DTOR_SECTION_FUNCTION \
-void \
-dtor_section () \
-{ \
- if (in_section != in_dtor) \
- { \
- fprintf (asm_out_file, "\t.section .dtor\n"); \
- in_section = in_dtor; \
- } \
-}
-void dtor_section PARAMS ((void));
-
#define DRECTVE_SECTION_FUNCTION \
void \
drectve_section () \
@@ -262,29 +236,11 @@ switch_to_section (section, decl) \
case in_text: text_section (); break; \
case in_data: data_section (); break; \
case in_named: named_section (decl, NULL, 0); break; \
- case in_ctor: ctor_section (); break; \
- case in_dtor: dtor_section (); break; \
case in_drectve: drectve_section (); break; \
default: abort (); break; \
} \
}
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctor_section (); \
- fputs (ASM_LONG, FILE); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtor_section (); \
- fputs (ASM_LONG, FILE); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
/* Don't allow flag_pic to propagate since gas may produce invalid code
otherwise. */
diff --git a/gcc/config/i386/djgpp.h b/gcc/config/i386/djgpp.h
index f5e79c2..0bde498 100644
--- a/gcc/config/i386/djgpp.h
+++ b/gcc/config/i386/djgpp.h
@@ -45,18 +45,10 @@ Boston, MA 02111-1307, USA. */
#undef BSS_SECTION_ASM_OP
#define BSS_SECTION_ASM_OP "\t.section\t.bss"
-/* Define the name of the .ctor section. */
-#undef CTORS_SECTION_ASM_OP
-#define CTORS_SECTION_ASM_OP "\t.section .ctor"
-
/* Define the name of the .data section. */
#undef DATA_SECTION_ASM_OP
#define DATA_SECTION_ASM_OP "\t.section .data"
-/* Define the name of the .dtor section. */
-#undef DTORS_SECTION_ASM_OP
-#define DTORS_SECTION_ASM_OP "\t.section .dtor"
-
/* Define the name of the .ident op. */
#undef IDENT_ASM_OP
#define IDENT_ASM_OP "\t.ident\t"
@@ -147,55 +139,9 @@ Boston, MA 02111-1307, USA. */
unless user explicitly requests it. */
#undef LOCAL_INCLUDE_DIR
-#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_ctor, in_dtor
-
-#undef EXTRA_SECTION_FUNCTIONS
-#define EXTRA_SECTION_FUNCTIONS \
- CTOR_SECTION_FUNCTION \
- DTOR_SECTION_FUNCTION
-
-#define CTOR_SECTION_FUNCTION \
-void \
-ctor_section () \
-{ \
- if (in_section != in_ctor) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctor; \
- } \
-}
-
-#define DTOR_SECTION_FUNCTION \
-void \
-dtor_section () \
-{ \
- if (in_section != in_dtor) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtor; \
- } \
-}
-
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctor_section (); \
- fputs (ASM_LONG, FILE); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
/* Switch into a generic section. */
#define TARGET_ASM_NAMED_SECTION default_coff_asm_named_section
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtor_section (); \
- fputs (ASM_LONG, FILE); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
/* Output at beginning of assembler file. */
/* The .file command should always begin the output. */
diff --git a/gcc/config/i386/i386-coff.h b/gcc/config/i386/i386-coff.h
index 69839e1..c1ae670 100644
--- a/gcc/config/i386/i386-coff.h
+++ b/gcc/config/i386/i386-coff.h
@@ -37,65 +37,7 @@ Boston, MA 02111-1307, USA. */
#undef PREFERRED_DEBUGGING_TYPE
#define PREFERRED_DEBUGGING_TYPE SDB_DEBUG
-/* Support the ctors and dtors sections for g++. */
-
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"x\""
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"x\""
-
-/* A list of other sections which the compiler might be "in" at any
- given time. */
-
-#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_ctors, in_dtors
-
-/* A list of extra section function definitions. */
-
-#undef EXTRA_SECTION_FUNCTIONS
-#define EXTRA_SECTION_FUNCTIONS \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
-
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
+/* Switch into a generic section. */
+#define TARGET_ASM_NAMED_SECTION default_coff_asm_named_section
/* end of i386-coff.h */
diff --git a/gcc/config/i386/i386-interix.h b/gcc/config/i386/i386-interix.h
index 864f520..5b114106 100644
--- a/gcc/config/i386/i386-interix.h
+++ b/gcc/config/i386/i386-interix.h
@@ -253,10 +253,7 @@ Boston, MA 02111-1307, USA. */
#undef LD_FINI_SWITCH
-/* The following are needed for C++, but also needed for profiling */
-
-/* Support const sections and the ctors and dtors sections for g++.
- Note that there appears to be two different ways to support const
+/* Note that there appears to be two different ways to support const
sections at the moment. You can either #define the symbol
READONLY_DATA_SECTION (giving it some code which switches to the
readonly data section) or else you can #define the symbols
@@ -267,31 +264,13 @@ Boston, MA 02111-1307, USA. */
#define CONST_SECTION_ASM_OP "\t.section\t.rdata,\"r\""
-/* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
-
- Note that we want to give these sections the SHF_WRITE attribute
- because these sections will actually contain data (i.e. tables of
- addresses of functions in the current root executable or shared library
- file) and, in the case of a shared library, the relocatable addresses
- will have to be properly resolved/relocated (and then written into) by
- the dynamic linker when it actually attaches the given shared library
- to the executing process. (Note that on SVR4, you may wish to use the
- `-z text' option to the ELF linker, when building a shared library, as
- an additional check that you are doing everything right. But if you do
- use the `-z text' option when building a shared library, you will get
- errors unless the .ctors and .dtors sections are marked as writable
- via the SHF_WRITE attribute.) */
-
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"x\""
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"x\""
-
/* A default list of other sections which we might be "in" at any given
time. For targets that use additional sections (e.g. .tdesc) you
should override this definition in the target-specific file which
includes this file. */
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_const, in_ctors, in_dtors
+#define EXTRA_SECTIONS in_const
/* A default list of extra section function definitions. For targets
that use additional sections (e.g. .tdesc) you should override this
@@ -299,9 +278,7 @@ Boston, MA 02111-1307, USA. */
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
- CONST_SECTION_FUNCTION \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
+ CONST_SECTION_FUNCTION
#undef READONLY_DATA_SECTION
#define READONLY_DATA_SECTION() const_section ()
@@ -319,53 +296,11 @@ const_section () \
} \
}
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
/* The MS compilers take alignment as a number of bytes, so we do as well */
#undef ASM_OUTPUT_ALIGN
#define ASM_OUTPUT_ALIGN(FILE,LOG) \
if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1<<(LOG))
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
/* The linker will take care of this, and having them causes problems with
ld -r (specifically -rU). */
#define CTOR_LISTS_DEFINED_EXTERNALLY 1
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 6508625d..aae281c 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -608,9 +608,13 @@ static int ix86_save_reg PARAMS ((int, int));
static void ix86_compute_frame_layout PARAMS ((struct ix86_frame *));
static int ix86_comp_type_attributes PARAMS ((tree, tree));
+#ifdef DO_GLOBAL_CTORS_BODY
+static void ix86_svr3_asm_out_constructor PARAMS ((rtx, int));
+#endif
#if defined(TARGET_ELF) && defined(TARGET_COFF)
static void sco_asm_named_section PARAMS ((const char *, unsigned int,
unsigned int));
+static void sco_asm_out_constructor PARAMS ((rtx, int));
#endif
/* Initialize the GCC target structure. */
@@ -10783,6 +10787,19 @@ ix86_memory_move_cost (mode, class, in)
}
}
+#ifdef DO_GLOBAL_CTORS_BODY
+static void
+ix86_svr3_asm_out_constructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ init_section ();
+ fputs ("\tpushl $", asm_out_file);
+ assemble_name (asm_out_file, XSTR (symbol, 0));
+ fputc ('\n', asm_out_file);
+}
+#endif
+
#if defined(TARGET_ELF) && defined(TARGET_COFF)
static void
sco_asm_named_section (name, flags, align)
@@ -10795,4 +10812,15 @@ sco_asm_named_section (name, flags, align)
else
default_coff_asm_named_section (name, flags, align);
}
+
+static void
+sco_asm_out_constructor (symbol, priority)
+ rtx symbol;
+ int priority;
+{
+ if (TARGET_ELF)
+ default_named_section_asm_out_constrctor (symbol, priority);
+ else
+ ix86_svr3_asm_out_constructor (symbol, priority);
+}
#endif
diff --git a/gcc/config/i386/sco5.h b/gcc/config/i386/sco5.h
index b7a7cdb..a818427 100644
--- a/gcc/config/i386/sco5.h
+++ b/gcc/config/i386/sco5.h
@@ -390,37 +390,8 @@ do { \
ASM_OUTPUT_INTERNAL_LABEL((FILE),(PREFIX),(NUM)); \
} while (0)
-
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
-do { \
- if (TARGET_ELF) { \
- ctors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } else { \
- init_section (); \
- fprintf (FILE, "\tpushl $"); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); } \
- } while (0)
-
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
-do { \
- if (TARGET_ELF) { \
- dtors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } else { \
- fini_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); } \
- } while (0)
-
+#undef TARGET_ASM_CONSTRUCTOR
+#define TARGET_ASM_CONSTRUCTOR sco_asm_out_constructor
#undef ASM_OUTPUT_IDENT
#define ASM_OUTPUT_IDENT(FILE, NAME) \
@@ -508,15 +479,13 @@ do { \
((TARGET_ELF) ? DWARF2_DEBUG: SDB_DEBUG)
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_const, in_init, in_fini, in_ctors, in_dtors
+#define EXTRA_SECTIONS in_const, in_init, in_fini
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
CONST_SECTION_FUNCTION \
INIT_SECTION_FUNCTION \
- FINI_SECTION_FUNCTION \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
+ FINI_SECTION_FUNCTION
#undef CONST_SECTION_FUNCTION
#define CONST_SECTION_FUNCTION \
@@ -556,30 +525,6 @@ init_section () \
} \
}
-#undef CTORS_SECTION_FUNCTION
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#undef DTORS_SECTION_FUNCTION
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
#undef SUBTARGET_FRAME_POINTER_REQUIRED
#define SUBTARGET_FRAME_POINTER_REQUIRED \
((TARGET_ELF) ? 0 : \
diff --git a/gcc/config/i386/svr3gas.h b/gcc/config/i386/svr3gas.h
index db4be5d..8733ba7 100644
--- a/gcc/config/i386/svr3gas.h
+++ b/gcc/config/i386/svr3gas.h
@@ -94,15 +94,6 @@ Boston, MA 02111-1307, USA. */
unless the specific tm.h file turns it on by defining
USE_CONST_SECTION as 1. */
-/* Define a few machine-specific details of the implementation of
- constructors.
-
- The __CTORS_LIST__ goes in the .init section. Define CTOR_LIST_BEGIN
- and CTOR_LIST_END to contribute to the .init section an instruction to
- push a word containing 0 (or some equivalent of that).
-
- Define ASM_OUTPUT_CONSTRUCTOR to push the address of the constructor. */
-
#define USE_CONST_SECTION 0
#define INIT_SECTION_ASM_OP "\t.section\t.init"
@@ -113,8 +104,12 @@ Boston, MA 02111-1307, USA. */
/* CTOR_LIST_BEGIN and CTOR_LIST_END are machine-dependent
because they push on the stack. */
+/* This is copied from i386/sysv3.h. */
-#ifdef STACK_GROWS_DOWNWARD
+#define CTOR_LIST_BEGIN \
+ asm (INIT_SECTION_ASM_OP); \
+ asm ("pushl $0")
+#define CTOR_LIST_END CTOR_LIST_BEGIN
/* Constructor list on stack is in reverse order. Go to the end of the
list and go backwards to call constructors in the right order. */
@@ -127,18 +122,6 @@ do { \
(*--p) (); \
} while (0)
-#else
-
-/* Constructor list on stack is in correct order. Just call them. */
-#define DO_GLOBAL_CTORS_BODY \
-do { \
- func_ptr *p, *beg = alloca (0); \
- for (p = beg; *p; ) \
- (*p++) (); \
-} while (0)
-
-#endif /* STACK_GROWS_DOWNWARD */
-
/* Add extra sections .rodata, .init and .fini. */
#undef EXTRA_SECTIONS
@@ -187,44 +170,7 @@ const_section () \
} \
}
-/* The ctors and dtors sections are not normally put into use
- by EXTRA_SECTIONS and EXTRA_SECTION_FUNCTIONS as defined in svr3.h,
- but it can't hurt to define these macros for whatever systems use them. */
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
-/* This is machine-dependent
- because it needs to push something on the stack. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- fini_section (); \
- fputs (ASM_LONG, FILE); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
+#define TARGET_ASM_CONSTRUCTOR ix86_svr3_asm_out_constructor
/* A C statement or statements to switch to the appropriate
section for output of DECL. DECL is either a `VAR_DECL' node
@@ -262,31 +208,3 @@ dtors_section () \
go into the const section. */
#define SELECT_RTX_SECTION(MODE,RTX) const_section()
-
-/* This is copied from i386/sysv3.h. */
-
-/* Define a few machine-specific details of the implementation of
- constructors.
-
- The __CTORS_LIST__ goes in the .init section. Define CTOR_LIST_BEGIN
- and CTOR_LIST_END to contribute to the .init section an instruction to
- push a word containing 0 (or some equivalent of that).
-
- ASM_OUTPUT_CONSTRUCTOR should be defined to push the address of the
- constructor. */
-
-#undef INIT_SECTION_ASM_OP
-#define INIT_SECTION_ASM_OP "\t.section .init,\"x\""
-
-#define CTOR_LIST_BEGIN \
- asm (INIT_SECTION_ASM_OP); \
- asm ("pushl $0")
-#define CTOR_LIST_END CTOR_LIST_BEGIN
-
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- init_section (); \
- fprintf (FILE, "\tpushl $"); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
diff --git a/gcc/config/i386/sysv3.h b/gcc/config/i386/sysv3.h
index 9d73502..8eb4bec 100644
--- a/gcc/config/i386/sysv3.h
+++ b/gcc/config/i386/sysv3.h
@@ -102,10 +102,7 @@ Boston, MA 02111-1307, USA. */
The __CTORS_LIST__ goes in the .init section. Define CTOR_LIST_BEGIN
and CTOR_LIST_END to contribute to the .init section an instruction to
- push a word containing 0 (or some equivalent of that).
-
- ASM_OUTPUT_CONSTRUCTOR should be defined to push the address of the
- constructor. */
+ push a word containing 0 (or some equivalent of that). */
#undef INIT_SECTION_ASM_OP
#define INIT_SECTION_ASM_OP "\t.section .init,\"x\""
@@ -115,10 +112,4 @@ Boston, MA 02111-1307, USA. */
asm ("pushl $0")
#define CTOR_LIST_END CTOR_LIST_BEGIN
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- init_section (); \
- fprintf (FILE, "\tpushl $"); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
+#define TARGET_ASM_CONSTRUCTOR ix86_svr3_asm_out_constructor
diff --git a/gcc/config/i386/vsta.h b/gcc/config/i386/vsta.h
index e9479ef..1bb897d 100644
--- a/gcc/config/i386/vsta.h
+++ b/gcc/config/i386/vsta.h
@@ -27,51 +27,3 @@ Boston, MA 02111-1307, USA. */
#undef CPP_PREDEFINES
#endif
#define CPP_PREDEFINES "-Dunix -DVSTA -Asystem=unix -Asystem=vsta"
-
-#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_ctor, in_dtor
-
-#undef EXTRA_SECTION_FUNCTIONS
-#define EXTRA_SECTION_FUNCTIONS \
- CTOR_SECTION_FUNCTION \
- DTOR_SECTION_FUNCTION
-
-#define CTOR_SECTION_FUNCTION \
-void \
-ctor_section () \
-{ \
- if (in_section != in_ctor) \
- { \
- fprintf (asm_out_file, "\t.section .ctor\n"); \
- in_section = in_ctor; \
- } \
-}
-
-#define DTOR_SECTION_FUNCTION \
-void \
-dtor_section () \
-{ \
- if (in_section != in_dtor) \
- { \
- fprintf (asm_out_file, "\t.section .dtor\n"); \
- in_section = in_dtor; \
- } \
-}
-
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctor_section (); \
- fputs (ASM_LONG, FILE); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtor_section (); \
- fputs (ASM_LONG, FILE); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-
diff --git a/gcc/config/i386/win32.h b/gcc/config/i386/win32.h
index 7e03383..d2ab075 100644
--- a/gcc/config/i386/win32.h
+++ b/gcc/config/i386/win32.h
@@ -103,52 +103,6 @@ Boston, MA 02111-1307, USA. */
#define NEED_ATEXIT 1
-#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_ctor, in_dtor
-
-#undef EXTRA_SECTION_FUNCTIONS
-#define EXTRA_SECTION_FUNCTIONS \
- CTOR_SECTION_FUNCTION \
- DTOR_SECTION_FUNCTION
-
-#define CTOR_SECTION_FUNCTION \
-void \
-ctor_section () \
-{ \
- if (in_section != in_ctor) \
- { \
- fprintf (asm_out_file, "\t.section .ctor\n"); \
- in_section = in_ctor; \
- } \
-}
-
-#define DTOR_SECTION_FUNCTION \
-void \
-dtor_section () \
-{ \
- if (in_section != in_dtor) \
- { \
- fprintf (asm_out_file, "\t.section .dtor\n"); \
- in_section = in_dtor; \
- } \
-}
-
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctor_section (); \
- fputs (ASM_LONG, FILE); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtor_section (); \
- fputs (ASM_LONG, FILE); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
/* Define this macro if references to a symbol must be treated
differently depending on something about the variable or
function named by the symbol (such as what section it is in).
diff --git a/gcc/config/i960/i960-coff.h b/gcc/config/i960/i960-coff.h
index b1fed12..7f46215 100644
--- a/gcc/config/i960/i960-coff.h
+++ b/gcc/config/i960/i960-coff.h
@@ -41,61 +41,6 @@ Boston, MA 02111-1307, USA. */
#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"x\""
#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"x\""
-/* A list of other sections which the compiler might be "in" at any
- given time. */
-
-#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_ctors, in_dtors
-
-/* A list of extra section function definitions. */
-
-#undef EXTRA_SECTION_FUNCTIONS
-#define EXTRA_SECTION_FUNCTIONS \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
-
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
#define INT_ASM_OP "\t.word\t"
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
/* end of i960-coff.h */
diff --git a/gcc/config/ia64/sysv4.h b/gcc/config/ia64/sysv4.h
index ea9eb2f..3902072 100644
--- a/gcc/config/ia64/sysv4.h
+++ b/gcc/config/ia64/sysv4.h
@@ -83,46 +83,6 @@ do { \
#define INIT_SECTION_ASM_OP "\t.section\t.init,\"ax\",\"progbits\""
#undef FINI_SECTION_ASM_OP
#define FINI_SECTION_ASM_OP "\t.section\t.fini,\"ax\",\"progbits\""
-#undef CTORS_SECTION_ASM_OP
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\",\"progbits\""
-#undef DTORS_SECTION_ASM_OP
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\",\"progbits\""
-
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-/* Must override this to get @fptr relocation. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- if (TARGET_NO_PIC || TARGET_AUTO_PIC) \
- fputs ("\tdata8\t ", FILE); \
- else \
- fputs ("\tdata8\t @fptr(", FILE); \
- assemble_name (FILE, NAME); \
- if (TARGET_NO_PIC || TARGET_AUTO_PIC) \
- fputs ("\n", FILE); \
- else \
- fputs (")\n", FILE); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-/* Must override this to get @fptr relocation. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- if (TARGET_NO_PIC || TARGET_AUTO_PIC) \
- fputs ("\tdata8\t ", FILE); \
- else \
- fputs ("\tdata8\t @fptr(", FILE); \
- assemble_name (FILE, NAME); \
- if (TARGET_NO_PIC || TARGET_AUTO_PIC) \
- fputs ("\n", FILE); \
- else \
- fputs (")\n", FILE); \
- } while (0)
/* svr4.h undefines this, so we need to define it here. */
#define DBX_REGISTER_NUMBER(REGNO) \
@@ -238,13 +198,11 @@ extern unsigned int ia64_section_threshold;
}
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_sdata, in_sbss
+#define EXTRA_SECTIONS in_const, in_sdata, in_sbss
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
CONST_SECTION_FUNCTION \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION \
SDATA_SECTION_FUNCTION \
SBSS_SECTION_FUNCTION
diff --git a/gcc/config/lynx.h b/gcc/config/lynx.h
index 7769be5..a0594d8 100644
--- a/gcc/config/lynx.h
+++ b/gcc/config/lynx.h
@@ -128,13 +128,11 @@ do { \
#undef INIT_SECTION_ASM_OP
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_fini
+#define EXTRA_SECTIONS in_const, in_fini
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
CONST_SECTION_FUNCTION \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION \
FINI_SECTION_FUNCTION
#undef CTORS_SECTION_ASM_OP
@@ -144,28 +142,6 @@ do { \
#define INT_ASM_OP "\t.long\t"
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
#undef DO_GLOBAL_CTORS_BODY
#undef DO_GLOBAL_DTORS_BODY
diff --git a/gcc/config/m68hc11/m68hc11.c b/gcc/config/m68hc11/m68hc11.c
index 119d8ee..04516fe 100644
--- a/gcc/config/m68hc11/m68hc11.c
+++ b/gcc/config/m68hc11/m68hc11.c
@@ -74,6 +74,8 @@ static void m68hc11_add_gc_roots PARAMS ((void));
static void asm_print_register PARAMS ((FILE *, int));
static void m68hc11_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
+static void m68hc11_asm_out_constructor PARAMS ((rtx, int));
+static void m68hc11_asm_out_destructor PARAMS ((rtx, int));
rtx m68hc11_soft_tmp_reg;
@@ -5254,3 +5256,21 @@ m68hc11_add_gc_roots ()
ggc_add_rtx_root (&stack_push_word, 1);
ggc_add_rtx_root (&stack_pop_word, 1);
}
+
+static void
+m68hc11_asm_out_constructor (symbol, priority)
+ rtx symbol;
+ int priority;
+{
+ default_ctor_section_asm_out_constructor (symbol, priority);
+ fprintf (asm_out_file, "\t.globl\t__do_global_ctors\n");
+}
+
+static void
+m68hc11_asm_out_destructor (symbol, priority)
+ rtx symbol;
+ int priority;
+{
+ default_dtor_section_asm_out_destructor (symbol, priority);
+ fprintf (asm_out_file, "\t.globl\t__do_global_dtors\n");
+}
diff --git a/gcc/config/m68hc11/m68hc11.h b/gcc/config/m68hc11/m68hc11.h
index 777fb88..5697a6a 100644
--- a/gcc/config/m68hc11/m68hc11.h
+++ b/gcc/config/m68hc11/m68hc11.h
@@ -1582,8 +1582,7 @@ do { \
/* This is the pseudo-op used to generate a reference to a specific
symbol in some section. It is only used in machine-specific
- configuration files, typically only in ASM_OUTPUT_CONSTRUCTOR and
- ASM_OUTPUT_DESTRUCTOR. This is the same for all known svr4
+ configuration files. This is the same for all known svr4
assemblers, except those in targets that don't use 32-bit pointers.
Those should override INT_ASM_OP. Yes, the name of the macro is
misleading. */
@@ -1600,31 +1599,8 @@ do { \
#undef DTORS_SECTION_ASM_OP
#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"a\""
-#undef CTORS_SECTION_FUNCTION
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "\t.globl\t__do_global_ctors\n"); \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#undef DTORS_SECTION_FUNCTION
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "\t.globl\t__do_global_dtors\n"); \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
+#define TARGET_ASM_CONSTRUCTOR m68hc11_asm_out_constructor
+#define TARGET_ASM_DESTRUCTOR m68hc11_asm_out_destructor
/* This is how to begin an assembly language file. Most svr4 assemblers want
at least a .file directive to come first, and some want to see a .version
diff --git a/gcc/config/m68k/auxgas.h b/gcc/config/m68k/auxgas.h
index c3c7635..28d9f9e 100644
--- a/gcc/config/m68k/auxgas.h
+++ b/gcc/config/m68k/auxgas.h
@@ -32,8 +32,6 @@ Boston, MA 02111-1307, USA. */
fprintf (FILE, "\t.ident \"%s\"\n", NAME);
#ifdef USE_COLLECT2
-#undef ASM_OUTPUT_CONSTRUCTOR
-#undef ASM_OUTPUT_DESTRUCTOR
/* for the sake of link-level compatibility with /bin/as version */
#define NO_DOLLAR_IN_LABEL
#define NO_DOT_IN_LABEL
diff --git a/gcc/config/m68k/coff.h b/gcc/config/m68k/coff.h
index 8a63c6c..946f196 100644
--- a/gcc/config/m68k/coff.h
+++ b/gcc/config/m68k/coff.h
@@ -104,68 +104,8 @@ Boston, MA 02111-1307, USA. */
#undef TARGET_ASM_NAMED_SECTION
#define TARGET_ASM_NAMED_SECTION m68k_coff_asm_named_section
-/* Support the ctors and dtors sections for g++. */
-
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"x\""
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"x\""
-
-/* A list of other sections which the compiler might be "in" at any
- given time. */
-
-#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_ctors, in_dtors
-
-/* A list of extra section function definitions. */
-
-#undef EXTRA_SECTION_FUNCTIONS
-#define EXTRA_SECTION_FUNCTIONS \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
-
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
#define INT_ASM_OP "\t.long\t"
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
/* Don't assume anything about startfiles. */
#undef STARTFILE_SPEC
diff --git a/gcc/config/m68k/dpx2.h b/gcc/config/m68k/dpx2.h
index 886a34b..bb1c498 100644
--- a/gcc/config/m68k/dpx2.h
+++ b/gcc/config/m68k/dpx2.h
@@ -31,6 +31,21 @@ Boston, MA 02111-1307, USA. */
#undef SELECT_RTX_SECTION
#include "svr3.h"
+/* We use collect2 instead of ctors_section constructors. */
+#undef INIT_SECTION_ASM_OP
+#undef FINI_SECTION_ASM_OP
+#undef DTORS_SECTION_ASM_OP
+#undef DO_GLOBAL_CTORS_BODY
+
+/* Remove handling for a separate constant data section. We put
+ constant data in text_section, which is the default. */
+#undef SELECT_SECTION
+#undef SELECT_RTX_SECTION
+#undef EXTRA_SECTIONS
+#undef EXTRA_SECTION_FUNCTIONS
+#undef CONST_SECTION_ASM_OP
+#undef READONLY_DATA_SECTION
+
#define DPX2
/* See m68k.h. 7 means 68020 with 68881.
@@ -84,24 +99,11 @@ Boston, MA 02111-1307, USA. */
/* The native assembler doesn't support fmovecr. */
#define NO_ASM_FMOVECR
-#undef EXTRA_SECTIONS
-#undef EXTRA_SECTION_FUNCTIONS
-#undef READONLY_DATA_SECTION
-#define READONLY_DATA_SECTION data_section
-#undef SELECT_SECTION
-#undef SELECT_RTX_SECTION
-#define fini_section() while (0)
-
-#undef CTORS_SECTION_ASM_OP
-#define CTORS_SECTION_ASM_OP "\tsection 15"
-#undef DTORS_SECTION_ASM_OP
-#define DTORS_SECTION_ASM_OP "\tsection 15"
-#undef INIT_SECTION_ASM_OP
-#define BSS_SECTION_ASM_OP "\tsection 14"
#undef TEXT_SECTION_ASM_OP
-#define TEXT_SECTION_ASM_OP "\tsection 10"
+#define TEXT_SECTION_ASM_OP "\tsection 10"
#undef DATA_SECTION_ASM_OP
-#define DATA_SECTION_ASM_OP "\tsection 15"
+#define DATA_SECTION_ASM_OP "\tsection 15"
+#define BSS_SECTION_ASM_OP "\tsection 14"
/* Don't try using XFmode. */
diff --git a/gcc/config/m68k/dpx2g.h b/gcc/config/m68k/dpx2g.h
index ea5cd13..ecf00fc 100644
--- a/gcc/config/m68k/dpx2g.h
+++ b/gcc/config/m68k/dpx2g.h
@@ -5,49 +5,11 @@
#define USE_GAS
#include "m68k/dpx2.h"
-#if 0 /* #ifndef USE_COLLECT2 */
-
-/* We use set vectors for the constructors/destructors. */
-
-#undef ASM_OUTPUT_CONSTRUCTOR
-#undef ASM_OUTPUT_DESTRUCTOR
-
-/* Although the gas we use can create .ctor and .dtor sections from N_SETT
- stabs, it does not support section directives, so we need to have the loader
- define the lists.
- */
-#define CTOR_LISTS_DEFINED_EXTERNALLY
-
-/* similar to default, but allows for the table defined by ld with gcc.ifile.
- nptrs is always 0. So we need to instead check that __DTOR_LIST__[1] != 0.
- The old check is left in so that the same macro can be used if and when
- a future version of gas does support section directives. */
-
-#define DO_GLOBAL_DTORS_BODY {int nptrs = *(int *)__DTOR_LIST__; int i; \
- if (nptrs == -1 || (__DTOR_LIST__[0] == 0 && __DTOR_LIST__[1] != 0)) \
- for (nptrs = 0; __DTOR_LIST__[nptrs + 1] != 0; nptrs++); \
- for (i = nptrs; i >= 1; i--) \
- __DTOR_LIST__[i] (); }
-
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC \
- "%{!r:gcc.ifile%s}\
- %{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}\
- huge.o%s"
-
-#endif /* !USE_COLLECT2 */
-
#undef STARTFILE_SPEC
#define STARTFILE_SPEC \
"%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}\
huge.o%s"
-
-/*
- * we are using GAS
- */
-#undef EXTRA_SECTION_FUNCTIONS
-#undef EXTRA_SECTIONS
/* Gas understands dollars in labels. */
#undef NO_DOLLAR_IN_LABEL
/* GAS does not understand .ident so don't output anything for #ident. */
@@ -56,16 +18,4 @@
#undef ASM_LONG
#define ASM_LONG "\t.long"
-/*
- * put const's in the text section
- */
-#define const_section() text_section()
-#define fini_section() while (0)
-
-#undef CTORS_SECTION_ASM_OP
-#define CTORS_SECTION_ASM_OP "\t.data"
-#undef DTORS_SECTION_ASM_OP
-#define DTORS_SECTION_ASM_OP "\t.data"
-#undef INIT_SECTION_ASM_OP
-
/* end of dpx2g.h */
diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c
index b18c07c..b03c29e 100644
--- a/gcc/config/m68k/m68k.c
+++ b/gcc/config/m68k/m68k.c
@@ -38,6 +38,7 @@ Boston, MA 02111-1307, USA. */
#include "tm_p.h"
#include "target.h"
#include "target-def.h"
+#include "debug.h"
/* Needed for use_return_insn. */
#include "flags.h"
@@ -62,6 +63,9 @@ static void m68k_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
static void m68k_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
static void m68k_coff_asm_named_section PARAMS ((const char *, unsigned int,
unsigned int));
+#ifdef INIT_SECTION_ASM_OP
+static void m68k_svr3_asm_out_constructor PARAMS ((rtx, int));
+#endif
/* Alignment to use for loops and jumps */
@@ -4228,3 +4232,19 @@ m68k_coff_asm_named_section (name, flags, align)
fprintf (asm_out_file, "\t.section\t%s,\"%c\"\n", name, flagchar);
}
+
+#ifdef INIT_SECTION_ASM_OP
+static void
+m68k_svr3_asm_out_constructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ rtx xop[2];
+
+ xop[1] = symbol;
+ xop[0] = gen_rtx_MEM (SImode, gen_rtx_PRE_DEC (SImode, stack_pointer_rtx));
+
+ init_section ();
+ output_asm_insn (output_move_simode (xop), xop);
+}
+#endif
diff --git a/gcc/config/m68k/mot3300.h b/gcc/config/m68k/mot3300.h
index fd91481..5cfe659 100644
--- a/gcc/config/m68k/mot3300.h
+++ b/gcc/config/m68k/mot3300.h
@@ -196,61 +196,6 @@ Boston, MA 02111-1307, USA. */
#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"x\""
#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"x\""
-
-/* A list of other sections which the compiler might be "in" at any
- given time. */
-
-#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_ctors, in_dtors
-
-/* A list of extra section function definitions. */
-
-#undef EXTRA_SECTION_FUNCTIONS
-#define EXTRA_SECTION_FUNCTIONS \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
-
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "\t%s\t ", ASM_LONG); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "\t%s\t ", ASM_LONG); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
#endif /* defined (USE_GLD) */
/* The file command should always begin the output. */
diff --git a/gcc/config/m68k/tower-as.h b/gcc/config/m68k/tower-as.h
index bb03b05..4679738 100644
--- a/gcc/config/m68k/tower-as.h
+++ b/gcc/config/m68k/tower-as.h
@@ -82,8 +82,8 @@ Boston, MA 02111-1307, USA. */
#define ASM_OUTPUT_SOURCE_LINE(FILE, LINENO) \
fprintf (FILE, "\tln\t%d\n", \
- (sdb_begin_function_line \
- ? last_linenum - sdb_begin_function_line : 1))
+ (sdb_begin_function_line > -1 \
+ ? (LINENO) - sdb_begin_function_line : 1))
#undef ASM_OUTPUT_IDENT
#define ASM_OUTPUT_IDENT(FILE, NAME) \
@@ -581,10 +581,7 @@ do { fprintf (asm_out_file, "\ttag\t"); \
The __CTORS_LIST__ goes in the .init section. Define CTOR_LIST_BEGIN
and CTOR_LIST_END to contribute to the .init section an instruction to
- push a word containing 0 (or some equivalent of that).
-
- ASM_OUTPUT_CONSTRUCTOR should be defined
- to push the address of the constructor. */
+ push a word containing 0 (or some equivalent of that). */
#define ASM_LONG "\tlong"
#undef INIT_SECTION_ASM_OP
@@ -601,10 +598,4 @@ do { fprintf (asm_out_file, "\ttag\t"); \
#define BSS_SECTION_ASM_OP "\tsection\t~bss"
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- init_section (); \
- fprintf (FILE, "\tmov.l &"); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, ",-(%%sp)\n"); \
- } while (0)
+#define TARGET_ASM_CONSTRUCTOR m68k_svr3_asm_out_constructor
diff --git a/gcc/config/m88k/m88k.c b/gcc/config/m88k/m88k.c
index 4ece2d6..f77aa47 100644
--- a/gcc/config/m88k/m88k.c
+++ b/gcc/config/m88k/m88k.c
@@ -67,6 +67,10 @@ static void m88k_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
static void m88k_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT));
static void m88k_output_function_end_prologue PARAMS ((FILE *));
static void m88k_output_function_begin_epilogue PARAMS ((FILE *));
+#ifdef INIT_SECTION_ASM_OP
+static void m88k_svr3_asm_out_constructor PARAMS ((rtx, int));
+static void m88k_svr3_asm_out_destructor PARAMS ((rtx, int));
+#endif
/* Initialize the GCC target structure. */
#undef TARGET_ASM_FUNCTION_PROLOGUE
@@ -1891,15 +1895,10 @@ m88k_layout_frame ()
int need
= ((m88k_stack_size ? STACK_UNIT_BOUNDARY - STARTING_FRAME_OFFSET : 0)
- (frame_size % STACK_UNIT_BOUNDARY));
- if (need)
- {
- if (need < 0)
- need += STACK_UNIT_BOUNDARY;
- (void) assign_stack_local (BLKmode, need, BITS_PER_UNIT);
- frame_size = get_frame_size ();
- }
+ if (need < 0)
+ need += STACK_UNIT_BOUNDARY;
m88k_stack_size
- = ROUND_CALL_BLOCK_SIZE (m88k_stack_size + frame_size
+ = ROUND_CALL_BLOCK_SIZE (m88k_stack_size + frame_size + need
+ current_function_pretend_args_size);
}
}
@@ -3285,3 +3284,34 @@ symbolic_operand (op, mode)
return 0;
}
}
+
+#ifdef INIT_SECTION_ASM_OP
+static void
+m88k_svr3_asm_out_constructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ const char *name = XSTR (symbol, 0);
+
+ init_section ();
+ fprintf (asm_out_file, "\tor.u\t r13,r0,hi16(");
+ assemble_name (asm_out_file, name);
+ fprintf (asm_out_file, ")\n\tor\t r13,r13,lo16(");
+ assemble_name (asm_out_file, name);
+ fprintf (asm_out_file, ")\n\tsubu\t r31,r31,%d\n\tst\t r13,r31,%d\n",
+ STACK_BOUNDARY / BITS_PER_UNIT, REG_PARM_STACK_SPACE (0));
+}
+
+static void
+m88k_svr3_asm_out_destructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ int i;
+
+ fini_section ();
+ assemble_integer (symbol, UNITS_PER_WORD, 1);
+ for (i = 1; i < 4; i++)
+ assemble_integer (constm1_rtx, UNITS_PER_WORD, 1);
+}
+#endif
diff --git a/gcc/config/m88k/m88k.h b/gcc/config/m88k/m88k.h
index 81358f7..1f7304c 100644
--- a/gcc/config/m88k/m88k.h
+++ b/gcc/config/m88k/m88k.h
@@ -2438,15 +2438,14 @@ do { \
#if defined(USING_SVR4_H)
-#define EXTRA_SECTIONS in_const, in_tdesc, in_sdata, in_ctors, in_dtors
+#define EXTRA_SECTIONS in_const, in_tdesc, in_sdata
#define INIT_SECTION_FUNCTION
#define FINI_SECTION_FUNCTION
#else
#if defined(USING_SVR3_H)
-#define EXTRA_SECTIONS in_const, in_tdesc, in_sdata, in_ctors, in_dtors, \
- in_init, in_fini
+#define EXTRA_SECTIONS in_const, in_tdesc, in_sdata, in_init, in_fini
#else /* luna or other not based on svr[34].h. */
@@ -2458,8 +2457,6 @@ const_section () \
{ \
text_section(); \
}
-#define CTORS_SECTION_FUNCTION
-#define DTORS_SECTION_FUNCTION
#define INIT_SECTION_FUNCTION
#define FINI_SECTION_FUNCTION
@@ -2490,8 +2487,6 @@ sdata_section () \
} \
} \
\
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION \
INIT_SECTION_FUNCTION \
FINI_SECTION_FUNCTION
diff --git a/gcc/config/m88k/sysv3.h b/gcc/config/m88k/sysv3.h
index 9986f62..bd9f4a1 100644
--- a/gcc/config/m88k/sysv3.h
+++ b/gcc/config/m88k/sysv3.h
@@ -76,20 +76,8 @@ Boston, MA 02111-1307, USA. */
asm ("\tst\t r0,r31,32"); /* REG_PARM_STACK_SPACE (0) == 32 */
#define CTOR_LIST_END
-/* ASM_OUTPUT_CONSTRUCTOR outputs code into the .init section to push the
- address of the constructor. This becomes the body of __do_global_ctors
- in crtstuff.c. r13 is a temporary register. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- init_section (); \
- fprintf (FILE, "\tor.u\t r13,r0,hi16("); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, ")\n\tor\t r13,r13,lo16("); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, ")\n\tsubu\t r31,r31,%d\n\tst\t r13,r31,%d\n", \
- STACK_BOUNDARY / BITS_PER_UNIT, REG_PARM_STACK_SPACE (0)); \
- } while (0)
+#define TARGET_ASM_CONSTRUCTOR m88k_svr3_asm_out_constructor
+#define TARGET_ASM_DESTRUCTOR m88k_svr3_asm_out_destructor
#undef DO_GLOBAL_CTORS_BODY
#define DO_GLOBAL_CTORS_BODY \
@@ -108,25 +96,6 @@ do { \
func_ptr __DTOR_END__[4] = { (func_ptr) 0, (func_ptr) 0, \
(func_ptr) 0, (func_ptr) 0 }
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. The table is constructed in the .fini section
- so that an explicit linker script is not required. The complication
- is that this section is padded with NOP instructions and to either
- 8 or 16 byte alignment depending on the specific system. A clever
- way to avoid trouble is to output a block of 16 bytes where the
- extra words are known values (-1). */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- register int i; \
- fini_section (); \
- fprintf (FILE, "\t%s\t ", ASM_LONG); \
- assemble_name (FILE,NAME); \
- fprintf (FILE, "\n"); \
- for (i = 1; i < 4; i++) \
- fprintf (FILE, "\t%s\t -1\n", ASM_LONG); \
- } while (0)
-
/* Walk the list looking for the terminating zero and ignoring all values of
-1. */
#undef DO_GLOBAL_DTORS_BODY
diff --git a/gcc/config/mcore/mcore-pe.h b/gcc/config/mcore/mcore-pe.h
index 2d0c195..2362b52 100644
--- a/gcc/config/mcore/mcore-pe.h
+++ b/gcc/config/mcore/mcore-pe.h
@@ -183,43 +183,15 @@ rdata_section () \
#define STARTFILE_SPEC "crt0.o%s"
#define ENDFILE_SPEC "%{!mno-lsim:-lsim}"
-#undef CTORS_SECTION_ASM_OP
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"x\""
-#undef DTORS_SECTION_ASM_OP
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"x\""
-
#define INT_ASM_OP "\t.long\t"
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(STREAM, NAME) \
- do \
- { \
- ctors_section (); \
- fprintf (STREAM, "%s", INT_ASM_OP); \
- assemble_name (STREAM, NAME); \
- fprintf (STREAM, "\n"); \
- } \
- while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(STREAM, NAME) \
- do \
- { \
- dtors_section (); \
- fprintf (STREAM, "%s", INT_ASM_OP); \
- assemble_name (STREAM, NAME); \
- fprintf (STREAM, "\n"); \
- } \
- while (0)
-
/* __CTOR_LIST__ and __DTOR_LIST__ must be defined by the linker script. */
#define CTOR_LISTS_DEFINED_EXTERNALLY
#undef DO_GLOBAL_CTORS_BODY
#undef DO_GLOBAL_DTORS_BODY
#undef INIT_SECTION_ASM_OP
+#undef DTORS_SECTION_ASM_OP
#define SUPPORTS_ONE_ONLY 1
diff --git a/gcc/config/mcore/mcore.h b/gcc/config/mcore/mcore.h
index 3cd595e..5974ab8 100644
--- a/gcc/config/mcore/mcore.h
+++ b/gcc/config/mcore/mcore.h
@@ -1080,39 +1080,13 @@ extern enum reg_class reg_class_from_letter[];
#define DATA_SECTION_ASM_OP "\t.data"
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_ctors, in_dtors, SUBTARGET_EXTRA_SECTIONS
+#define EXTRA_SECTIONS SUBTARGET_EXTRA_SECTIONS
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION \
SUBTARGET_EXTRA_SECTION_FUNCTIONS \
SWITCH_SECTION_FUNCTION
-#ifndef CTORS_SECTION_FUNCTION
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-#endif
-
/* Switch to SECTION (an `enum in_section').
??? This facility should be provided by GCC proper.
@@ -1130,8 +1104,6 @@ switch_to_section (section, decl) \
case in_text: text_section (); break; \
case in_data: data_section (); break; \
case in_named: named_section (decl, NULL, 0); break; \
- case in_ctors: ctors_section (); break; \
- case in_dtors: dtors_section (); break; \
SUBTARGET_SWITCH_SECTIONS \
default: abort (); break; \
} \
diff --git a/gcc/config/mips/elf.h b/gcc/config/mips/elf.h
index 4b88363..aa094b6 100644
--- a/gcc/config/mips/elf.h
+++ b/gcc/config/mips/elf.h
@@ -200,29 +200,6 @@ do { \
#define UNIQUE_SECTION(DECL,RELOC) \
mips_unique_section ((DECL), (RELOC))
-/* Support the ctors/dtors and other sections. */
-
-/* Define the names of and pseudo-ops used to switch to the .ctors and
- .dtors sections.
-
- Note that we want to give these sections the SHF_WRITE attribute
- because these sections will actually contain data (i.e. tables of
- addresses of functions in the current root executable or shared library
- file) and, in the case of a shared library, the relocatable addresses
- will have to be properly resolved/relocated (and then written into) by
- the dynamic linker when it actually attaches the given shared library
- to the executing process. (Note that on SVR4, you may wish to use the
- `-z text' option to the ELF linker, when building a shared library, as
- an additional check that you are doing everything right. But if you do
- use the `-z text' option when building a shared library, you will get
- errors unless the .ctors and .dtors sections are marked as writable
- via the SHF_WRITE attribute.) */
-
-#define CTORS_SECTION_NAME ".ctors"
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
-#define DTORS_SECTION_NAME ".dtors"
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
-
/* There's no point providing a default definition of __CTOR_LIST__
since people are expected either to use crtbegin.o, or an equivalent,
or provide their own definition. */
@@ -231,7 +208,7 @@ do { \
/* A list of other sections which the compiler might be "in" at any
given time. */
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_sdata, in_sbss, in_rdata, in_ctors, in_dtors
+#define EXTRA_SECTIONS in_sdata, in_sbss, in_rdata
#define INVOKE__main
@@ -239,9 +216,7 @@ do { \
#define EXTRA_SECTION_FUNCTIONS \
SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) \
- SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP) \
- SECTION_FUNCTION_TEMPLATE(ctors_section, in_ctors, CTORS_SECTION_ASM_OP) \
- SECTION_FUNCTION_TEMPLATE(dtors_section, in_dtors, DTORS_SECTION_ASM_OP)
+ SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP)
#define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
void FN () \
@@ -253,46 +228,6 @@ void FN () \
} \
}
-
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word"); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word"); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-#define CTOR_LIST_BEGIN \
-func_ptr __CTOR_LIST__ __attribute__((section(CTORS_SECTION_NAME))) = \
- (func_ptr) (-1)
-
-#define CTOR_LIST_END \
-func_ptr __CTOR_END__ __attribute__((section(CTORS_SECTION_NAME))) = \
- (func_ptr) 0
-
-#define DTOR_LIST_BEGIN \
-func_ptr __DTOR_LIST__ __attribute__((section(DTORS_SECTION_NAME))) = \
- (func_ptr) (-1)
-
-#define DTOR_LIST_END \
-func_ptr __DTOR_END__ __attribute__((section(DTORS_SECTION_NAME))) = \
- (func_ptr) 0
-
/* Don't set the target flags, this is done by the linker script */
#undef LIB_SPEC
#define LIB_SPEC ""
diff --git a/gcc/config/mips/elf64.h b/gcc/config/mips/elf64.h
index 782c62b..c9bcd3e 100644
--- a/gcc/config/mips/elf64.h
+++ b/gcc/config/mips/elf64.h
@@ -243,29 +243,6 @@ do { \
DECL_SECTION_NAME (DECL) = build_string (len, string); \
} while (0)
-/* Support the ctors/dtors and other sections. */
-
-/* Define the names of and pseudo-ops used to switch to the .ctors and
- .dtors sections.
-
- Note that we want to give these sections the SHF_WRITE attribute
- because these sections will actually contain data (i.e. tables of
- addresses of functions in the current root executable or shared library
- file) and, in the case of a shared library, the relocatable addresses
- will have to be properly resolved/relocated (and then written into) by
- the dynamic linker when it actually attaches the given shared library
- to the executing process. (Note that on SVR4, you may wish to use the
- `-z text' option to the ELF linker, when building a shared library, as
- an additional check that you are doing everything right. But if you do
- use the `-z text' option when building a shared library, you will get
- errors unless the .ctors and .dtors sections are marked as writable
- via the SHF_WRITE attribute.) */
-
-#define CTORS_SECTION_NAME ".ctors"
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
-#define DTORS_SECTION_NAME ".dtors"
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
-
/* There's no point providing a default definition of __CTOR_LIST__
since people are expected either to use crtbegin.o, or an equivalent,
or provide their own definition. */
@@ -274,16 +251,14 @@ do { \
/* A list of other sections which the compiler might be "in" at any
given time. */
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_sdata, in_rdata, in_ctors, in_dtors
+#define EXTRA_SECTIONS in_sdata, in_rdata
#define INVOKE__main
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
- SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP) \
- SECTION_FUNCTION_TEMPLATE(ctors_section, in_ctors, CTORS_SECTION_ASM_OP) \
- SECTION_FUNCTION_TEMPLATE(dtors_section, in_dtors, DTORS_SECTION_ASM_OP)
+ SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP)
#define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \
void FN () \
@@ -294,47 +269,6 @@ void FN () \
in_section = ENUM; \
} \
}
-
-
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "\t%s\t", (Pmode == SImode) ? ".word" : ".dword"); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "\t%s\t", (Pmode == SImode) ? ".word" : ".dword"); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-#define CTOR_LIST_BEGIN \
-func_ptr __CTOR_LIST__ __attribute__((section(CTORS_SECTION_NAME))) = \
- (func_ptr) (-1)
-
-#define CTOR_LIST_END \
-func_ptr __CTOR_END__ __attribute__((section(CTORS_SECTION_NAME))) = \
- (func_ptr) 0
-
-#define DTOR_LIST_BEGIN \
-func_ptr __DTOR_LIST__ __attribute__((section(DTORS_SECTION_NAME))) = \
- (func_ptr) (-1)
-
-#define DTOR_LIST_END \
-func_ptr __DTOR_END__ __attribute__((section(DTORS_SECTION_NAME))) = \
- (func_ptr) 0
-
/* Don't set the target flags, this is done by the linker script */
#undef LIB_SPEC
#define LIB_SPEC ""
diff --git a/gcc/config/mips/iris6.h b/gcc/config/mips/iris6.h
index 4e3a227..ee33487 100644
--- a/gcc/config/mips/iris6.h
+++ b/gcc/config/mips/iris6.h
@@ -242,8 +242,6 @@ Boston, MA 02111-1307, USA. */
#undef SUBTARGET_ASM_OPTIMIZING_SPEC
#define SUBTARGET_ASM_OPTIMIZING_SPEC "-O0"
-/* Stuff for constructors. Start here. */
-
/* The assembler now accepts .section pseudo-ops, but it does not allow
one to change the section in the middle of a function, so we can't use
the INIT_SECTION_ASM_OP code in crtstuff. But we can build up the ctor
@@ -254,38 +252,13 @@ Boston, MA 02111-1307, USA. */
#define CONST_SECTION_ASM_OP_32 "\t.rdata"
#define CONST_SECTION_ASM_OP_64 "\t.section\t.rodata"
-/* The IRIX 6 assembler .section directive takes four additional args:
- section type, flags, entry size, and alignment. The alignment of the
- .ctors and .dtors sections needs to be the same as the size of a pointer
- so that the linker doesn't add padding between elements. */
-#if defined (CRT_BEGIN) || defined (CRT_END)
-
-/* If we are included from crtstuff.c, these need to be plain strings.
- _MIPS_SZPTR is defined in SUBTARGET_CPP_SPEC above. */
-#if _MIPS_SZPTR == 64
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,1,2,0,8"
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,1,2,0,8"
-#else /* _MIPS_SZPTR != 64 */
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,1,2,0,4"
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,1,2,0,4"
-#endif /* _MIPS_SZPTR == 64 */
-
-#else /* ! (defined (CRT_BEGIN) || defined (CRT_END)) */
-
-/* If we are included from varasm.c, these need to depend on -mabi. */
-#define CTORS_SECTION_ASM_OP \
- (Pmode == DImode ? "\t.section\t.ctors,1,2,0,8" : "\t.section\t.ctors,1,2,0,4")
-#define DTORS_SECTION_ASM_OP \
- (Pmode == DImode ? "\t.section\t.dtors,1,2,0,8" : "\t.section\t.dtors,1,2,0,4")
-#endif /* defined (CRT_BEGIN) || defined (CRT_END) */
-
/* A default list of other sections which we might be "in" at any given
time. For targets that use additional sections (e.g. .tdesc) you
should override this definition in the target-specific file which
includes this file. */
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_sdata, in_rdata, in_const, in_ctors, in_dtors
+#define EXTRA_SECTIONS in_sdata, in_rdata, in_const
/* A default list of extra section function definitions. For targets
that use additional sections (e.g. .tdesc) you should override this
@@ -316,60 +289,12 @@ rdata_section () \
fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP_32); \
in_section = in_rdata; \
} \
-} \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
-
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
}
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "\t%s\t ", \
- (Pmode == DImode) ? ".dword" : ".word"); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "\t%s\t ", \
- (Pmode == DImode) ? ".dword" : ".word"); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
/* Switch into a generic section. */
#undef TARGET_ASM_NAMED_SECTION
#define TARGET_ASM_NAMED_SECTION iris6_asm_named_section
-/* Stuff for constructors. End here. */
-
/* ??? Perhaps just include svr4.h in this file? */
/* ??? SGI assembler may core dump when compiling with -g.
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index b917a78..c441198 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -1312,19 +1312,6 @@ do { \
#define OBJECT_FORMAT_COFF /* Object file looks like COFF */
#define EXTENDED_COFF /* ECOFF, not normal coff */
#endif
-
-#if 0 /* These definitions normally have no effect because
- MIPS systems define USE_COLLECT2, so
- assemble_constructor does nothing anyway. */
-
-/* Don't use the default definitions, because we don't have gld.
- Also, we don't want stabs when generating ECOFF output.
- Instead we depend on collect to handle these. */
-
-#define ASM_OUTPUT_CONSTRUCTOR(file, name)
-#define ASM_OUTPUT_DESTRUCTOR(file, name)
-
-#endif /* 0 */
/* Target machine storage layout */
diff --git a/gcc/config/mips/rtems64.h b/gcc/config/mips/rtems64.h
index ccec732..7a455e5 100644
--- a/gcc/config/mips/rtems64.h
+++ b/gcc/config/mips/rtems64.h
@@ -30,13 +30,6 @@ Boston, MA 02111-1307, USA. */
#define TARGET_MEM_FUNCTIONS
#endif
-/* Undefine the following which were defined in elf64.h. This will cause the rtems64
- port to continue to use collect2 for constructors/destructors. These may be removed
- when .ctor/.dtor section support is desired. */
-
-#undef CTORS_SECTION_ASM_OP
-#undef DTORS_SECTION_ASM_OP
-
#undef EXTRA_SECTIONS
#define EXTRA_SECTIONS in_sdata, in_rdata
@@ -49,14 +42,6 @@ Boston, MA 02111-1307, USA. */
SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP)
-#undef ASM_OUTPUT_CONSTRUCTOR
-#undef ASM_OUTPUT_DESTRUCTOR
-
-#undef CTOR_LIST_BEGIN
-#undef CTOR_LIST_END
-#undef DTOR_LIST_BEGIN
-#undef DTOR_LIST_END
-
#undef STARTFILE_SPEC
#undef ENDFILE_SPEC
diff --git a/gcc/config/mips/vxworks.h b/gcc/config/mips/vxworks.h
index 7d48662..ec6e13b 100644
--- a/gcc/config/mips/vxworks.h
+++ b/gcc/config/mips/vxworks.h
@@ -17,13 +17,6 @@ along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-/* Undefine the following which were defined in elf.h. Thise will cause the mips-vxworks
- port to continue to use collect2 for constructors/destructors. This entire file may
- be removed when .ctor/.dtor section support is desired. */
-
-#undef CTORS_SECTION_ASM_OP
-#undef DTORS_SECTION_ASM_OP
-
#undef EXTRA_SECTIONS
#define EXTRA_SECTIONS in_sdata, in_rdata, in_sbss
@@ -37,15 +30,5 @@ Boston, MA 02111-1307, USA. */
SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) \
SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP)
-#undef ASM_OUTPUT_CONSTRUCTOR
-#undef ASM_OUTPUT_DESTRUCTOR
-
-#undef CTOR_LIST_BEGIN
-#undef CTOR_LIST_END
-#undef DTOR_LIST_BEGIN
-#undef DTOR_LIST_END
-
#undef STARTFILE_SPEC
#undef ENDFILE_SPEC
-
-/* End of undefines to turn off .ctor/.dtor section support */
diff --git a/gcc/config/netware.h b/gcc/config/netware.h
index a28a9d0..2438a56 100644
--- a/gcc/config/netware.h
+++ b/gcc/config/netware.h
@@ -80,15 +80,13 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
given time. */
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_const, in_ctors, in_dtors
+#define EXTRA_SECTIONS in_const
/* A list of extra section function definitions. */
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
- CONST_SECTION_FUNCTION \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
+ CONST_SECTION_FUNCTION
#undef CONST_SECTION_FUNCTION
#define CONST_SECTION_FUNCTION \
@@ -102,48 +100,4 @@ const_section () \
} \
}
-#undef CTORS_SECTION_FUNCTION
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#undef DTORS_SECTION_FUNCTION
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
#define INT_ASM_OP ".long"
-
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
diff --git a/gcc/config/nextstep.c b/gcc/config/nextstep.c
index f15ae04..94492d4 100644
--- a/gcc/config/nextstep.c
+++ b/gcc/config/nextstep.c
@@ -89,3 +89,24 @@ handle_pragma (p_getc, p_ungetc, pname)
return retval;
}
+
+void
+nextstep_asm_out_constructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ constructor_section ();
+ assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1);
+ fprintf (asm_out_file, ".reference .constructors_used\n");
+}
+
+void
+nextstep_asm_out_destructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ destructor_section ();
+ assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1);
+ fprintf (asm_out_file, ".reference .destructors_used\n");
+}
+
diff --git a/gcc/config/nextstep.h b/gcc/config/nextstep.h
index d32675c..7bb9681 100644
--- a/gcc/config/nextstep.h
+++ b/gcc/config/nextstep.h
@@ -212,25 +212,10 @@ Boston, MA 02111-1307, USA. */
#define INIT_SECTION_ASM_OP
#undef INVOKE__main
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { constructor_section (); \
- ASM_OUTPUT_ALIGN (FILE, 1); \
- fprintf (FILE, "\t.long "); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- fprintf (FILE, ".reference .constructors_used\n"); \
- } while (0)
-
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { destructor_section (); \
- ASM_OUTPUT_ALIGN (FILE, 1); \
- fprintf (FILE, "\t.long "); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- fprintf (FILE, ".reference .destructors_used\n"); \
- } while (0)
+#define TARGET_ASM_CONSTRUCTOR nextstep_asm_out_constructor
+#define TARGET_ASM_DESTRUCTOR nextstep_asm_out_destructor
+extern void nextstep_asm_out_constructor PARAMS ((struct rtx_def *, int));
+extern void nextstep_asm_out_destructor PARAMS ((struct rtx_def *, int));
/* ??? Should be changed to EH_FRAME_SECTION_NAME, but that requires
named section support. Based on this definition, it seems clear
diff --git a/gcc/config/nextstep21.h b/gcc/config/nextstep21.h
index aa2c443..40004d1 100644
--- a/gcc/config/nextstep21.h
+++ b/gcc/config/nextstep21.h
@@ -37,8 +37,8 @@ Boston, MA 02111-1307, USA. */
#define INVOKE__main
/* We call the global destructors, constructors from __main */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#undef ASM_OUTPUT_DESTRUCTOR
+#undef TARGET_ASM_CONSTRUCTOR
+#undef TARGET_ASM_DESTRUCTOR
#undef ASM_FILE_END
#define ASM_FILE_END(FILE) \
diff --git a/gcc/config/pa/pa64-hpux.h b/gcc/config/pa/pa64-hpux.h
index bc2cc92..2df1615 100644
--- a/gcc/config/pa/pa64-hpux.h
+++ b/gcc/config/pa/pa64-hpux.h
@@ -101,24 +101,6 @@ do { \
#define CONST_SECTION_ASM_OP "\t.section\t.rodata"
-/* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
-
- Note that we want to give these sections the SHF_WRITE attribute
- because these sections will actually contain data (i.e. tables of
- addresses of functions in the current root executable or shared library
- file) and, in the case of a shared library, the relocatable addresses
- will have to be properly resolved/relocated (and then written into) by
- the dynamic linker when it actually attaches the given shared library
- to the executing process. (Note that on SVR4, you may wish to use the
- `-z text' option to the ELF linker, when building a shared library, as
- an additional check that you are doing everything right. But if you do
- use the `-z text' option when building a shared library, you will get
- errors unless the .ctors and .dtors sections are marked as writable
- via the SHF_WRITE attribute.) */
-
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
-
/* On svr4, we *do* have support for the .init and .fini sections, and we
can put stuff in there to be executed before and after `main'. We let
crtstuff.c and other files know this by defining the following symbols.
@@ -137,7 +119,7 @@ do { \
includes this file. */
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_const, in_ctors, in_dtors
+#define EXTRA_SECTIONS in_const
/* A default list of extra section function definitions. For targets
that use additional sections (e.g. .tdesc) you should override this
@@ -145,9 +127,8 @@ do { \
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
- CONST_SECTION_FUNCTION \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
+ CONST_SECTION_FUNCTION
+
#define READONLY_DATA_SECTION() const_section ()
@@ -164,28 +145,6 @@ const_section () \
} \
}
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
/* Switch into a generic section. */
#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
@@ -222,29 +181,6 @@ do { \
} while (0)
#define INT_ASM_OP "\t.dword\t"
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "%sP%%", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "%sP%%", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* ??? For the time being, we aren't using .ctors/.dtors sections. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#undef ASM_OUTPUT_CONSTRUCTOR
/* Define the strings used for the special svr4 .type and .size directives.
These strings generally do not vary from one system running svr4 to
diff --git a/gcc/config/psos.h b/gcc/config/psos.h
index 6f67f35..26be5ef 100644
--- a/gcc/config/psos.h
+++ b/gcc/config/psos.h
@@ -76,77 +76,6 @@ Boston, MA 02111-1307, USA.
/* Switch into a generic section. */
#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
-/* Define the pseudo-ops used to switch to the .ctors and .dtors
- sections. */
-
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
-
-/* A default list of other sections which we might be "in" at any given
- time. For targets that use additional sections (e.g. .tdesc) you
- should override this definition in the target-specific file which
- includes this file. */
-
-#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_ctors, in_dtors
-
-/* A default list of extra section function definitions. For targets
- that use additional sections (e.g. .tdesc) you should override this
- definition in the target-specific file which includes this file. */
-
-#undef EXTRA_SECTION_FUNCTIONS
-#define EXTRA_SECTION_FUNCTIONS \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
-
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-
-#ifndef INT_ASM_OP
-#define INT_ASM_OP "\t.long\t"
-#endif
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-
/* Use DBX debugging info by default. */
#ifndef PREFERRED_DEBUGGING_TYPE
diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h
index f5b39e5..428ab43 100644
--- a/gcc/config/rs6000/aix.h
+++ b/gcc/config/rs6000/aix.h
@@ -30,10 +30,6 @@ Boston, MA 02111-1307, USA. */
/* This is the only version of nm that collect2 can work with. */
#define REAL_NM_FILE_NAME "/usr/ucb/nm"
-/* AIX does not have any init/fini or ctor/dtor sections, so create
- static constructors and destructors as normal functions. */
-/* #define ASM_OUTPUT_CONSTRUCTOR(file, name) */
-/* #define ASM_OUTPUT_DESTRUCTOR(file, name) */
#define USER_LABEL_PREFIX ""
/* Don't turn -B into -L if the argument specifies a relative file name. */
#define RELATIVE_PREFIX_NOT_LINKDIR
diff --git a/gcc/config/rs6000/lynx.h b/gcc/config/rs6000/lynx.h
index 646c987..8b755fc 100644
--- a/gcc/config/rs6000/lynx.h
+++ b/gcc/config/rs6000/lynx.h
@@ -38,10 +38,6 @@ Boston, MA 02111-1307, USA. */
#undef ASM_GENERATE_INTERNAL_LABEL
#undef ASM_OUTPUT_COMMON
#undef ASM_OUTPUT_LOCAL
-#undef ASM_OUTPUT_CONSTRUCTOR
-#undef ASM_OUTPUT_DESTRUCTOR
-#undef CTORS_SECTION_FUNCTION
-#undef DTORS_SECTION_FUNCTION
#undef SDB_DEBUGGING_INFO
#undef DBX_DEBUGGING_INFO
diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
index 2851d70..f52efa6 100644
--- a/gcc/config/rs6000/sysv4.h
+++ b/gcc/config/rs6000/sysv4.h
@@ -444,14 +444,12 @@ do { \
/* Besides the usual ELF sections, we need a toc section. */
/* Override elfos.h definition. */
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_toc, in_sdata, in_sdata2, in_sbss, in_init, in_fini
+#define EXTRA_SECTIONS in_const, in_toc, in_sdata, in_sdata2, in_sbss, in_init, in_fini
/* Override elfos.h definition. */
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
CONST_SECTION_FUNCTION \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION \
TOC_SECTION_FUNCTION \
SDATA_SECTION_FUNCTION \
SDATA2_SECTION_FUNCTION \
@@ -557,6 +555,13 @@ fini_section () \
} \
}
+/* Ordinarily, we wouldn't need to define these, since generic code would
+ do the right thing based on knowing that we have named sections.
+ However, -mrelocatable needs to know when we're in [cd]tors sections,
+ and the easiest way to do that is rely on varasm.c defining in_[cd]tors. */
+#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
+#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
+
/* A C statement or statements to switch to the appropriate section
for output of RTX in mode MODE. You can assume that RTX is some
kind of constant in RTL. The argument MODE is redundant except in
@@ -919,46 +924,6 @@ do { \
asm_fprintf (FILE, "%U%s", _name); \
} while (0)
-/* Override elfos.h definition. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- if (DEFAULT_ABI != ABI_SOLARIS) \
- { \
- ctors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- } \
- else \
- { \
- init_section (); \
- fputs ("\tbl ", FILE); \
- assemble_name (FILE, NAME); \
- } \
- fputs ("\n", FILE); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-/* Override elfos.h definition. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- if (DEFAULT_ABI != ABI_SOLARIS) \
- { \
- dtors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- } \
- else \
- { \
- fini_section (); \
- fputs ("\tbl ", FILE); \
- assemble_name (FILE, NAME); \
- } \
- fputs ("\n", FILE); \
- } while (0)
-
/* But, to make this work, we have to output the stabs for the function
name *first*... */
diff --git a/gcc/config/sh/elf.h b/gcc/config/sh/elf.h
index 183fa96..761b1fb 100644
--- a/gcc/config/sh/elf.h
+++ b/gcc/config/sh/elf.h
@@ -36,11 +36,7 @@ Boston, MA 02111-1307, USA. */
#undef ASM_FILE_END
#undef ASM_OUTPUT_SOURCE_LINE
#undef DBX_OUTPUT_MAIN_SOURCE_FILE_END
-#undef CTORS_SECTION_ASM_OP
-#undef DTORS_SECTION_ASM_OP
#undef TARGET_ASM_NAMED_SECTION
-#undef ASM_OUTPUT_CONSTRUCTOR
-#undef ASM_OUTPUT_DESTRUCTOR
#undef ASM_DECLARE_FUNCTION_NAME
#undef MAX_OFILE_ALIGNMENT
diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h
index 1377610..9a2c347 100644
--- a/gcc/config/sh/sh.h
+++ b/gcc/config/sh/sh.h
@@ -1897,28 +1897,6 @@ while (0)
#define TEXT_SECTION_ASM_OP "\t.text"
#define DATA_SECTION_ASM_OP "\t.data"
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors\n"
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors\n"
-#define EXTRA_SECTIONS in_ctors, in_dtors
-#define EXTRA_SECTION_FUNCTIONS \
-void \
-ctors_section() \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-} \
-void \
-dtors_section() \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
/* If defined, a C expression whose value is a string containing the
assembler operation to identify the following data as
@@ -1956,32 +1934,7 @@ dtors_section() \
#define INT_ASM_OP "\t.long\t"
-/* A C statement (sans semicolon) to output an
- element in the table of global constructors. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE, NAME) \
- do \
- { \
- ctors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } \
- while (0)
-
-/* A C statement (sans semicolon) to output an
- element in the table of global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do \
- { \
- dtors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } \
- while (0)
-
#undef DO_GLOBAL_CTORS_BODY
-
#define DO_GLOBAL_CTORS_BODY \
{ \
typedef (*pfunc)(); \
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
index 3481c4b..d72f57f 100644
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -387,31 +387,3 @@ do { \
: /* no outputs */ \
: "r" (ms_flags), "r" (ms_saveret));
#endif /* sparc32 */
-
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- if (TARGET_ARCH64) \
- fprintf (FILE, "\t%s\t ", ASM_LONGLONG); \
- else \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- if (TARGET_ARCH64) \
- fprintf (FILE, "\t%s\t ", ASM_LONGLONG); \
- else \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
diff --git a/gcc/config/sparc/litecoff.h b/gcc/config/sparc/litecoff.h
index c662eb3..e2340c3 100644
--- a/gcc/config/sparc/litecoff.h
+++ b/gcc/config/sparc/litecoff.h
@@ -42,72 +42,19 @@ Boston, MA 02111-1307, USA. */
#undef INIT_SECTION_ASM_OP
-/* Support the ctors and dtors sections for g++. */
-
-#undef CTORS_SECTION_ASM_OP
-#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"x\""
-#undef DTORS_SECTION_ASM_OP
-#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"x\""
-
/* A list of other sections which the compiler might be "in" at any
given time. */
#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_const, in_ctors, in_dtors
+#define EXTRA_SECTIONS in_const
/* A list of extra section function definitions. */
#undef EXTRA_SECTION_FUNCTIONS
#define EXTRA_SECTION_FUNCTIONS \
- CONST_SECTION_FUNCTION \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
-
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
+ CONST_SECTION_FUNCTION
#define INT_ASM_OP "\t.long\t"
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
#undef DO_GLOBAL_CTORS_BODY
#undef DO_GLOBAL_DTORS_BODY
diff --git a/gcc/config/sparc/sol2-sld-64.h b/gcc/config/sparc/sol2-sld-64.h
index 9179635..21545f2 100644
--- a/gcc/config/sparc/sol2-sld-64.h
+++ b/gcc/config/sparc/sol2-sld-64.h
@@ -329,32 +329,4 @@
#endif /* ! SPARC_BI_ARCH */
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- if (TARGET_ARCH64) \
- fprintf (FILE, "\t%s\t ", ASM_LONGLONG); \
- else \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- if (TARGET_ARCH64) \
- fprintf (FILE, "\t%s\t ", ASM_LONGLONG); \
- else \
- fprintf (FILE, "%s", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
#endif
diff --git a/gcc/config/svr3.h b/gcc/config/svr3.h
index 5e732af..6f26fde 100644
--- a/gcc/config/svr3.h
+++ b/gcc/config/svr3.h
@@ -211,14 +211,13 @@ Boston, MA 02111-1307, USA.
and CTOR_LIST_END to contribute to the .init section an instruction to
push a word containing 0 (or some equivalent of that).
- Define ASM_OUTPUT_CONSTRUCTOR to push the address of the constructor. */
+ Define TARGET_ASM_CONSTRUCTOR to push the address of the constructor. */
#define USE_CONST_SECTION 0
#define INIT_SECTION_ASM_OP "\t.section\t.init"
#define FINI_SECTION_ASM_OP "\t.section .fini,\"x\""
#define CONST_SECTION_ASM_OP "\t.section\t.rodata, \"x\""
-#define CTORS_SECTION_ASM_OP INIT_SECTION_ASM_OP
#define DTORS_SECTION_ASM_OP FINI_SECTION_ASM_OP
/* CTOR_LIST_BEGIN and CTOR_LIST_END are machine-dependent
@@ -297,45 +296,6 @@ const_section () \
} \
}
-/* The ctors and dtors sections are not normally put into use
- by EXTRA_SECTIONS and EXTRA_SECTION_FUNCTIONS as defined in svr3.h,
- but it can't hurt to define these macros for whatever systems use them. */
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
-/* This is machine-dependent
- because it needs to push something on the stack. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- fini_section (); \
- fprintf (FILE, "%s\t ", ASM_LONG); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
/* A C statement or statements to switch to the appropriate
section for output of DECL. DECL is either a `VAR_DECL' node
or a constant of some sort. RELOC indicates whether forming
diff --git a/gcc/config/vax/vax.c b/gcc/config/vax/vax.c
index e8a13dc..df4f76e 100644
--- a/gcc/config/vax/vax.c
+++ b/gcc/config/vax/vax.c
@@ -38,6 +38,10 @@ Boston, MA 02111-1307, USA. */
#include "target-def.h"
static void vax_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT));
+#if VMS_TARGET
+static void vms_asm_out_constructor PARAMS ((rtx, int));
+static void vms_asm_out_destructor PARAMS ((rtx, int));
+#endif
/* Initialize the GCC target structure. */
#undef TARGET_ASM_FUNCTION_PROLOGUE
@@ -833,11 +837,34 @@ vms_flush_pending_externals (file)
fprintf (file, ",%d\n", p->size);
}
}
+
+static void
+vms_asm_out_constructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ fprintf (asm_out_file,".globl $$PsectAttributes_NOOVR$$__gxx_init_1\n");
+ data_section();
+ fprintf (asm_out_file,"$$PsectAttributes_NOOVR$$__gxx_init_1:\n\t.long\t");
+ assemble_name (asm_out_file, XSTR (symbol, 0));
+ fputc ('\n', asm_out_file);
+}
+
+static void
+vms_asm_out_destructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ fprintf (asm_out_file,".globl $$PsectAttributes_NOOVR$$__gxx_clean_1\n");
+ data_section();
+ fprintf (asm_out_file,"$$PsectAttributes_NOOVR$$__gxx_clean_1:\n\t.long\t");
+ assemble_name (asm_out_file, XSTR (symbol, 0));
+ fputc ('\n', asm_out_file);
+}
#endif /* VMS_TARGET */
-#ifdef VMS
/* Additional support code for VMS host. */
-
+/* ??? This should really be in libiberty; vax.c is a target file. */
#ifdef QSORT_WORKAROUND
/*
Do not use VAXCRTL's qsort() due to a severe bug: once you've
@@ -845,7 +872,7 @@ vms_flush_pending_externals (file)
and is longword aligned, you cannot safely sort anything which
is either not a multiple of 4 in size or not longword aligned.
A static "move-by-longword" optimization flag inside qsort() is
- never reset. This is known of affect VMS V4.6 through VMS V5.5-1,
+ never reset. This is known to affect VMS V4.6 through VMS V5.5-1,
and was finally fixed in VMS V5.5-2.
In this work-around an insertion sort is used for simplicity.
@@ -919,5 +946,3 @@ not_qsort (array, count, size, compare)
return;
}
#endif /* QSORT_WORKAROUND */
-
-#endif /* VMS */
diff --git a/gcc/config/vax/vms.h b/gcc/config/vax/vms.h
index ccc1715..52f4d27 100644
--- a/gcc/config/vax/vms.h
+++ b/gcc/config/vax/vms.h
@@ -248,27 +248,8 @@ const_section () \
that are needed to tell the startup code which constructors need to
be run. */
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
-{ \
- fprintf ((FILE),".globl $$PsectAttributes_NOOVR$$__gxx_init_1\n"); \
- data_section(); \
- fprintf ((FILE),"$$PsectAttributes_NOOVR$$__gxx_init_1:\n\t.long\t"); \
- assemble_name ((FILE), (NAME)); \
- fputc ('\n', (FILE)); \
-}
-
-/* This is used by a hook in varasm.c to write the assembler directives
- that are needed to tell the startup code which destructors need to
- be run. */
-
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
-{ \
- fprintf ((FILE),".globl $$PsectAttributes_NOOVR$$__gxx_clean_1\n"); \
- data_section(); \
- fprintf ((FILE),"$$PsectAttributes_NOOVR$$__gxx_clean_1:\n\t.long\t");\
- assemble_name ((FILE), (NAME)); \
- fputc ('\n', (FILE)); \
-}
+#define TARGET_ASM_CONSTRUCTOR vms_asm_out_constructor
+#define TARGET_ASM_DESTRUCTOR vms_asm_out_destructor
/* The following definitions are used in libgcc2.c with the __main
function. The _SHR symbol is used when the sharable image library
diff --git a/gcc/configure b/gcc/configure
index cd03812..640e5c2 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -6785,15 +6785,10 @@ if test x$use_collect2 = xno; then
fi
# Add a definition of USE_COLLECT2 if system wants one.
-# Also tell toplev.c what to do.
-# This substitutes for lots of t-* files.
-if test x$use_collect2 = x
+if test x$use_collect2 != x
then
- will_use_collect2=
- maybe_use_collect2=
-else
- will_use_collect2="collect2"
- maybe_use_collect2="-DUSE_COLLECT2"
+ host_xm_defines="${host_xm_defines} USE_COLLECT2"
+ xm_defines="${xm_defines} USE_COLLECT2"
fi
# If we have gas in the build tree, make a link to it.
@@ -6808,16 +6803,12 @@ fi
# If we have ld in the build tree, make a link to it.
if test -f ../ld/Makefile; then
-# if test x$use_collect2 = x; then
-# rm -f ld; $symbolic_link ../ld/ld-new$host_exeext ld$host_exeext 2>/dev/null
-# else
- rm -f collect-ld; $symbolic_link ../ld/ld-new$host_exeext collect-ld$host_exeext 2>/dev/null
-# fi
+ rm -f collect-ld; $symbolic_link ../ld/ld-new$host_exeext collect-ld$host_exeext 2>/dev/null
fi
# Figure out what assembler we will be using.
echo $ac_n "checking what assembler to use""... $ac_c" 1>&6
-echo "configure:6821: checking what assembler to use" >&5
+echo "configure:6812: checking what assembler to use" >&5
gcc_cv_as=
gcc_cv_gas_major_version=
gcc_cv_gas_minor_version=
@@ -6902,7 +6893,7 @@ fi
# Figure out what nm we will be using.
echo $ac_n "checking what nm to use""... $ac_c" 1>&6
-echo "configure:6906: checking what nm to use" >&5
+echo "configure:6897: checking what nm to use" >&5
if test -x nm$host_exeext; then
gcc_cv_nm=./nm$host_exeext
elif test x$host = x$target; then
@@ -6913,7 +6904,7 @@ echo "$ac_t""$gcc_cv_nm" 1>&6
# Figure out what assembler alignment features are present.
echo $ac_n "checking assembler alignment features""... $ac_c" 1>&6
-echo "configure:6917: checking assembler alignment features" >&5
+echo "configure:6908: checking assembler alignment features" >&5
gcc_cv_as_alignment_features=none
if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then
# Gas version 2.6 and later support for .balign and .p2align.
@@ -6961,7 +6952,7 @@ fi
echo "$ac_t""$gcc_cv_as_alignment_features" 1>&6
echo $ac_n "checking assembler subsection support""... $ac_c" 1>&6
-echo "configure:6965: checking assembler subsection support" >&5
+echo "configure:6956: checking assembler subsection support" >&5
gcc_cv_as_subsections=no
if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then
if test "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 9 -o "$gcc_cv_gas_major_version" -gt 2 && grep 'obj_format = elf' ../gas/Makefile > /dev/null; then
@@ -7001,7 +6992,7 @@ fi
echo "$ac_t""$gcc_cv_as_subsections" 1>&6
echo $ac_n "checking assembler weak support""... $ac_c" 1>&6
-echo "configure:7005: checking assembler weak support" >&5
+echo "configure:6996: checking assembler weak support" >&5
gcc_cv_as_weak=no
if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then
if test "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 2 -o "$gcc_cv_gas_major_version" -gt 2; then
@@ -7024,7 +7015,7 @@ fi
echo "$ac_t""$gcc_cv_as_weak" 1>&6
echo $ac_n "checking assembler hidden support""... $ac_c" 1>&6
-echo "configure:7028: checking assembler hidden support" >&5
+echo "configure:7019: checking assembler hidden support" >&5
gcc_cv_as_hidden=no
if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then
if test "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 10 -o "$gcc_cv_gas_major_version" -gt 2 && grep 'obj_format = elf' ../gas/Makefile > /dev/null; then
@@ -7048,7 +7039,7 @@ fi
echo "$ac_t""$gcc_cv_as_hidden" 1>&6
echo $ac_n "checking assembler leb128 support""... $ac_c" 1>&6
-echo "configure:7052: checking assembler leb128 support" >&5
+echo "configure:7043: checking assembler leb128 support" >&5
gcc_cv_as_leb128=no
if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then
if test "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 11 -o "$gcc_cv_gas_major_version" -gt 2 && grep 'obj_format = elf' ../gas/Makefile > /dev/null; then
@@ -7093,7 +7084,7 @@ fi
echo "$ac_t""$gcc_cv_as_leb128" 1>&6
echo $ac_n "checking assembler eh_frame optimization""... $ac_c" 1>&6
-echo "configure:7097: checking assembler eh_frame optimization" >&5
+echo "configure:7088: checking assembler eh_frame optimization" >&5
gcc_cv_as_eh_frame=no
if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then
if test "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 12 -o "$gcc_cv_gas_major_version" -gt 2 && grep 'obj_format = elf' ../gas/Makefile > /dev/null; then
@@ -7176,7 +7167,7 @@ echo "$ac_t""$gcc_cv_as_eh_frame" 1>&6
case "$target" in
sparc*-*-*)
echo $ac_n "checking assembler .register pseudo-op support""... $ac_c" 1>&6
-echo "configure:7180: checking assembler .register pseudo-op support" >&5
+echo "configure:7171: checking assembler .register pseudo-op support" >&5
if eval "test \"`echo '$''{'gcc_cv_as_register_pseudo_op'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -7204,7 +7195,7 @@ EOF
fi
echo $ac_n "checking assembler supports -relax""... $ac_c" 1>&6
-echo "configure:7208: checking assembler supports -relax" >&5
+echo "configure:7199: checking assembler supports -relax" >&5
if eval "test \"`echo '$''{'gcc_cv_as_relax_opt'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -7234,7 +7225,7 @@ EOF
case "$tm_file" in
*64*)
echo $ac_n "checking for 64 bit support in assembler ($gcc_cv_as)""... $ac_c" 1>&6
-echo "configure:7238: checking for 64 bit support in assembler ($gcc_cv_as)" >&5
+echo "configure:7229: checking for 64 bit support in assembler ($gcc_cv_as)" >&5
if eval "test \"`echo '$''{'gcc_cv_as_flags64'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -7279,7 +7270,7 @@ EOF
if test "x$gcc_cv_as_flags64" != xno; then
echo $ac_n "checking for assembler offsetable %lo() support""... $ac_c" 1>&6
-echo "configure:7283: checking for assembler offsetable %lo() support" >&5
+echo "configure:7274: checking for assembler offsetable %lo() support" >&5
if eval "test \"`echo '$''{'gcc_cv_as_offsetable_lo10'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -7319,7 +7310,7 @@ EOF
i[34567]86-*-*)
echo $ac_n "checking assembler instructions""... $ac_c" 1>&6
-echo "configure:7323: checking assembler instructions" >&5
+echo "configure:7314: checking assembler instructions" >&5
gcc_cv_as_instructions=
if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then
if test "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 9 -o "$gcc_cv_gas_major_version" -gt 2; then
@@ -7348,7 +7339,7 @@ EOF
esac
echo $ac_n "checking assembler dwarf2 debug_line support""... $ac_c" 1>&6
-echo "configure:7352: checking assembler dwarf2 debug_line support" >&5
+echo "configure:7343: checking assembler dwarf2 debug_line support" >&5
gcc_cv_as_dwarf2_debug_line=no
# ??? Not all targets support dwarf2 debug_line, even within a version
# of gas. Moreover, we need to emit a valid instruction to trigger any
@@ -7533,7 +7524,7 @@ fi
echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
-echo "configure:7537: checking whether to enable maintainer-specific portions of Makefiles" >&5
+echo "configure:7528: checking whether to enable maintainer-specific portions of Makefiles" >&5
# Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
if test "${enable_maintainer_mode+set}" = set; then
enableval="$enable_maintainer_mode"
@@ -7844,8 +7835,6 @@ ${CONFIG_SHELL-/bin/sh} $srcdir/configure.frag $srcdir "$subdirs" "$dep_host_xma
-
-
# Echo that links are built
if test x$host = x$target
then
@@ -8142,7 +8131,6 @@ s%@lang_options_files@%$lang_options_files%g
s%@lang_specs_files@%$lang_specs_files%g
s%@lang_tree_files@%$lang_tree_files%g
s%@local_prefix@%$local_prefix%g
-s%@maybe_use_collect2@%$maybe_use_collect2%g
s%@md_file@%$md_file%g
s%@objc_boehm_gc@%$objc_boehm_gc%g
s%@out_file@%$out_file%g
@@ -8156,7 +8144,6 @@ s%@tm_p_file_list@%$tm_p_file_list%g
s%@tm_p_file@%$tm_p_file%g
s%@xm_file@%$xm_file%g
s%@xm_defines@%$xm_defines%g
-s%@will_use_collect2@%$will_use_collect2%g
s%@c_target_objs@%$c_target_objs%g
s%@cxx_target_objs@%$cxx_target_objs%g
s%@target_cpu_default@%$target_cpu_default%g
diff --git a/gcc/configure.in b/gcc/configure.in
index b4a8ba7..6d10583 100644
--- a/gcc/configure.in
+++ b/gcc/configure.in
@@ -1129,15 +1129,10 @@ if test x$use_collect2 = xno; then
fi
# Add a definition of USE_COLLECT2 if system wants one.
-# Also tell toplev.c what to do.
-# This substitutes for lots of t-* files.
-if test x$use_collect2 = x
+if test x$use_collect2 != x
then
- will_use_collect2=
- maybe_use_collect2=
-else
- will_use_collect2="collect2"
- maybe_use_collect2="-DUSE_COLLECT2"
+ host_xm_defines="${host_xm_defines} USE_COLLECT2"
+ xm_defines="${xm_defines} USE_COLLECT2"
fi
# If we have gas in the build tree, make a link to it.
@@ -1152,11 +1147,7 @@ fi
# If we have ld in the build tree, make a link to it.
if test -f ../ld/Makefile; then
-# if test x$use_collect2 = x; then
-# rm -f ld; $symbolic_link ../ld/ld-new$host_exeext ld$host_exeext 2>/dev/null
-# else
- rm -f collect-ld; $symbolic_link ../ld/ld-new$host_exeext collect-ld$host_exeext 2>/dev/null
-# fi
+ rm -f collect-ld; $symbolic_link ../ld/ld-new$host_exeext collect-ld$host_exeext 2>/dev/null
fi
# Figure out what assembler we will be using.
@@ -2089,7 +2080,6 @@ AC_SUBST(lang_options_files)
AC_SUBST(lang_specs_files)
AC_SUBST(lang_tree_files)
AC_SUBST(local_prefix)
-AC_SUBST(maybe_use_collect2)
AC_SUBST(md_file)
AC_SUBST(objc_boehm_gc)
AC_SUBST(out_file)
@@ -2103,7 +2093,6 @@ AC_SUBST(tm_p_file_list)
AC_SUBST(tm_p_file)
AC_SUBST(xm_file)
AC_SUBST(xm_defines)
-AC_SUBST(will_use_collect2)
AC_SUBST(c_target_objs)
AC_SUBST(cxx_target_objs)
AC_SUBST(target_cpu_default)
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 50a96b6..02f3415 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2001-08-09 Richard Henderson <rth@redhat.com>
+
+ * decl2.c (finish_objects): Use target hooks instead of
+ assemble_constructor and assemble_destructor.
+
2001-08-08 John David Anglin <dave@hiauly1.hia.nrc.ca>
* g++spec.c (lang_specific_driver): Quote argument after `-Xlinker'.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index a649e23..0a9e5ad 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2806,11 +2806,9 @@ start_objects (method_type, initp)
NULL_TREE),
NULL_TREE, SF_DEFAULT);
-#if defined(ASM_OUTPUT_CONSTRUCTOR) && defined(ASM_OUTPUT_DESTRUCTOR)
/* It can be a static function as long as collect2 does not have
to scan the object file to find its ctor/dtor routine. */
- TREE_PUBLIC (current_function_decl) = 0;
-#endif
+ TREE_PUBLIC (current_function_decl) = ! targetm.have_ctors_dtors;
/* Mark this declaration as used to avoid spurious warnings. */
TREE_USED (current_function_decl) = 1;
@@ -2843,7 +2841,6 @@ finish_objects (method_type, initp, body)
tree body;
{
tree fn;
- rtx fnsym;
/* Finish up. */
finish_compound_stmt (/*has_no_scope=*/0, body);
@@ -2856,11 +2853,14 @@ finish_objects (method_type, initp, body)
if (flag_syntax_only)
return;
- fnsym = XEXP (DECL_RTL (fn), 0);
- if (method_type == 'I')
- assemble_constructor (fnsym, initp);
- else
- assemble_destructor (fnsym, initp);
+ if (targetm.have_ctors_dtors)
+ {
+ rtx fnsym = XEXP (DECL_RTL (fn), 0);
+ if (method_type == 'I')
+ (* targetm.asm_out.constructor) (fnsym, initp);
+ else
+ (* targetm.asm_out.destructor) (fnsym, initp);
+ }
}
/* The names of the parameters to the function created to handle
diff --git a/gcc/crtstuff.c b/gcc/crtstuff.c
index c74377e..402ab01 100644
--- a/gcc/crtstuff.c
+++ b/gcc/crtstuff.c
@@ -100,32 +100,6 @@ extern void *__deregister_frame_info_bases (void *)
#ifndef OBJECT_FORMAT_MACHO
-/* Provide default definitions for the pseudo-ops used to switch to the
- .ctors and .dtors sections.
-
- Note that we want to give these sections the SHF_WRITE attribute
- because these sections will actually contain data (i.e. tables of
- addresses of functions in the current root executable or shared library
- file) and, in the case of a shared library, the relocatable addresses
- will have to be properly resolved/relocated (and then written into) by
- the dynamic linker when it actually attaches the given shared library
- to the executing process. (Note that on SVR4, you may wish to use the
- `-z text' option to the ELF linker, when building a shared library, as
- an additional check that you are doing everything right. But if you do
- use the `-z text' option when building a shared library, you will get
- errors unless the .ctors and .dtors sections are marked as writable
- via the SHF_WRITE attribute.)
-
- These defaults do not include leading spacing, as they will only be
- used in asm:s here. */
-
-#ifndef CTORS_SECTION_ASM_OP
-#define CTORS_SECTION_ASM_OP ".section\t.ctors,\"aw\""
-#endif
-#ifndef DTORS_SECTION_ASM_OP
-#define DTORS_SECTION_ASM_OP ".section\t.dtors,\"aw\""
-#endif
-
#ifdef OBJECT_FORMAT_ELF
/* Declare a pointer to void function type. */
@@ -372,9 +346,6 @@ __frame_dummy (void)
#endif /* defined(INIT_SECTION_ASM_OP) */
-/* Force cc1 to switch to .data section. */
-static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { };
-
/* NOTE: In order to be able to support SVR4 shared libraries, we arrange
to have one set of symbols { __CTOR_LIST__, __DTOR_LIST__, __CTOR_END__,
__DTOR_END__ } per root executable and also one set of these symbols
@@ -387,21 +358,36 @@ static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { };
refer to only the __CTOR_END__ symbol in crtend.o and the __DTOR_LIST__
symbol in crtbegin.o, where they are defined. */
-/* The -1 is a flag to __do_global_[cd]tors
- indicating that this table does not start with a count of elements. */
+/* The -1 is a flag to __do_global_[cd]tors indicating that this table
+ does not start with a count of elements. */
#ifdef CTOR_LIST_BEGIN
CTOR_LIST_BEGIN;
+
+#elif defined(CTORS_SECTION_ASM_OP)
+/* Hack: force cc1 to switch to .data section early, so that assembling
+ __CTOR_LIST__ does not undo our behind-the-back change to .ctors. */
+static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { };
+asm (CTORS_SECTION_ASM_OP);
+STATIC func_ptr __CTOR_LIST__[1]
+ __attribute__ ((__unused__))
+ = { (func_ptr) (-1) };
+
#else
-asm (CTORS_SECTION_ASM_OP); /* cc1 doesn't know that we are switching! */
-STATIC func_ptr __CTOR_LIST__[1] __attribute__ ((__unused__))
+STATIC func_ptr __CTOR_LIST__[1]
+ __attribute__ ((__unused__, section(".ctors")))
= { (func_ptr) (-1) };
+
#endif
#ifdef DTOR_LIST_BEGIN
DTOR_LIST_BEGIN;
-#else
-asm (DTORS_SECTION_ASM_OP); /* cc1 doesn't know that we are switching! */
+#elif defined(DTORS_SECTION_ASM_OP)
+asm (DTORS_SECTION_ASM_OP);
STATIC func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) };
+#else
+STATIC func_ptr __DTOR_LIST__[1]
+ __attribute__((section(".dtors")))
+ = { (func_ptr) (-1) };
#endif
#ifdef EH_FRAME_SECTION_NAME
@@ -533,9 +519,6 @@ __do_global_ctors (void)
#endif /* defined(INIT_SECTION_ASM_OP) */
-/* Force cc1 to switch to .data section. */
-static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { };
-
/* Put a word containing zero at the end of each of our two lists of function
addresses. Note that the words defined here go into the .ctors and .dtors
sections of the crtend.o file, and since that file is always linked in
@@ -544,16 +527,29 @@ static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { };
#ifdef CTOR_LIST_END
CTOR_LIST_END;
-#else
-asm (CTORS_SECTION_ASM_OP); /* cc1 doesn't know that we are switching! */
+
+#elif defined(CTORS_SECTION_ASM_OP)
+/* Hack: force cc1 to switch to .data section early, so that assembling
+ __CTOR_LIST__ does not undo our behind-the-back change to .ctors. */
+static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { };
+asm (CTORS_SECTION_ASM_OP);
STATIC func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
+
+#else
+STATIC func_ptr __CTOR_END__[1]
+ __attribute__((section(".ctors")))
+ = { (func_ptr) 0 };
#endif
#ifdef DTOR_LIST_END
DTOR_LIST_END;
+#elif defined(DTORS_SECTION_ASM_OP)
+asm (DTORS_SECTION_ASM_OP);
+STATIC func_ptr __DTOR_END__[1] __attribute__ ((unused))
+ = { (func_ptr) 0 };
#else
-asm (DTORS_SECTION_ASM_OP); /* cc1 doesn't know that we are switching! */
-STATIC func_ptr __DTOR_END__[1] __attribute__ ((__unused__))
+STATIC func_ptr __DTOR_END__[1]
+ __attribute__((unused, section(".dtors")))
= { (func_ptr) 0 };
#endif
@@ -636,4 +632,3 @@ STATIC int __FRAME_END__[]
#endif /* CRT_END */
#endif /* OBJECT_FORMAT_MACHO */
-
diff --git a/gcc/defaults.h b/gcc/defaults.h
index 0939d07..b069c57 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -209,9 +209,9 @@ do { ASM_OUTPUT_LABEL(FILE,LABEL_ALTERNATE_NAME (INSN)); } while (0)
#define DWARF2_UNWIND_INFO 1
#endif
-/* If we have named section, and we're using crtstuff to run ctors,
- then use named sections for registering eh frame information. */
-#if defined (TARGET_ASM_NAMED_SECTION) && defined (ASM_OUTPUT_CONSTRUCTOR)
+/* If we have named sections, and we're using crtstuff to run ctors,
+ use them for registering eh frame information. */
+#if defined (TARGET_ASM_NAMED_SECTION)
#ifndef EH_FRAME_SECTION_NAME
#define EH_FRAME_SECTION_NAME ".eh_frame"
#endif
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 4bcf827..0de3768 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -396,7 +396,7 @@ the effect you need.
@findex LINK_ELIMINATE_DUPLICATE_LDIRECTORIES
@item LINK_ELIMINATE_DUPLICATE_LDIRECTORIES
-A nonzero value causes collect2 to remove duplicate @option{-L@var{directory}} search
+A nonzero value causes @command{collect2} to remove duplicate @option{-L@var{directory}} search
directories from linking commands. Do not give it a nonzero value if
removing duplicate search directories changes the linker's semantics.
@@ -6318,7 +6318,7 @@ systems. This macro is used in @code{assemble_name}.
@ignore @c Seems not to exist anymore.
@findex ASM_OUTPUT_LABELREF_AS_INT
@item ASM_OUTPUT_LABELREF_AS_INT (@var{file}, @var{label})
-Define this macro for systems that use the program @code{collect2}.
+Define this macro for systems that use the program @command{collect2}.
The definition should be a C statement to output a word containing
a reference to the label @var{label}.
@end ignore
@@ -6546,49 +6546,56 @@ the constructor section to point to that function. The linker
accumulates all these words into one contiguous @samp{.ctors} section.
Termination functions are handled similarly.
-To use this method, you need appropriate definitions of the macros
-@code{ASM_OUTPUT_CONSTRUCTOR} and @code{ASM_OUTPUT_DESTRUCTOR}. Usually
-you can get them by including @file{svr4.h}.
+This method will be chosen as the default by @file{target-def.h} if
+@code{TARGET_ASM_NAMED_SECTION} is defined. A target that does not
+support arbitrary sections, but does support special designated
+constructor and destructor sections may define @code{CTORS_SECTION_ASM_OP}
+and @code{DTORS_SECTION_ASM_OP} to achieve the same effect.
When arbitrary sections are available, there are two variants, depending
upon how the code in @file{crtstuff.c} is called. On systems that
-support an @dfn{init} section which is executed at program startup,
+support a @dfn{.init} section which is executed at program startup,
parts of @file{crtstuff.c} are compiled into that section. The
program is linked by the @code{gcc} driver like this:
@example
-ld -o @var{output_file} crtbegin.o @dots{} crtend.o -lgcc
+ld -o @var{output_file} crti.o crtbegin.o @dots{} -lgcc crtend.o crtn.o
@end example
-The head of a function (@code{__do_global_ctors}) appears in the init
-section of @file{crtbegin.o}; the remainder of the function appears in
-the init section of @file{crtend.o}. The linker will pull these two
-parts of the section together, making a whole function. If any of the
-user's object files linked into the middle of it contribute code, then that
-code will be executed as part of the body of @code{__do_global_ctors}.
+The prologue of a function (@code{__init}) appears in the @code{.init}
+section of @file{crti.o}; the epilogue appears in @file{crtn.o}. Likewise
+for the function @code{__fini} in the @dfn{.fini} section. Normally these
+files are provided by the operating system or by the GNU C library, but
+are provided by GCC for a few targets.
+
+The objects @file{crtbegin.o} and @file{crtend.o} are (for most targets)
+compiled from @file{crtstuff.c}. They contain, among other things, code
+fragments within the @code{.init} and @code{.fini} sections that branch
+to routines in the @code{.text} section. The linker will pull all parts
+of a section together, which results in a complete @code{__init} function
+that invokes the routines we need at startup.
To use this variant, you must define the @code{INIT_SECTION_ASM_OP}
macro properly.
-If no init section is available, do not define
-@code{INIT_SECTION_ASM_OP}. Then @code{__do_global_ctors} is built into
-the text section like all other functions, and resides in
-@file{libgcc.a}. When GCC compiles any function called @code{main}, it
-inserts a procedure call to @code{__main} as the first executable code
-after the function prologue. The @code{__main} function, also defined
-in @file{libgcc2.c}, simply calls @file{__do_global_ctors}.
+If no init section is available, when GCC compiles any function called
+@code{main} (or more accurately, any function designated as a program
+entry point by the language front end calling @code{expand_main_function}),
+it inserts a procedure call to @code{__main} as the first executable code
+after the function prologue. The @code{__main} function is defined
+in @file{libgcc2.c} and runs the global constructors.
In file formats that don't support arbitrary sections, there are again
two variants. In the simplest variant, the GNU linker (GNU @code{ld})
and an `a.out' format must be used. In this case,
-@code{ASM_OUTPUT_CONSTRUCTOR} is defined to produce a @code{.stabs}
+@code{TARGET_ASM_CONSTRUCTOR} is defined to produce a @code{.stabs}
entry of type @samp{N_SETT}, referencing the name @code{__CTOR_LIST__},
and with the address of the void function containing the initialization
code as its value. The GNU linker recognizes this as a request to add
-the value to a ``set''; the values are accumulated, and are eventually
+the value to a @dfn{set}; the values are accumulated, and are eventually
placed in the executable as a vector in the format described above, with
a leading (ignored) count and a trailing zero element.
-@code{ASM_OUTPUT_DESTRUCTOR} is handled similarly. Since no init
+@code{TARGET_ASM_DESTRUCTOR} is handled similarly. Since no init
section is available, the absence of @code{INIT_SECTION_ASM_OP} causes
the compilation of @code{main} to call @code{__main} as above, starting
the initialization process.
@@ -6596,37 +6603,14 @@ the initialization process.
The last variant uses neither arbitrary sections nor the GNU linker.
This is preferable when you want to do dynamic linking and when using
file formats which the GNU linker does not support, such as `ECOFF'@. In
-this case, @code{ASM_OUTPUT_CONSTRUCTOR} does not produce an
-@code{N_SETT} symbol; initialization and termination functions are
-recognized simply by their names. This requires an extra program in the
-linkage step, called @code{collect2}. This program pretends to be the
-linker, for use with GCC; it does its job by running the ordinary
-linker, but also arranges to include the vectors of initialization and
-termination functions. These functions are called via @code{__main} as
-described above.
-
-Choosing among these configuration options has been simplified by a set
-of operating-system-dependent files in the @file{config} subdirectory.
-These files define all of the relevant parameters. Usually it is
-sufficient to include one into your specific machine-dependent
-configuration file. These files are:
-
-@table @file
-@item aoutos.h
-For operating systems using the `a.out' format.
-
-@item next.h
-For operating systems using the `MachO' format.
-
-@item svr3.h
-For System V Release 3 and similar systems using `COFF' format.
-
-@item svr4.h
-For System V Release 4 and similar systems using `ELF' format.
-
-@item vms.h
-For the VMS operating system.
-@end table
+this case, @code{TARGET_HAVE_CTORS_DTORS} is false, initialization and
+termination functions are recognized simply by their names. This requires
+an extra program in the linkage step, called @command{collect2}. This program
+pretends to be the linker, for use with GCC; it does its job by running
+the ordinary linker, but also arranges to include the vectors of
+initialization and termination functions. These functions are called
+via @code{__main} as described above. In order to use this method,
+@code{use_collect2} must be defined in the target in @file{config.gcc}.
@ifinfo
The following section describes the specific macros that control and
@@ -6652,10 +6636,9 @@ run the initialization functions.
@item HAS_INIT_SECTION
@findex HAS_INIT_SECTION
If defined, @code{main} will not call @code{__main} as described above.
-This macro should be defined for systems that control the contents of the
-init section on a symbol-by-symbol basis, such as OSF/1, and should not
-be defined explicitly for systems that support
-@code{INIT_SECTION_ASM_OP}.
+This macro should be defined for systems that control start-up code
+on a symbol-by-symbol basis, such as OSF/1, and should not
+be defined explicitly for systems that support @code{INIT_SECTION_ASM_OP}.
@item LD_INIT_SWITCH
@findex LD_INIT_SWITCH
@@ -6680,65 +6663,65 @@ If nonzero, the C++ @code{init_priority} attribute is supported and the
compiler should emit instructions to control the order of initialization
of objects. If zero, the compiler will issue an error message upon
encountering an @code{init_priority} attribute.
+@end table
+
+@deftypefn {Target Hook} bool TARGET_HAVE_CTORS_DTORS
+This value is true if the target supports some ``native'' method of
+collecting constructors and destructors to be run at startup and exit.
+It is false if we must use @command{collect2}.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_ASM_CONSTRUCTOR (rtx @var{symbol}, int @var{priority})
+If defined, a function that outputs assembler code to arrange to call
+the function referenced by @var{symbol} at initialization time.
-@item ASM_OUTPUT_CONSTRUCTOR (@var{stream}, @var{name})
-@findex ASM_OUTPUT_CONSTRUCTOR
-Define this macro as a C statement to output on the stream @var{stream}
-the assembler code to arrange to call the function named @var{name} at
-initialization time.
-
-Assume that @var{name} is the name of a C function generated
-automatically by the compiler. This function takes no arguments. Use
-the function @code{assemble_name} to output the name @var{name}; this
-performs any system-specific syntactic transformations such as adding an
-underscore.
-
-If you don't define this macro, nothing special is output to arrange to
-call the function. This is correct when the function will be called in
-some other manner---for example, by means of the @code{collect2} program,
-which looks through the symbol table to find these functions by their
-names.
-
-@item ASM_OUTPUT_DESTRUCTOR (@var{stream}, @var{name})
-@findex ASM_OUTPUT_DESTRUCTOR
-This is like @code{ASM_OUTPUT_CONSTRUCTOR} but used for termination
+Assume that @var{symbol} is a @code{SYMBOL_REF} for a function taking
+no arguments and with no return value. If the target supports initialization
+priorities, @var{priority} is a value between 0 and @code{MAX_INIT_PRIORITY};
+otherwise it must be @code{DEFAULT_INIT_PRIORITY}.
+
+If this macro is is not defined by the target, a suitable default will
+be chosen if (1) the target supports arbitrary section names, (2) the
+target defines @code{CTORS_SECTION_ASM_OP}, or (3) @code{USE_COLLECT2}
+is not defined.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_ASM_DESTRUCTOR (rtx @var{symbol}, int @var{priority})
+This is like @code{TARGET_ASM_CONSTRUCTOR} but used for termination
functions rather than initialization functions.
+@end deftypefn
-When @code{ASM_OUTPUT_CONSTRUCTOR} and @code{ASM_OUTPUT_DESTRUCTOR} are
-defined, the initialization routine generated for the generated object
-file will have static linkage.
-@end table
+If @code{TARGET_HAVE_CTORS_DTORS} is true, the initialization routine
+generated for the generated object file will have static linkage.
-If your system uses @code{collect2} as the means of processing
-constructors, then that program normally uses @code{nm} to scan an
-object file for constructor functions to be called. On such systems you
-must not define @code{ASM_OUTPUT_CONSTRUCTOR} and @code{ASM_OUTPUT_DESTRUCTOR}
-as the object file's initialization routine must have global scope.
+If your system uses @command{collect2} as the means of processing
+constructors, then that program normally uses @command{nm} to scan
+an object file for constructor functions to be called.
On certain kinds of systems, you can define these macros to make
-@code{collect2} work faster (and, in some cases, make it work at all):
+@command{collect2} work faster (and, in some cases, make it work at all):
@table @code
@findex OBJECT_FORMAT_COFF
@item OBJECT_FORMAT_COFF
Define this macro if the system uses COFF (Common Object File Format)
-object files, so that @code{collect2} can assume this format and scan
+object files, so that @command{collect2} can assume this format and scan
object files directly for dynamic constructor/destructor functions.
@findex OBJECT_FORMAT_ROSE
@item OBJECT_FORMAT_ROSE
Define this macro if the system uses ROSE format object files, so that
-@code{collect2} can assume this format and scan object files directly
+@command{collect2} can assume this format and scan object files directly
for dynamic constructor/destructor functions.
-These macros are effective only in a native compiler; @code{collect2} as
-part of a cross compiler always uses @code{nm} for the target machine.
+These macros are effective only in a native compiler; @command{collect2} as
+part of a cross compiler always uses @command{nm} for the target machine.
@findex REAL_NM_FILE_NAME
@item REAL_NM_FILE_NAME
Define this macro as a C string constant containing the file name to use
-to execute @code{nm}. The default is to search the path normally for
-@code{nm}.
+to execute @command{nm}. The default is to search the path normally for
+@command{nm}.
If your system supports shared libraries and has a program to list the
dynamic dependencies of a given library or executable, you can define
@@ -6747,8 +6730,8 @@ termination functions in shared libraries:
@findex LDD_SUFFIX
@item LDD_SUFFIX
-Define this macro to a C string constant containing the name of the
-program which lists dynamic dependencies, like @code{"ldd"} under SunOS 4.
+Define this macro to a C string constant containing the name of the program
+which lists dynamic dependencies, like @command{"ldd"} under SunOS 4.
@findex PARSE_LDD_OUTPUT
@item PARSE_LDD_OUTPUT (@var{ptr})
@@ -6758,7 +6741,6 @@ of type @code{char *} that points to the beginning of a line of output
from @code{LDD_SUFFIX}. If the line lists a dynamic dependency, the
code must advance @var{ptr} to the beginning of the filename on that
line. Otherwise, it must set @var{ptr} to @code{NULL}.
-
@end table
@node Instruction Output
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 7734a5f..7924574 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,9 @@
+2001-08-09 Richard Henderson <rth@redhat.com>
+
+ * Make-lang.in (class.o): Depend on TARGET_H.
+ * class.c (emit_register_classes): Use target hooks instead of
+ assemble_constructor and assemble_destructor.
+
2001-08-08 Alexandre Petit-Bianco <apbianco@redhat.com>
* check-init.c (flags.h): Include
diff --git a/gcc/java/Make-lang.in b/gcc/java/Make-lang.in
index 5768225..d0ae26c 100644
--- a/gcc/java/Make-lang.in
+++ b/gcc/java/Make-lang.in
@@ -245,7 +245,7 @@ java/buffer.o: java/buffer.c $(CONFIG_H) java/buffer.h $(SYSTEM_H) toplev.h
java/check-init.o: java/check-init.c $(CONFIG_H) \
$(JAVA_TREE_H) $(SYSTEM_H) toplev.h
java/class.o: java/class.c $(CONFIG_H) $(JAVA_TREE_H) $(RTL_H) java/jcf.h \
- java/parse.h toplev.h $(SYSTEM_H) output.h $(GGC_H)
+ java/parse.h toplev.h $(SYSTEM_H) output.h $(GGC_H) $(TARGET_H) function.h
java/constants.o: java/constants.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h \
toplev.h $(SYSTEM_H) $(GGC_H)
java/decl.o: java/decl.c $(CONFIG_H) $(JAVA_TREE_H) java/jcf.h \
diff --git a/gcc/java/class.c b/gcc/java/class.c
index 7e153b5..0e46a78 100644
--- a/gcc/java/class.c
+++ b/gcc/java/class.c
@@ -36,6 +36,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
#include "toplev.h"
#include "output.h"
#include "parse.h"
+#include "function.h"
#include "ggc.h"
#include "target.h"
@@ -1881,6 +1882,9 @@ register_class ()
void
emit_register_classes ()
{
+ /* ??? This isn't quite the correct test. We also have to know
+ that the target is using gcc's crtbegin/crtend objects rather
+ than the ones that come with the operating system. */
if (SUPPORTS_WEAK && targetm.have_named_sections)
{
tree t;
@@ -1902,29 +1906,37 @@ emit_register_classes ()
SET_DECL_ASSEMBLER_NAME (init_decl, init_name);
TREE_STATIC (init_decl) = 1;
current_function_decl = init_decl;
- DECL_RESULT (init_decl) = build_decl(RESULT_DECL, NULL_TREE, void_type_node);
- /* DECL_EXTERNAL (init_decl) = 1;*/
- TREE_PUBLIC (init_decl) = 1;
+ DECL_RESULT (init_decl) = build_decl (RESULT_DECL, NULL_TREE,
+ void_type_node);
+
+ /* It can be a static function as long as collect2 does not have
+ to scan the object file to find its ctor/dtor routine. */
+ TREE_PUBLIC (init_decl) = ! targetm.have_ctors_dtors;
+
+ /* Suppress spurious warnings. */
+ TREE_USED (init_decl) = 1;
+
pushlevel (0);
make_decl_rtl (init_decl, NULL);
init_function_start (init_decl, input_filename, 0);
expand_function_start (init_decl, 0);
-
+
+ /* Do not allow the function to be deferred. */
+ current_function_cannot_inline
+ = "static constructors and destructors cannot be inlined";
+
for ( t = registered_class; t; t = TREE_CHAIN (t))
emit_library_call (registerClass_libfunc, 0, VOIDmode, 1,
XEXP (DECL_RTL (t), 0), Pmode);
expand_function_end (input_filename, 0, 0);
poplevel (1, 0, 1);
- {
- /* Force generation, even with -O3 or deeper. Gross hack. FIXME */
- int saved_flag = flag_inline_functions;
- flag_inline_functions = 0;
- rest_of_compilation (init_decl);
- flag_inline_functions = saved_flag;
- }
+ rest_of_compilation (init_decl);
current_function_decl = NULL_TREE;
- assemble_constructor (XEXP (DECL_RTL (init_decl), 0), DEFAULT_INIT_PRIORITY);
+
+ if (targetm.have_ctors_dtors)
+ (* targetm.asm_out.constructor) (XEXP (DECL_RTL (init_decl), 0),
+ DEFAULT_INIT_PRIORITY);
}
}
diff --git a/gcc/objc/Make-lang.in b/gcc/objc/Make-lang.in
index bd2437d..824870b 100644
--- a/gcc/objc/Make-lang.in
+++ b/gcc/objc/Make-lang.in
@@ -77,7 +77,7 @@ $(srcdir)/objc/objc-parse.y: $(srcdir)/c-parse.in
$(SHELL) $(srcdir)/move-if-change tmp-objc-prs.y $(srcdir)/objc/objc-parse.y
objc-act.o : $(srcdir)/objc/objc-act.c \
- $(CONFIG_H) $(TREE_H) $(RTL_H) $(SYSTEM_H) $(EXPR_H) \
+ $(CONFIG_H) $(TREE_H) $(RTL_H) $(SYSTEM_H) $(EXPR_H) $(TARGET_H) \
$(srcdir)/c-tree.h $(srcdir)/c-common.h $(srcdir)/c-lex.h \
$(srcdir)/toplev.h $(srcdir)/flags.h $(srcdir)/objc/objc-act.h \
$(srcdir)/input.h $(srcdir)/function.h $(srcdir)/output.h $(srcdir)/debug.h
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 67e4000..c0b14b5 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -57,6 +57,7 @@ Boston, MA 02111-1307, USA. */
#include "ggc.h"
#include "cpplib.h"
#include "debug.h"
+#include "target.h"
/* This is the default way of generating a method name. */
/* I am not sure it is really correct.
@@ -1913,60 +1914,51 @@ build_module_descriptor ()
return NULL_RTX;
{
- tree parms, function_decl, decelerator, void_list_node_1;
- tree function_type;
- tree init_function_name = get_file_function_name ('I');
+ tree parms, execclass_decl, decelerator, void_list_node_1;
+ tree init_function_name, init_function_decl;
/* Declare void __objc_execClass (void *); */
void_list_node_1 = build_tree_list (NULL_TREE, void_type_node);
- function_type
- = build_function_type (void_type_node,
- tree_cons (NULL_TREE, ptr_type_node,
- void_list_node_1));
- function_decl = build_decl (FUNCTION_DECL,
- get_identifier (TAG_EXECCLASS),
- function_type);
- DECL_EXTERNAL (function_decl) = 1;
- DECL_ARTIFICIAL (function_decl) = 1;
- TREE_PUBLIC (function_decl) = 1;
-
- pushdecl (function_decl);
- rest_of_decl_compilation (function_decl, 0, 0, 0);
-
- parms
- = build_tree_list (NULL_TREE,
- build_unary_op (ADDR_EXPR, UOBJC_MODULES_decl, 0));
- decelerator = build_function_call (function_decl, parms);
+ execclass_decl = build_decl (FUNCTION_DECL,
+ get_identifier (TAG_EXECCLASS),
+ build_function_type (void_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ void_list_node_1)));
+ DECL_EXTERNAL (execclass_decl) = 1;
+ DECL_ARTIFICIAL (execclass_decl) = 1;
+ TREE_PUBLIC (execclass_decl) = 1;
+ pushdecl (execclass_decl);
+ rest_of_decl_compilation (execclass_decl, 0, 0, 0);
+ assemble_external (execclass_decl);
/* void _GLOBAL_$I$<gnyf> () {objc_execClass (&L_OBJC_MODULES);} */
+ init_function_name = get_file_function_name ('I');
start_function (void_list_node_1,
build_nt (CALL_EXPR, init_function_name,
- /* This has the format of the output
- of get_parm_info. */
tree_cons (NULL_TREE, NULL_TREE,
void_list_node_1),
NULL_TREE),
NULL_TREE);
-#if 0 /* This should be turned back on later
- for the systems where collect is not needed. */
- /* Make these functions nonglobal
- so each file can use the same name. */
- TREE_PUBLIC (current_function_decl) = 0;
-#endif
- TREE_USED (current_function_decl) = 1;
store_parm_decls ();
- assemble_external (function_decl);
- c_expand_expr_stmt (decelerator);
+ init_function_decl = current_function_decl;
+ TREE_PUBLIC (init_function_decl) = ! targetm.have_ctors_dtors;
+ TREE_USED (init_function_decl) = 1;
+ current_function_cannot_inline
+ = "static constructors and destructors cannot be inlined";
- TREE_PUBLIC (current_function_decl) = 1;
+ parms
+ = build_tree_list (NULL_TREE,
+ build_unary_op (ADDR_EXPR, UOBJC_MODULES_decl, 0));
+ decelerator = build_function_call (execclass_decl, parms);
+
+ c_expand_expr_stmt (decelerator);
- function_decl = current_function_decl;
finish_function (0);
- return XEXP (DECL_RTL (function_decl), 0);
+ return XEXP (DECL_RTL (init_function_decl), 0);
}
}
@@ -8360,8 +8352,8 @@ finish_objc ()
{
/* Arrange for Objc data structures to be initialized at run time. */
rtx init_sym = build_module_descriptor ();
- if (init_sym)
- assemble_constructor (init_sym, DEFAULT_INIT_PRIORITY);
+ if (init_sym && targetm.have_ctors_dtors)
+ (* targetm.asm_out.constructor) (init_sym, DEFAULT_INIT_PRIORITY);
}
/* Dump the class references. This forces the appropriate classes
diff --git a/gcc/output.h b/gcc/output.h
index 1b4601e..a72f80d 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -257,15 +257,6 @@ extern void assemble_variable PARAMS ((tree, int, int, int));
extern void assemble_external PARAMS ((tree));
#endif /* TREE_CODE */
-#ifdef RTX_CODE
-/* Record an element in the table of global destructors. The argument
- should be a SYMBOL_REF of the function to be called. */
-extern void assemble_destructor PARAMS ((rtx, int));
-
-/* Likewise for global constructors. */
-extern void assemble_constructor PARAMS ((rtx, int));
-#endif
-
/* Assemble code to leave SIZE bytes of zeros. */
extern void assemble_zeros PARAMS ((int));
@@ -476,3 +467,13 @@ extern void default_coff_asm_named_section PARAMS ((const char *, unsigned int,
extern void default_pe_asm_named_section PARAMS ((const char *, unsigned int,
unsigned int));
+extern void default_stabs_asm_out_destructor PARAMS ((struct rtx_def *, int));
+extern void default_named_section_asm_out_destructor PARAMS ((struct rtx_def *,
+ int));
+extern void default_dtor_section_asm_out_destructor PARAMS ((struct rtx_def *,
+ int));
+extern void default_stabs_asm_out_constructor PARAMS ((struct rtx_def *, int));
+extern void default_named_section_asm_out_constructor PARAMS ((struct rtx_def *,
+ int));
+extern void default_ctor_section_asm_out_constructor PARAMS ((struct rtx_def *,
+ int));
diff --git a/gcc/profile.c b/gcc/profile.c
index 983df43..dbde892 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -48,6 +48,7 @@ Boston, MA 02111-1307, USA. */
#include "hard-reg-set.h"
#include "basic-block.h"
#include "gcov-io.h"
+#include "target.h"
/* Additional information about the edges we need. */
struct edge_info
@@ -1122,13 +1123,11 @@ output_func_start_profiler ()
build_function_type (void_type_node, NULL_TREE));
DECL_EXTERNAL (fndecl) = 0;
-#if defined(ASM_OUTPUT_CONSTRUCTOR) && defined(ASM_OUTPUT_DESTRUCTOR)
/* It can be a static function as long as collect2 does not have
to scan the object file to find its ctor/dtor routine. */
- TREE_PUBLIC (fndecl) = 0;
-#else
- TREE_PUBLIC (fndecl) = 1;
-#endif
+ TREE_PUBLIC (fndecl) = ! targetm.have_ctors_dtors;
+
+ TREE_USED (fndecl) = 1;
DECL_RESULT (fndecl) = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
@@ -1176,5 +1175,7 @@ output_func_start_profiler ()
fflush (asm_out_file);
current_function_decl = NULL_TREE;
- assemble_constructor (XEXP (DECL_RTL (fndecl), 0), DEFAULT_INIT_PRIORITY);
+ if (targetm.have_ctors_dtors)
+ (* targetm.asm_out.constructor) (XEXP (DECL_RTL (fndecl), 0),
+ DEFAULT_INIT_PRIORITY);
}
diff --git a/gcc/target-def.h b/gcc/target-def.h
index 939ca8f..94f8d10 100644
--- a/gcc/target-def.h
+++ b/gcc/target-def.h
@@ -33,6 +33,38 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define TARGET_ASM_FUNCTION_END_PROLOGUE no_asm_to_stream
#define TARGET_ASM_FUNCTION_BEGIN_EPILOGUE no_asm_to_stream
+#if !defined(TARGET_ASM_CONSTRUCTOR) && !defined(USE_COLLECT2)
+# ifdef CTORS_SECTION_ASM_OP
+# define TARGET_ASM_CONSTRUCTOR default_ctor_section_asm_out_constructor
+# else
+# ifdef TARGET_ASM_NAMED_SECTION
+# define TARGET_ASM_CONSTRUCTOR default_named_section_asm_out_constructor
+# else
+# define TARGET_ASM_CONSTRUCTOR default_stabs_asm_out_constructor
+# endif
+# endif
+#endif
+
+#if !defined(TARGET_ASM_DESTRUCTOR) && !defined(USE_COLLECT2)
+# ifdef DTORS_SECTION_ASM_OP
+# define TARGET_ASM_DESTRUCTOR default_dtor_section_asm_out_destructor
+# else
+# ifdef TARGET_ASM_NAMED_SECTION
+# define TARGET_ASM_DESTRUCTOR default_named_section_asm_out_destructor
+# else
+# define TARGET_ASM_DESTRUCTOR default_stabs_asm_out_destructor
+# endif
+# endif
+#endif
+
+#if defined(TARGET_ASM_CONSTRUCTOR) && defined(TARGET_ASM_DESTRUCTOR)
+#define TARGET_HAVE_CTORS_DTORS true
+#else
+#define TARGET_HAVE_CTORS_DTORS false
+#define TARGET_ASM_CONSTRUCTOR NULL
+#define TARGET_ASM_DESTRUCTOR NULL
+#endif
+
#ifdef TARGET_ASM_NAMED_SECTION
#define TARGET_HAVE_NAMED_SECTIONS true
#else
@@ -46,7 +78,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
TARGET_ASM_FUNCTION_END_PROLOGUE, \
TARGET_ASM_FUNCTION_BEGIN_EPILOGUE, \
TARGET_ASM_FUNCTION_EPILOGUE, \
- TARGET_ASM_NAMED_SECTION}
+ TARGET_ASM_NAMED_SECTION, \
+ TARGET_ASM_CONSTRUCTOR, \
+ TARGET_ASM_DESTRUCTOR}
/* All in tree.c. */
#define TARGET_MERGE_DECL_ATTRIBUTES merge_decl_attributes
@@ -80,5 +114,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
TARGET_INIT_BUILTINS, \
TARGET_EXPAND_BUILTIN, \
TARGET_SECTION_TYPE_FLAGS, \
- TARGET_HAVE_NAMED_SECTIONS \
+ TARGET_HAVE_NAMED_SECTIONS, \
+ TARGET_HAVE_CTORS_DTORS \
}
diff --git a/gcc/target.h b/gcc/target.h
index d3f32fa..3e9b46c 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -72,6 +72,12 @@ struct gcc_target
the section; 0 if the default should be used. */
void (* named_section) PARAMS ((const char *, unsigned int,
unsigned int));
+
+ /* Output a constructor for a symbol with a given priority. */
+ void (* constructor) PARAMS ((struct rtx_def *, int));
+
+ /* Output a destructor for a symbol with a given priority. */
+ void (* destructor) PARAMS ((struct rtx_def *, int));
} asm_out;
/* Given two decls, merge their attributes and return the result. */
@@ -120,6 +126,10 @@ struct gcc_target
/* True if arbitrary sections are supported. */
bool have_named_sections;
+
+ /* True if "native" constructors and destructors are supported,
+ false if we're using collect2 for the job. */
+ bool have_ctors_dtors;
};
extern struct gcc_target targetm;
diff --git a/gcc/varasm.c b/gcc/varasm.c
index d031bd1..7480cf6 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -188,6 +188,12 @@ static enum in_section { no_section, in_text, in_data, in_named
#ifdef BSS_SECTION_ASM_OP
, in_bss
#endif
+#ifdef CTORS_SECTION_ASM_OP
+ , in_ctors
+#endif
+#ifdef DTORS_SECTION_ASM_OP
+ , in_dtors
+#endif
#ifdef EXTRA_SECTIONS
, EXTRA_SECTIONS
#endif
@@ -813,88 +819,127 @@ assemble_asm (string)
fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string));
}
-/* Record an element in the table of global destructors. The argument
- should be a SYMBOL_REF of the function to be called. */
+/* Record an element in the table of global destructors. SYMBOL is
+ a SYMBOL_REF of the function to be called; PRIORITY is a number
+ between 0 and MAX_INIT_PRIORITY. */
void
-assemble_destructor (symbol, priority)
+default_stabs_asm_out_destructor (symbol, priority)
rtx symbol;
- int priority;
+ int priority ATTRIBUTE_UNUSED;
{
- const char *name;
+ /* Tell GNU LD that this is part of the static destructor set.
+ This will work for any system that uses stabs, most usefully
+ aout systems. */
+ fprintf (asm_out_file, "%s\"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP);
+ assemble_name (asm_out_file, XSTR (symbol, 0));
+ fputc ('\n', asm_out_file);
+}
- if (GET_CODE (symbol) != SYMBOL_REF)
- abort ();
- name = XSTR (symbol, 0);
+void
+default_named_section_asm_out_destructor (symbol, priority)
+ rtx symbol;
+ int priority;
+{
+ const char *section = ".dtors";
+ char buf[16];
- if (priority != DEFAULT_INIT_PRIORITY
- && targetm.have_named_sections)
+ /* ??? This only works reliably with the GNU linker. */
+ if (priority != DEFAULT_INIT_PRIORITY)
{
- char buf[15];
sprintf (buf, ".dtors.%.5u",
/* Invert the numbering so the linker puts us in the proper
order; constructors are run from right to left, and the
linker sorts in increasing order. */
MAX_INIT_PRIORITY - priority);
- named_section_flags (buf, SECTION_WRITE, POINTER_SIZE / BITS_PER_UNIT);
- assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1);
- return;
+ section = buf;
}
-#ifdef ASM_OUTPUT_DESTRUCTOR
- ASM_OUTPUT_DESTRUCTOR (asm_out_file, name);
-#else
- if (flag_gnu_linker)
+ named_section_flags (section, SECTION_WRITE, POINTER_SIZE / BITS_PER_UNIT);
+ assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1);
+}
+
+#ifdef DTORS_SECTION_ASM_OP
+void
+dtors_section ()
+{
+ if (in_section != in_dtors)
{
- /* Now tell GNU LD that this is part of the static destructor set. */
- /* This code works for any machine provided you use GNU as/ld. */
- fprintf (asm_out_file, "%s\"___DTOR_LIST__\",22,0,0,", ASM_STABS_OP);
- assemble_name (asm_out_file, name);
+ in_section = in_dtors;
+ fputs (DTORS_SECTION_ASM_OP, asm_out_file);
fputc ('\n', asm_out_file);
}
-#endif
}
+void
+default_dtor_section_asm_out_destructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ dtors_section ();
+ assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1);
+}
+#endif
+
/* Likewise for global constructors. */
void
-assemble_constructor (symbol, priority)
+default_stabs_asm_out_constructor (symbol, priority)
rtx symbol;
- int priority;
+ int priority ATTRIBUTE_UNUSED;
{
- const char *name;
+ /* Tell GNU LD that this is part of the static destructor set.
+ This will work for any system that uses stabs, most usefully
+ aout systems. */
+ fprintf (asm_out_file, "%s\"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP);
+ assemble_name (asm_out_file, XSTR (symbol, 0));
+ fputc ('\n', asm_out_file);
+}
- if (GET_CODE (symbol) != SYMBOL_REF)
- abort ();
- name = XSTR (symbol, 0);
+void
+default_named_section_asm_out_constructor (symbol, priority)
+ rtx symbol;
+ int priority;
+{
+ const char *section = ".ctors";
+ char buf[16];
- if (priority != DEFAULT_INIT_PRIORITY
- && targetm.have_named_sections)
+ /* ??? This only works reliably with the GNU linker. */
+ if (priority != DEFAULT_INIT_PRIORITY)
{
- char buf[15];
sprintf (buf, ".ctors.%.5u",
/* Invert the numbering so the linker puts us in the proper
order; constructors are run from right to left, and the
linker sorts in increasing order. */
MAX_INIT_PRIORITY - priority);
- named_section_flags (buf, SECTION_WRITE, POINTER_SIZE / BITS_PER_UNIT);
- assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1);
- return;
+ section = buf;
}
-#ifdef ASM_OUTPUT_CONSTRUCTOR
- ASM_OUTPUT_CONSTRUCTOR (asm_out_file, name);
-#else
- if (flag_gnu_linker)
+ named_section_flags (section, SECTION_WRITE, POINTER_SIZE / BITS_PER_UNIT);
+ assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1);
+}
+
+#ifdef CTORS_SECTION_ASM_OP
+void
+ctors_section ()
+{
+ if (in_section != in_ctors)
{
- /* Now tell GNU LD that this is part of the static constructor set. */
- /* This code works for any machine provided you use GNU as/ld. */
- fprintf (asm_out_file, "%s\"___CTOR_LIST__\",22,0,0,", ASM_STABS_OP);
- assemble_name (asm_out_file, name);
+ in_section = in_ctors;
+ fputs (CTORS_SECTION_ASM_OP, asm_out_file);
fputc ('\n', asm_out_file);
}
-#endif
}
+
+void
+default_ctor_section_asm_out_constructor (symbol, priority)
+ rtx symbol;
+ int priority ATTRIBUTE_UNUSED;
+{
+ ctors_section ();
+ assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, 1);
+}
+#endif
/* CONSTANT_POOL_BEFORE_FUNCTION may be defined as an expression with
a non-zero value if the constant pool should be output before the