Re: [google/gcc-4_6_2-mobile] PATCH: PR other/46770: Replace .ctors/.dtors with .init_array/.fini_array on targets supporting them

2012-02-22 Thread Jing Yu
The attachment is a complete patch for [google/gcc-4_6] branch, to
replace .ctors/.dtors with .init_array/.fini_array.

Bootstrap and crosstool testers pass.
I have verified that gcc_cv_initfini_array=no, which means the
crosstool will do whatever it did before (won't replace .ctors/.dtors
with .init_array/.fini_array).

I also built Android toolchain and verified gcc_cv_initfini_array=no.

r177933 is already in google/gcc-4_6_2-mobile and
google/gcc-4_6-mobile. I need to backport the rest to these two
branches.

ok?

2012-02-21   Jing Yu  jin...@google.com

Google Ref 47894
Backport from mainline r177933, r175181, r177963, r178116, r183299.

2011-08-20  H.J. Lu  hongjiu...@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.

2011-06-18  H.J. Lu  hongjiu...@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...@intel.com
* acinclude.m4 (gcc_AC_INITFINI_ARRAY): Error if __ELF__ isn't
defined.
* configure: Regenerated.

2011-08-26  Rainer Orth  r...@cebitec.uni-bielefeld.de
PR target/50166
* acinclude.m4 (gcc_AC_INITFINI_ARRAY): Check count in main.
* configure: Regenerate.

2012-01-19  Jakub Jelinek  ja...@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.

Thanks,
Jing

