aboutsummaryrefslogtreecommitdiff
path: root/gcc/crtstuff.c
diff options
context:
space:
mode:
authorH.J. Lu <hongjiu.lu@intel.com>2011-08-20 20:02:17 +0000
committerH.J. Lu <hjl@gcc.gnu.org>2011-08-20 13:02:17 -0700
commit9ce7ad7f3a7f61fd62ac81544af04f95368f597f (patch)
tree3906273c1671420742bbbcd2e6b652c9b3f19c95 /gcc/crtstuff.c
parent13001f33ca62776df6dddf738d6f3f8633c3f3a9 (diff)
downloadgcc-9ce7ad7f3a7f61fd62ac81544af04f95368f597f.zip
gcc-9ce7ad7f3a7f61fd62ac81544af04f95368f597f.tar.gz
gcc-9ce7ad7f3a7f61fd62ac81544af04f95368f597f.tar.bz2
Use .init_arrary/.fini_array sections if possible.
2011-08-20 H.J. Lu <hongjiu.lu@intel.com> PR other/46770 * config.gcc (tm_file): Add initfini-array.h if .init_arrary/.fini_array are supported. * crtstuff.c: Don't generate .ctors nor .dtors sections if USE_INITFINI_ARRAY is defined. * output.h (default_elf_init_array_asm_out_constructor): New. (default_elf_fini_array_asm_out_destructor): Likewise. * varasm.c (elf_init_array_section): Likewise. (elf_fini_array_section): Likewise. (get_elf_initfini_array_priority_section): Likewise. (default_elf_init_array_asm_out_constructor): Likewise. (default_elf_fini_array_asm_out_destructor): Likewise. * config/initfini-array.h: New. From-SVN: r177933
Diffstat (limited to 'gcc/crtstuff.c')
-rw-r--r--gcc/crtstuff.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/crtstuff.c b/gcc/crtstuff.c
index b65f490..010d472 100644
--- a/gcc/crtstuff.c
+++ b/gcc/crtstuff.c
@@ -1,7 +1,8 @@
/* Specialized bits of code needed to support construction and
destruction of file-scope objects in C++ code.
Copyright (C) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
- 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+ 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011
+ Free Software Foundation, Inc.
Contributed by Ron Guilmette (rfg@monkeys.com).
This file is part of GCC.
@@ -189,6 +190,9 @@ typedef void (*func_ptr) (void);
refer to only the __CTOR_END__ symbol in crtend.o and the __DTOR_LIST__
symbol in crtbegin.o, where they are defined. */
+/* No need for .ctors/.dtors section if linker can place them in
+ .init_array/.fini_array section. */
+#ifndef USE_INITFINI_ARRAY
/* 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
@@ -219,6 +223,7 @@ STATIC func_ptr __DTOR_LIST__[1]
__attribute__((section(".dtors"), aligned(sizeof(func_ptr))))
= { (func_ptr) (-1) };
#endif /* __DTOR_LIST__ alternatives */
+#endif /* USE_INITFINI_ARRAY */
#ifdef USE_EH_FRAME_REGISTRY
/* Stick a label at the beginning of the frame unwind info so we can register
@@ -489,6 +494,9 @@ __do_global_ctors_1(void)
#elif defined(CRT_END) /* ! CRT_BEGIN */
+/* No need for .ctors/.dtors section if linker can place them in
+ .init_array/.fini_array section. */
+#ifndef USE_INITFINI_ARRAY
/* 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
@@ -534,6 +542,7 @@ STATIC func_ptr __DTOR_END__[1]
__attribute__((used, section(".dtors"), aligned(sizeof(func_ptr))))
= { (func_ptr) 0 };
#endif
+#endif /* USE_INITFINI_ARRAY */
#ifdef EH_FRAME_SECTION_NAME
/* Terminate the frame unwind info section with a 4byte 0 as a sentinel;