diff options
| author | Jing Yu <jingyu@google.com> | 2012-02-22 14:58:28 -0800 |
|---|---|---|
| committer | Jing Yu <jingyu@google.com> | 2012-02-22 14:58:28 -0800 |
| commit | fb15b4c077bef8a9ee6c969273b05645ce4ed6a1 (patch) | |
| tree | 457ca88c07e2da2578ac6a9bbe2ad952387f3f2c | |
| parent | 3f73d6ef90458b45bbbb33ef4c2b174d4662a22d (diff) | |
| download | toolchain_gcc-fb15b4c077bef8a9ee6c969273b05645ce4ed6a1.tar.gz toolchain_gcc-fb15b4c077bef8a9ee6c969273b05645ce4ed6a1.tar.bz2 toolchain_gcc-fb15b4c077bef8a9ee6c969273b05645ce4ed6a1.zip | |
.init_array/.fini_array patch for Android/x86
Backport from gcc mainline r177933, r175181, r177963, r178116, r183299.
| -rw-r--r-- | gcc-4.6/gcc/ChangeLog.google-4_6 | 58 | ||||
| -rw-r--r-- | gcc-4.6/gcc/acinclude.m4 | 79 | ||||
| -rw-r--r-- | gcc-4.6/gcc/config/initfini-array.h | 41 | ||||
| -rwxr-xr-x | gcc-4.6/gcc/configure | 180 | ||||
| -rw-r--r-- | gcc-4.6/gcc/configure.ac | 9 | ||||
| -rw-r--r-- | gcc-4.6/gcc/crtstuff.c | 11 | ||||
| -rw-r--r-- | gcc-4.6/gcc/output.h | 2 | ||||
| -rw-r--r-- | gcc-4.6/gcc/varasm.c | 58 |
8 files changed, 385 insertions, 53 deletions
diff --git a/gcc-4.6/gcc/ChangeLog.google-4_6 b/gcc-4.6/gcc/ChangeLog.google-4_6 index ae66f5584..88867a32c 100644 --- a/gcc-4.6/gcc/ChangeLog.google-4_6 +++ b/gcc-4.6/gcc/ChangeLog.google-4_6 @@ -1,3 +1,61 @@ +2012-02-21 Jing Yu <jingyu@google.com> + + Bakcport r175181, r177963, r178116, r183299 from mainline. + + 2011-06-18 H.J. Lu <hongjiu.lu@intel.com> + PR other/49325 + * acinclude.m4 (gcc_AC_INITFINI_ARRAY): Properly check if + .init_array can be used with .ctors on targets. + * configure: Regenerated. + + 2011-08-22 H.J. Lu <hongjiu.lu@intel.com> + * acinclude.m4 (gcc_AC_INITFINI_ARRAY): Error if __ELF__ isn't + defined. + * configure: Regenerated. + + 2011-08-26 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> + PR target/50166 + * acinclude.m4 (gcc_AC_INITFINI_ARRAY): Check count in main. + * configure: Regenerate. + + 2012-01-19 Jakub Jelinek <jakub@redhat.com> + PR bootstrap/50237 + * config/initfini-array.h: Guard content of the header + with #ifdef HAVE_INITFINI_ARRAY. + * configure.ac: Move gcc_AC_INITFINI_ARRAY much later into the + file. + Add initfini-array.h to tm_file here. + * acinclude.m4 (gcc_AC_INITFINI_ARRAY): For non-ia64 do a + linker test. + * config.gcc: Don't add initfini-array.h to tm_file here. + * configure: Regenerated. + +2012-02-19 Ollie Wild <aaw@google.com> + + * initfini-array.h: Moved to config/initfini-array.h. + * config/initfini-array.h: New. + +2012-02-17 Jing Yu <jingyu@google.com> + Google Ref 47894 + + 2011-12-07 H.J. Lu <hongjiu.lu@intel.com> + Backport from mainline r177933. + 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. + 2012-02-14 Jing Yu <jingyu@google.com> Backport r184226 from google/main (Google ref 42402-p2) diff --git a/gcc-4.6/gcc/acinclude.m4 b/gcc-4.6/gcc/acinclude.m4 index 3eec559e8..334839b1d 100644 --- a/gcc-4.6/gcc/acinclude.m4 +++ b/gcc-4.6/gcc/acinclude.m4 @@ -375,13 +375,86 @@ AC_DEFUN([gcc_AC_INITFINI_ARRAY], [], [ AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support, gcc_cv_initfini_array, [dnl - AC_RUN_IFELSE([AC_LANG_SOURCE([ + if test "x${build}" = "x${target}" && test "x${build}" = "x${host}"; then + case "${target}" in + ia64-*) + AC_RUN_IFELSE([AC_LANG_SOURCE([ +#ifndef __ELF__ +#error Not an ELF OS +#endif +/* We turn on .preinit_array/.init_array/.fini_array support for ia64 + if it can be used. */ static int x = -1; int main (void) { return x; } int foo (void) { x = 0; } -int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;])], +int (*fp) (void) __attribute__ ((section (".init_array"))) = foo; +])], [gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no], - [gcc_cv_initfini_array=no])]) + [gcc_cv_initfini_array=no]);; + *) + gcc_cv_initfini_array=no + if test $in_tree_ld = yes ; then + if test "$gcc_cv_gld_major_version" -eq 2 \ + -a "$gcc_cv_gld_minor_version" -ge 22 \ + -o "$gcc_cv_gld_major_version" -gt 2 \ + && test $in_tree_ld_is_elf = yes; then + gcc_cv_initfini_array=yes + fi + elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then + cat > conftest.s <<\EOF +.section .dtors,"a",%progbits +.balign 4 +.byte 'A', 'A', 'A', 'A' +.section .ctors,"a",%progbits +.balign 4 +.byte 'B', 'B', 'B', 'B' +.section .fini_array.65530,"a",%progbits +.balign 4 +.byte 'C', 'C', 'C', 'C' +.section .init_array.65530,"a",%progbits +.balign 4 +.byte 'D', 'D', 'D', 'D' +.section .dtors.64528,"a",%progbits +.balign 4 +.byte 'E', 'E', 'E', 'E' +.section .ctors.64528,"a",%progbits +.balign 4 +.byte 'F', 'F', 'F', 'F' +.section .fini_array.01005,"a",%progbits +.balign 4 +.byte 'G', 'G', 'G', 'G' +.section .init_array.01005,"a",%progbits +.balign 4 +.byte 'H', 'H', 'H', 'H' +.text +EOF + if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \ + && $gcc_cv_ld -e 0 -o conftest conftest.o > /dev/null 2>&1 \ + && $gcc_cv_objdump -s -j .init_array conftest \ + | grep HHHHFFFFDDDDBBBB > /dev/null 2>&1 \ + && $gcc_cv_objdump -s -j .fini_array conftest \ + | grep GGGGEEEECCCCAAAA > /dev/null 2>&1; then + gcc_cv_initfini_array=yes + fi +changequote(,)dnl + rm -f conftest conftest.* +changequote([,])dnl + fi + AC_PREPROC_IFELSE([AC_LANG_SOURCE([ +#ifndef __ELF__ +#error Not an ELF OS +#endif +#include <stdlib.h> +#if defined __GLIBC_PREREQ && __GLIBC_PREREQ (2, 4) +#else +#error The C library not known to support .init_array/.fini_array +#endif +])],, [gcc_cv_initfini_array=no]);; + esac + else + AC_MSG_CHECKING(cross compile... guessing) + gcc_cv_initfini_array=no + fi]) enable_initfini_array=$gcc_cv_initfini_array ]) if test $enable_initfini_array = yes; then diff --git a/gcc-4.6/gcc/config/initfini-array.h b/gcc-4.6/gcc/config/initfini-array.h new file mode 100644 index 000000000..bb48c70a9 --- /dev/null +++ b/gcc-4.6/gcc/config/initfini-array.h @@ -0,0 +1,41 @@ +/* Definitions for ELF systems with .init_array/.fini_array section + support. + Copyright (C) 2011, 2012 + Free Software Foundation, Inc. + + This file is part of GCC. + + GCC 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 3, or (at your + option) any later version. + + GCC 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 GCC; see the file COPYING3. If not see + <http://www.gnu.org/licenses/>. */ + +#ifdef HAVE_INITFINI_ARRAY + +#define USE_INITFINI_ARRAY + +#undef INIT_SECTION_ASM_OP +#undef FINI_SECTION_ASM_OP + +#undef INIT_ARRAY_SECTION_ASM_OP +#define INIT_ARRAY_SECTION_ASM_OP + +#undef FINI_ARRAY_SECTION_ASM_OP +#define FINI_ARRAY_SECTION_ASM_OP + +/* Use .init_array/.fini_array section for constructors and destructors. */ +#undef TARGET_ASM_CONSTRUCTOR +#define TARGET_ASM_CONSTRUCTOR default_elf_init_array_asm_out_constructor +#undef TARGET_ASM_DESTRUCTOR +#define TARGET_ASM_DESTRUCTOR default_elf_fini_array_asm_out_destructor + +#endif diff --git a/gcc-4.6/gcc/configure b/gcc-4.6/gcc/configure index 1438b948a..19701575d 100755 --- a/gcc-4.6/gcc/configure +++ b/gcc-4.6/gcc/configure @@ -894,7 +894,6 @@ enable_languages with_multilib_list enable_rpath with_libiconv_prefix -enable_initfini_array enable_sjlj_exceptions with_system_libunwind enable_secureplt @@ -908,6 +907,7 @@ enable_fast_install enable_libtool_lock with_plugin_ld enable_gnu_indirect_function +enable_initfini_array enable_comdat enable_gnu_unique_object enable_linker_build_id @@ -1595,7 +1595,6 @@ Optional Features: --disable-shared don't provide a shared libgcc --enable-languages=LIST specify which front-ends to build --disable-rpath do not hardcode runtime library paths - --enable-initfini-array use .init_array/.fini_array sections --enable-sjlj-exceptions arrange to use setjmp/longjmp exception handling --enable-secureplt enable -msecure-plt by default for PowerPC @@ -1618,6 +1617,7 @@ Optional Features: --enable-gnu-indirect-function enable the use of the @gnu_indirect_function to glibc systems + --enable-initfini-array use .init_array/.fini_array sections --enable-comdat enable COMDAT group support --enable-gnu-unique-object enable the use of the @gnu_unique_object ELF @@ -10494,49 +10494,6 @@ fi # Restore CFLAGS from before the gcc_AC_NEED_DECLARATIONS tests. CFLAGS="$saved_CFLAGS" -# Check whether --enable-initfini-array was given. -if test "${enable_initfini_array+set}" = set; then : - enableval=$enable_initfini_array; -else - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for .preinit_array/.init_array/.fini_array support" >&5 -$as_echo_n "checking for .preinit_array/.init_array/.fini_array support... " >&6; } -if test "${gcc_cv_initfini_array+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - gcc_cv_initfini_array=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -static int x = -1; -int main (void) { return x; } -int foo (void) { x = 0; } -int (*fp) (void) __attribute__ ((section (".init_array"))) = foo; -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - gcc_cv_initfini_array=yes -else - gcc_cv_initfini_array=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_initfini_array" >&5 -$as_echo "$gcc_cv_initfini_array" >&6; } - enable_initfini_array=$gcc_cv_initfini_array - -fi - -if test $enable_initfini_array = yes; then - -$as_echo "#define HAVE_INITFINI_ARRAY 1" >>confdefs.h - -fi - # mkdir takes a single argument on some systems. { $as_echo "$as_me:${as_lineno-$LINENO}: checking if mkdir takes one argument" >&5 $as_echo_n "checking if mkdir takes one argument... " >&6; } @@ -10695,6 +10652,11 @@ if test x"$tmake_file" = x then tmake_file=$cpu_type/t-$cpu_type fi +# Support --enable-initfini-array. +if test x$enable_initfini_array != xno; then + tm_file="${tm_file} initfini-array.h" +fi + if test x"$dwarf2" = xyes then tm_file="$tm_file tm-dwarf2.h" fi @@ -17572,7 +17534,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17575 "configure" +#line 17537 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -17678,7 +17640,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17681 "configure" +#line 17643 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -21943,6 +21905,130 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_ro_rw_mix" >&5 $as_echo "$gcc_cv_ld_ro_rw_mix" >&6; } +# Check whether --enable-initfini-array was given. +if test "${enable_initfini_array+set}" = set; then : + enableval=$enable_initfini_array; +else + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for .preinit_array/.init_array/.fini_array support" >&5 +$as_echo_n "checking for .preinit_array/.init_array/.fini_array support... " >&6; } +if test "${gcc_cv_initfini_array+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test "x${build}" = "x${target}" && test "x${build}" = "x${host}"; then + case "${target}" in + ia64-*) + if test "$cross_compiling" = yes; then : + gcc_cv_initfini_array=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifndef __ELF__ +#error Not an ELF OS +#endif +/* We turn on .preinit_array/.init_array/.fini_array support for ia64 + if it can be used. */ +static int x = -1; +int main (void) { return x; } +int foo (void) { x = 0; } +int (*fp) (void) __attribute__ ((section (".init_array"))) = foo; + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gcc_cv_initfini_array=yes +else + gcc_cv_initfini_array=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi +;; + *) + gcc_cv_initfini_array=no + if test $in_tree_ld = yes ; then + if test "$gcc_cv_gld_major_version" -eq 2 \ + -a "$gcc_cv_gld_minor_version" -ge 22 \ + -o "$gcc_cv_gld_major_version" -gt 2 \ + && test $in_tree_ld_is_elf = yes; then + gcc_cv_initfini_array=yes + fi + elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then + cat > conftest.s <<\EOF +.section .dtors,"a",%progbits +.balign 4 +.byte 'A', 'A', 'A', 'A' +.section .ctors,"a",%progbits +.balign 4 +.byte 'B', 'B', 'B', 'B' +.section .fini_array.65530,"a",%progbits +.balign 4 +.byte 'C', 'C', 'C', 'C' +.section .init_array.65530,"a",%progbits +.balign 4 +.byte 'D', 'D', 'D', 'D' +.section .dtors.64528,"a",%progbits +.balign 4 +.byte 'E', 'E', 'E', 'E' +.section .ctors.64528,"a",%progbits +.balign 4 +.byte 'F', 'F', 'F', 'F' +.section .fini_array.01005,"a",%progbits +.balign 4 +.byte 'G', 'G', 'G', 'G' +.section .init_array.01005,"a",%progbits +.balign 4 +.byte 'H', 'H', 'H', 'H' +.text +EOF + if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \ + && $gcc_cv_ld -e 0 -o conftest conftest.o > /dev/null 2>&1 \ + && $gcc_cv_objdump -s -j .init_array conftest \ + | grep HHHHFFFFDDDDBBBB > /dev/null 2>&1 \ + && $gcc_cv_objdump -s -j .fini_array conftest \ + | grep GGGGEEEECCCCAAAA > /dev/null 2>&1; then + gcc_cv_initfini_array=yes + fi + rm -f conftest conftest.* + fi + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifndef __ELF__ +#error Not an ELF OS +#endif +#include <stdlib.h> +#if defined __GLIBC_PREREQ && __GLIBC_PREREQ (2, 4) +#else +#error The C library not known to support .init_array/.fini_array +#endif + +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + gcc_cv_initfini_array=no +fi +rm -f conftest.err conftest.$ac_ext;; + esac + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking cross compile... guessing" >&5 +$as_echo_n "checking cross compile... guessing... " >&6; } + gcc_cv_initfini_array=no + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_initfini_array" >&5 +$as_echo "$gcc_cv_initfini_array" >&6; } + enable_initfini_array=$gcc_cv_initfini_array + +fi + +if test $enable_initfini_array = yes; then + +$as_echo "#define HAVE_INITFINI_ARRAY 1" >>confdefs.h + +fi + # Check if we have .[us]leb128, and support symbol arithmetic with it. { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .sleb128 and .uleb128" >&5 $as_echo_n "checking assembler for .sleb128 and .uleb128... " >&6; } diff --git a/gcc-4.6/gcc/configure.ac b/gcc-4.6/gcc/configure.ac index 5062115ab..4a496edc7 100644 --- a/gcc-4.6/gcc/configure.ac +++ b/gcc-4.6/gcc/configure.ac @@ -1152,8 +1152,6 @@ fi # Restore CFLAGS from before the gcc_AC_NEED_DECLARATIONS tests. CFLAGS="$saved_CFLAGS" -gcc_AC_INITFINI_ARRAY - # mkdir takes a single argument on some systems. gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG @@ -1231,6 +1229,11 @@ if test x"$tmake_file" = x then tmake_file=$cpu_type/t-$cpu_type fi +# Support --enable-initfini-array. +if test x$enable_initfini_array != xno; then + tm_file="${tm_file} initfini-array.h" +fi + if test x"$dwarf2" = xyes then tm_file="$tm_file tm-dwarf2.h" fi @@ -2368,6 +2371,8 @@ if test x$gcc_cv_ld_ro_rw_mix = xread-write; then fi AC_MSG_RESULT($gcc_cv_ld_ro_rw_mix) +gcc_AC_INITFINI_ARRAY + # Check if we have .[us]leb128, and support symbol arithmetic with it. gcc_GAS_CHECK_FEATURE([.sleb128 and .uleb128], gcc_cv_as_leb128, [elf,2,11,0],, diff --git a/gcc-4.6/gcc/crtstuff.c b/gcc-4.6/gcc/crtstuff.c index b65f490da..010d47276 100644 --- a/gcc-4.6/gcc/crtstuff.c +++ b/gcc-4.6/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; diff --git a/gcc-4.6/gcc/output.h b/gcc-4.6/gcc/output.h index 7031b0843..661b62380 100644 --- a/gcc-4.6/gcc/output.h +++ b/gcc-4.6/gcc/output.h @@ -655,6 +655,8 @@ extern void file_end_indicate_split_stack (void); extern void default_elf_asm_output_external (FILE *file, tree, const char *); +extern void default_elf_init_array_asm_out_constructor (rtx, int); +extern void default_elf_fini_array_asm_out_destructor (rtx, int); extern int maybe_assemble_visibility (tree); extern int default_address_cost (rtx, bool); diff --git a/gcc-4.6/gcc/varasm.c b/gcc-4.6/gcc/varasm.c index 40a856758..d15c27873 100644 --- a/gcc-4.6/gcc/varasm.c +++ b/gcc-4.6/gcc/varasm.c @@ -7397,4 +7397,62 @@ make_debug_expr_from_rtl (const_rtx exp) return dval; } +static GTY(()) section *elf_init_array_section; +static GTY(()) section *elf_fini_array_section; + +static section * +get_elf_initfini_array_priority_section (int priority, + bool constructor_p) +{ + section *sec; + if (priority != DEFAULT_INIT_PRIORITY) + { + char buf[18]; + sprintf (buf, "%s.%.5u", + constructor_p ? ".init_array" : ".fini_array", + priority); + sec = get_section (buf, SECTION_WRITE, NULL_TREE); + } + else + { + if (constructor_p) + { + if (elf_init_array_section == NULL) + elf_init_array_section + = get_unnamed_section (0, output_section_asm_op, + "\t.section\t.init_array"); + sec = elf_init_array_section; + } + else + { + if (elf_fini_array_section == NULL) + elf_fini_array_section + = get_unnamed_section (0, output_section_asm_op, + "\t.section\t.fini_array"); + sec = elf_fini_array_section; + } + } + return sec; +} + +/* Use .init_array section for constructors. */ + +void +default_elf_init_array_asm_out_constructor (rtx symbol, int priority) +{ + section *sec = get_elf_initfini_array_priority_section (priority, + true); + assemble_addr_to_section (symbol, sec); +} + +/* Use .fini_array section for destructors. */ + +void +default_elf_fini_array_asm_out_destructor (rtx symbol, int priority) +{ + section *sec = get_elf_initfini_array_priority_section (priority, + false); + assemble_addr_to_section (symbol, sec); +} + #include "gt-varasm.h" |