On Tue, Feb 21, 2012 at 9:34 AM, H.J. Lu hjl.to...@gmail.com wrote:
 On Mon, Feb 20, 2012 at 11:31 PM, Jing Yu jin...@google.com wrote:
 Hi H.J.,

 I think the patch itself is not enough.
 I compared AC_DEFUN([gcc_AC_INITFINI_ARRAY] part (in acinclude.m4)
 of gcc trunk and google/gcc-4_6_2-mobile, and found how
 enable_initfini_array is
 configured is different.

 The patch breaks some of our tests. enable_initfini_array should be
 disabled for cross compile by default. But it is not true in our
 branch. Could you please point us all related patches?


 I missed this backport. There are some additional changes needed for
 non-Linux systems:

 http://gcc.gnu.org/ml/gcc-cvs/2011-08/msg00978.html
 http://gcc.gnu.org/ml/gcc-cvs/2011-08/msg01132.html
 http://gcc.gnu.org/ml/gcc-cvs/2012-01/msg00544.html



 --
 H.J.


initfini.patch
Description: Binary data


Re: [google/gcc-4_6_2-mobile] PATCH: PR other/46770: Replace .ctors/.dtors with .init_array/.fini_array on targets supporting them

2012-02-20 Thread Ilya Enkovich
Hello,

 Hey, Jing, you broke the google/gcc-4_6 branch by checking the new
 header file into the wrong directory.

 Fixed via r184386.


google/gcc-4_6_2-mobile branch still has the same problem. Could
please someone fix it?

Thanks
Ilya

 Ollie

 On Fri, Feb 17, 2012 at 10:25 PM, Jing Yu jin...@google.com wrote:

 OK. Thanks for porting the patch.
 I will commit the patch into google/gcc-4_6_2-mobile for you.

 I would also like to commit it into google/gcc-4_6 branch if all tests
 pass. This patch is almost the same as Google Ref 47894.

 Thanks,
 Jing

 On Fri, Feb 17, 2012 at 5:20 PM, H.J. Lu hongjiu...@intel.com wrote:
  Hi,
 
  This patch backports the fix from trunk:
 
  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770
 
  for google/gcc-4_6_2-mobile branch.  This is needed to support C++
  global constructors/destructiors on Android/x86.  OK for
  google/gcc-4_6_2-mobile branch?
 
  Thanks.
 
  H.J.
  ---
  2011-08-20  H.J. Lu  hongjiu...@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.
 
  git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177933 
  138bc75d-0d04-0410-961f-82ee72b054a4
 
  Conflicts:
 
         gcc/ChangeLog
  ---
   gcc/ChangeLog.hjl           |   21 +++
   gcc/config.gcc              |    5 +++
   gcc/config/initfini-array.h |   37 +++
   gcc/crtstuff.c              |   11 +++-
   gcc/output.h                |    2 +
   gcc/varasm.c                |   58 
  +++
   6 files changed, 133 insertions(+), 1 deletions(-)
   create mode 100644 gcc/ChangeLog.hjl
   create mode 100644 gcc/config/initfini-array.h
 
  diff --git a/gcc/ChangeLog.hjl b/gcc/ChangeLog.hjl
  new file mode 100644
  index 000..3527b27
  --- /dev/null
  +++ b/gcc/ChangeLog.hjl
  @@ -0,0 +1,21 @@
  +2011-12-07  H.J. Lu  hongjiu...@intel.com
  +
  +       Backport from mainline
  +       2011-08-20  H.J. Lu  hongjiu...@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.
  diff --git a/gcc/config.gcc b/gcc/config.gcc
  index d9ac0fa..b386424 100644
  --- a/gcc/config.gcc
  +++ b/gcc/config.gcc
  @@ -3176,6 +3176,11 @@ if test x$with_schedule = x; then
         esac
   fi
 
  +# Support --enable-initfini-array.
  +if test x$enable_initfini_array = xyes; then
  +  tm_file=${tm_file} initfini-array.h
  +fi
  +
   # Validate and mark as valid any --with options supported
   # by this target.  In order to use a particular --with option
   # you must list it in supported_defaults; validating the value
  diff --git a/gcc/config/initfini-array.h b/gcc/config/initfini-array.h
  new file mode 100644
  index 000..8aaadf6
  --- /dev/null
  +++ b/gcc/config/initfini-array.h
  @@ -0,0 +1,37 @@
  +/* Definitions for ELF systems with .init_array/.fini_array section
  +   support.
  +   Copyright (C) 2011
  +   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/.  */
  +
  +#define USE_INITFINI_ARRAY
  +
  +#undef INIT_SECTION_ASM_OP
  

Re: [google/gcc-4_6_2-mobile] PATCH: PR other/46770: Replace .ctors/.dtors with .init_array/.fini_array on targets supporting them

2012-02-20 Thread Jing Yu
Sorry -- I will fix it in google/gcc-4_6_2-mobile.

Thanks,
Jing

On Mon, Feb 20, 2012 at 7:15 AM, Ilya Enkovich enkovich@gmail.com wrote:
 Hello,

 Hey, Jing, you broke the google/gcc-4_6 branch by checking the new
 header file into the wrong directory.

 Fixed via r184386.


 google/gcc-4_6_2-mobile branch still has the same problem. Could
 please someone fix it?

 Thanks
 Ilya

 Ollie

 On Fri, Feb 17, 2012 at 10:25 PM, Jing Yu jin...@google.com wrote:

 OK. Thanks for porting the patch.
 I will commit the patch into google/gcc-4_6_2-mobile for you.

 I would also like to commit it into google/gcc-4_6 branch if all tests
 pass. This patch is almost the same as Google Ref 47894.

 Thanks,
 Jing

 On Fri, Feb 17, 2012 at 5:20 PM, H.J. Lu hongjiu...@intel.com wrote:
  Hi,
 
  This patch backports the fix from trunk:
 
  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770
 
  for google/gcc-4_6_2-mobile branch.  This is needed to support C++
  global constructors/destructiors on Android/x86.  OK for
  google/gcc-4_6_2-mobile branch?
 
  Thanks.
 
  H.J.
  ---
  2011-08-20  H.J. Lu  hongjiu...@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.
 
  git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177933 
  138bc75d-0d04-0410-961f-82ee72b054a4
 
  Conflicts:
 
         gcc/ChangeLog
  ---
   gcc/ChangeLog.hjl           |   21 +++
   gcc/config.gcc              |    5 +++
   gcc/config/initfini-array.h |   37 +++
   gcc/crtstuff.c              |   11 +++-
   gcc/output.h                |    2 +
   gcc/varasm.c                |   58 
  +++
   6 files changed, 133 insertions(+), 1 deletions(-)
   create mode 100644 gcc/ChangeLog.hjl
   create mode 100644 gcc/config/initfini-array.h
 
  diff --git a/gcc/ChangeLog.hjl b/gcc/ChangeLog.hjl
  new file mode 100644
  index 000..3527b27
  --- /dev/null
  +++ b/gcc/ChangeLog.hjl
  @@ -0,0 +1,21 @@
  +2011-12-07  H.J. Lu  hongjiu...@intel.com
  +
  +       Backport from mainline
  +       2011-08-20  H.J. Lu  hongjiu...@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.
  diff --git a/gcc/config.gcc b/gcc/config.gcc
  index d9ac0fa..b386424 100644
  --- a/gcc/config.gcc
  +++ b/gcc/config.gcc
  @@ -3176,6 +3176,11 @@ if test x$with_schedule = x; then
         esac
   fi
 
  +# Support --enable-initfini-array.
  +if test x$enable_initfini_array = xyes; then
  +  tm_file=${tm_file} initfini-array.h
  +fi
  +
   # Validate and mark as valid any --with options supported
   # by this target.  In order to use a particular --with option
   # you must list it in supported_defaults; validating the value
  diff --git a/gcc/config/initfini-array.h b/gcc/config/initfini-array.h
  new file mode 100644
  index 000..8aaadf6
  --- /dev/null
  +++ b/gcc/config/initfini-array.h
  @@ -0,0 +1,37 @@
  +/* Definitions for ELF systems with .init_array/.fini_array section
  +   support.
  +   Copyright (C) 2011
  +   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; 

Re: [google/gcc-4_6_2-mobile] PATCH: PR other/46770: Replace .ctors/.dtors with .init_array/.fini_array on targets supporting them

2012-02-20 Thread Jing Yu
Hi H.J.,

I think the patch itself is not enough.
I compared AC_DEFUN([gcc_AC_INITFINI_ARRAY] part (in acinclude.m4)
of gcc trunk and google/gcc-4_6_2-mobile, and found how
enable_initfini_array is
configured is different.

The patch breaks some of our tests. enable_initfini_array should be
disabled for cross compile by default. But it is not true in our
branch. Could you please point us all related patches?

Thanks,
Jing

On Mon, Feb 20, 2012 at 8:30 AM, H.J. Lu hjl.to...@gmail.com wrote:
 On Sat, Feb 18, 2012 at 1:54 AM, Jakub Jelinek ja...@redhat.com wrote:
 On Fri, Feb 17, 2012 at 05:20:02PM -0800, H.J. Lu wrote:
 This patch backports the fix from trunk:

 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770

 for google/gcc-4_6_2-mobile branch.  This is needed to support C++
 global constructors/destructiors on Android/x86.  OK for
 google/gcc-4_6_2-mobile branch?

 Don't you want to backport also all the follow-ups on this?


 The original patch works with cross compile since it is disabled by
 default.  For native compile, it works with the default GNU assembler
 and linker.  If there are additional failure for native compile, it should
 be disabled at configure time.


 --
 H.J.


Re: [google/gcc-4_6_2-mobile] PATCH: PR other/46770: Replace .ctors/.dtors with .init_array/.fini_array on targets supporting them

2012-02-19 Thread Ollie Wild
Hey, Jing, you broke the google/gcc-4_6 branch by checking the new
header file into the wrong directory.

Fixed via r184386.

Ollie

On Fri, Feb 17, 2012 at 10:25 PM, Jing Yu jin...@google.com wrote:

 OK. Thanks for porting the patch.
 I will commit the patch into google/gcc-4_6_2-mobile for you.

 I would also like to commit it into google/gcc-4_6 branch if all tests
 pass. This patch is almost the same as Google Ref 47894.

 Thanks,
 Jing

 On Fri, Feb 17, 2012 at 5:20 PM, H.J. Lu hongjiu...@intel.com wrote:
  Hi,
 
  This patch backports the fix from trunk:
 
  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770
 
  for google/gcc-4_6_2-mobile branch.  This is needed to support C++
  global constructors/destructiors on Android/x86.  OK for
  google/gcc-4_6_2-mobile branch?
 
  Thanks.
 
  H.J.
  ---
  2011-08-20  H.J. Lu  hongjiu...@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.
 
  git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177933 
  138bc75d-0d04-0410-961f-82ee72b054a4
 
  Conflicts:
 
         gcc/ChangeLog
  ---
   gcc/ChangeLog.hjl           |   21 +++
   gcc/config.gcc              |    5 +++
   gcc/config/initfini-array.h |   37 +++
   gcc/crtstuff.c              |   11 +++-
   gcc/output.h                |    2 +
   gcc/varasm.c                |   58 
  +++
   6 files changed, 133 insertions(+), 1 deletions(-)
   create mode 100644 gcc/ChangeLog.hjl
   create mode 100644 gcc/config/initfini-array.h
 
  diff --git a/gcc/ChangeLog.hjl b/gcc/ChangeLog.hjl
  new file mode 100644
  index 000..3527b27
  --- /dev/null
  +++ b/gcc/ChangeLog.hjl
  @@ -0,0 +1,21 @@
  +2011-12-07  H.J. Lu  hongjiu...@intel.com
  +
  +       Backport from mainline
  +       2011-08-20  H.J. Lu  hongjiu...@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.
  diff --git a/gcc/config.gcc b/gcc/config.gcc
  index d9ac0fa..b386424 100644
  --- a/gcc/config.gcc
  +++ b/gcc/config.gcc
  @@ -3176,6 +3176,11 @@ if test x$with_schedule = x; then
         esac
   fi
 
  +# Support --enable-initfini-array.
  +if test x$enable_initfini_array = xyes; then
  +  tm_file=${tm_file} initfini-array.h
  +fi
  +
   # Validate and mark as valid any --with options supported
   # by this target.  In order to use a particular --with option
   # you must list it in supported_defaults; validating the value
  diff --git a/gcc/config/initfini-array.h b/gcc/config/initfini-array.h
  new file mode 100644
  index 000..8aaadf6
  --- /dev/null
  +++ b/gcc/config/initfini-array.h
  @@ -0,0 +1,37 @@
  +/* Definitions for ELF systems with .init_array/.fini_array section
  +   support.
  +   Copyright (C) 2011
  +   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/.  */
  +
  +#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 

Re: [google/gcc-4_6_2-mobile] PATCH: PR other/46770: Replace .ctors/.dtors with .init_array/.fini_array on targets supporting them

2012-02-18 Thread Jakub Jelinek
On Fri, Feb 17, 2012 at 05:20:02PM -0800, H.J. Lu wrote:
 This patch backports the fix from trunk:
 
 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770
 
 for google/gcc-4_6_2-mobile branch.  This is needed to support C++
 global constructors/destructiors on Android/x86.  OK for
 google/gcc-4_6_2-mobile branch?

Don't you want to backport also all the follow-ups on this?

Jakub


Re: [google/gcc-4_6_2-mobile] PATCH: PR other/46770: Replace .ctors/.dtors with .init_array/.fini_array on targets supporting them

2012-02-17 Thread Jing Yu
OK. Thanks for porting the patch.
I will commit the patch into google/gcc-4_6_2-mobile for you.

I would also like to commit it into google/gcc-4_6 branch if all tests
pass. This patch is almost the same as Google Ref 47894.

Thanks,
Jing

On Fri, Feb 17, 2012 at 5:20 PM, H.J. Lu hongjiu...@intel.com wrote:
 Hi,

 This patch backports the fix from trunk:

 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770

 for google/gcc-4_6_2-mobile branch.  This is needed to support C++
 global constructors/destructiors on Android/x86.  OK for
 google/gcc-4_6_2-mobile branch?

 Thanks.

 H.J.
 ---
 2011-08-20  H.J. Lu  hongjiu...@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.

 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177933 
 138bc75d-0d04-0410-961f-82ee72b054a4

 Conflicts:

        gcc/ChangeLog
 ---
  gcc/ChangeLog.hjl           |   21 +++
  gcc/config.gcc              |    5 +++
  gcc/config/initfini-array.h |   37 +++
  gcc/crtstuff.c              |   11 +++-
  gcc/output.h                |    2 +
  gcc/varasm.c                |   58 
 +++
  6 files changed, 133 insertions(+), 1 deletions(-)
  create mode 100644 gcc/ChangeLog.hjl
  create mode 100644 gcc/config/initfini-array.h

 diff --git a/gcc/ChangeLog.hjl b/gcc/ChangeLog.hjl
 new file mode 100644
 index 000..3527b27
 --- /dev/null
 +++ b/gcc/ChangeLog.hjl
 @@ -0,0 +1,21 @@
 +2011-12-07  H.J. Lu  hongjiu...@intel.com
 +
 +       Backport from mainline
 +       2011-08-20  H.J. Lu  hongjiu...@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.
 diff --git a/gcc/config.gcc b/gcc/config.gcc
 index d9ac0fa..b386424 100644
 --- a/gcc/config.gcc
 +++ b/gcc/config.gcc
 @@ -3176,6 +3176,11 @@ if test x$with_schedule = x; then
        esac
  fi

 +# Support --enable-initfini-array.
 +if test x$enable_initfini_array = xyes; then
 +  tm_file=${tm_file} initfini-array.h
 +fi
 +
  # Validate and mark as valid any --with options supported
  # by this target.  In order to use a particular --with option
  # you must list it in supported_defaults; validating the value
 diff --git a/gcc/config/initfini-array.h b/gcc/config/initfini-array.h
 new file mode 100644
 index 000..8aaadf6
 --- /dev/null
 +++ b/gcc/config/initfini-array.h
 @@ -0,0 +1,37 @@
 +/* Definitions for ELF systems with .init_array/.fini_array section
 +   support.
 +   Copyright (C) 2011
 +   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/.  */
 +
 +#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