From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29760 invoked by alias); 14 Aug 2011 16:20:37 -0000 Received: (qmail 29751 invoked by uid 22791); 14 Aug 2011 16:20:36 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_GM,TW_PM X-Spam-Check-By: sourceware.org Received: from mail-qy0-f175.google.com (HELO mail-qy0-f175.google.com) (209.85.216.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 14 Aug 2011 16:20:21 +0000 Received: by qyk4 with SMTP id 4so490374qyk.20 for ; Sun, 14 Aug 2011 09:20:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.177.168 with SMTP id bi40mr1970221qcb.161.1313338820482; Sun, 14 Aug 2011 09:20:20 -0700 (PDT) Received: by 10.229.29.7 with HTTP; Sun, 14 Aug 2011 09:20:20 -0700 (PDT) In-Reply-To: References: <20110722123042.GB2687@tyan-ft48-01.lab.bos.redhat.com> Date: Sun, 14 Aug 2011 19:20:00 -0000 Message-ID: Subject: Re: PING: PATCH: PR target/46770: Use .init_array/.fini_array sections From: "H.J. Lu" To: Jakub Jelinek Cc: GCC Patches Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg01212.txt.bz2 PING On Tue, Aug 9, 2011 at 6:56 AM, H.J. Lu wrote: > PING. > > On Sat, Aug 6, 2011 at 7:40 AM, H.J. Lu wrote: >> PING. >> >> On Fri, Jul 22, 2011 at 7:06 AM, H.J. Lu wrote: >>> On Fri, Jul 22, 2011 at 7:00 AM, H.J. Lu wrote: >>>> On Fri, Jul 22, 2011 at 6:03 AM, H.J. Lu wrote: >>>>> On Fri, Jul 22, 2011 at 5:30 AM, Jakub Jelinek wro= te: >>>>>> On Fri, Jul 22, 2011 at 04:59:28AM -0700, H.J. Lu wrote: >>>>>>> @@ -2660,6 +2664,7 @@ esac >>>>>>> =A0case ${target} in >>>>>>> =A0i[34567]86-*-linux* | x86_64-*-linux*) >>>>>>> =A0 =A0 =A0 tmake_file=3D"${tmake_file} i386/t-pmm_malloc i386/t-i3= 86" >>>>>>> + =A0 =A0 use_initfini_array=3Dyes >>>>>>> =A0 =A0 =A0 ;; >>>>>>> =A0i[34567]86-*-* | x86_64-*-*) >>>>>>> =A0 =A0 =A0 tmake_file=3D"${tmake_file} i386/t-gmm_malloc i386/t-i3= 86" >>>>>> >>>>>> What is i?86/x86_64 specific on it? =A0Don't most other glibc targets >>>>>> want to use it too, perhaps with some arch specific tweaks? >>>>> >>>>> I do have a patch for all ELF targets: >>>>> >>>>> http://gcc.gnu.org/ml/gcc-patches/2011-06/msg01416.html >>>>> >>>>> It touches many targets. . =A0But I only have one feedback from one >>>>> target maintainer. =A0I don't know how long it will take to review it. >>>>> >>>>> >>>>>>> --- /dev/null >>>>>>> +++ b/gcc/config/initfini-array.c >>>>>> >>>>>> This is ugly. =A0varasm.c already has lots of ELF specific code, sim= ply >>>>>> put them there as well and only let configury set some macro which w= ill >>>>>> allow targets to choose which of the implementations in the generic = code >>>>>> they want to use (or if they want their own which e.g. calls the gen= eric >>>>>> routine and does something additional to it etc.). =A0The sections p= robably >>>>>> can be created only the first time you actually need them. >>>>> >>>>> I will do that. >>>>> >>>>>>> --- a/gcc/crtstuff.c >>>>>>> +++ b/gcc/crtstuff.c >>>>>>> @@ -189,6 +190,9 @@ typedef void (*func_ptr) (void); >>>>>>> =A0 =A0 refer to only the __CTOR_END__ symbol in crtend.o and the _= _DTOR_LIST__ >>>>>>> =A0 =A0 symbol in crtbegin.o, where they are defined. =A0*/ >>>>>>> >>>>>>> +/* No need for .ctors/.dtors section if linker can place them in >>>>>>> + =A0 .init_array/.fini_array section. =A0*/ >>>>>>> +#ifndef NO_CTORS_DTORS_SECTIONS >>>>>>> =A0/* The -1 is a flag to __do_global_[cd]tors indicating that this= table >>>>>>> =A0 =A0 does not start with a count of elements. =A0*/ >>>>>>> =A0#ifdef CTOR_LIST_BEGIN >>>>>>> @@ -219,6 +223,7 @@ STATIC func_ptr __DTOR_LIST__[1] >>>>>>> =A0 =A0__attribute__((section(".dtors"), aligned(sizeof(func_ptr)))) >>>>>>> =A0 =A0=3D { (func_ptr) (-1) }; >>>>>>> =A0#endif /* __DTOR_LIST__ alternatives */ >>>>>>> +#endif /* NO_CTORS_DTORS_SECTIONS */ >>>>>>> >>>>>>> =A0#ifdef USE_EH_FRAME_REGISTRY >>>>>>> =A0/* Stick a label at the beginning of the frame unwind info so we= can register >>>>>>> @@ -489,6 +494,9 @@ __do_global_ctors_1(void) >>>>>>> >>>>>>> =A0#elif defined(CRT_END) /* ! CRT_BEGIN */ >>>>>>> >>>>>>> +/* No need for .ctors/.dtors section if linker can place them in >>>>>>> + =A0 .init_array/.fini_array section. =A0*/ >>>>>>> +#ifndef NO_CTORS_DTORS_SECTIONS >>>>>>> =A0/* Put a word containing zero at the end of each of our two list= s of function >>>>>>> =A0 =A0 addresses. =A0Note that the words defined here go into the = .ctors and .dtors >>>>>>> =A0 =A0 sections of the crtend.o file, and since that file is alway= s linked in >>>>>>> @@ -534,6 +542,7 @@ STATIC func_ptr __DTOR_END__[1] >>>>>>> =A0 =A0__attribute__((used, section(".dtors"), aligned(sizeof(func_= ptr)))) >>>>>>> =A0 =A0=3D { (func_ptr) 0 }; >>>>>>> =A0#endif >>>>>>> +#endif /* NO_CTORS_DTORS_SECTIONS */ >>>>>>> >>>>>>> =A0#ifdef EH_FRAME_SECTION_NAME >>>>>>> =A0/* Terminate the frame unwind info section with a 4byte 0 as a s= entinel; >>>>>> >>>>>> I don't see how you can do this. =A0It would IMO break any time you = link code >>>>>> built by different gcc versions where some code emitted by the older= gcc >>>>>> used .ctors or .dtors. >>>>> >>>>> crtstuff.c is used to generate crt*.o, which is the part of GCC. =A0Y= ou only use >>>>> it with the GCC you are using. =A0Since your GCC doesn't put anything= in >>>>> .ctors/.dtors section, you don't need them. =A0As for .o files genera= ted by >>>>> old GCCs, that is the linker test, use_initfini_array, is for. =A0The= newer linker >>>>> can put input .ctors/.dtors sections in output .init_array/,fini_arra= y sections. >>>>> >>>>> >>>> >>>> Here is the updated patch. =A0Any comments? >>>> >>>> Thanks. >>>> >>>> -- >>>> H.J. >>>> --- >>>> 2011-07-22 =A0H.J. Lu =A0 >>>> >>>> =A0 =A0 =A0 =A0PR target/46770 >>>> =A0 =A0 =A0 =A0* config.gcc (use_initfini_array): New variable. >>>> =A0 =A0 =A0 =A0Use .init_arary/.fini_array if they are supported. >>>> >>>> =A0 =A0 =A0 =A0* crtstuff.c: Don't generate .ctors nor .dtors sections= if >>>> =A0 =A0 =A0 =A0USE_INITFINI_ARRAY is defined. >>>> >>>> =A0 =A0 =A0 =A0* output.h (default_initfini_array_init_sections): New. >>>> =A0 =A0 =A0 =A0* varasm.c (elf_init_array_section): Likewise. >>>> =A0 =A0 =A0 =A0(elf_fini_array_section): Likewise. >>>> =A0 =A0 =A0 =A0(get_elf_initfini_array_priority_section): Likewise. >>>> =A0 =A0 =A0 =A0(default_elf_init_array_asm_out_constructor): Likewise. >>>> =A0 =A0 =A0 =A0(default_elf_fini_array_asm_out_destructor): Likewise. >>>> =A0 =A0 =A0 =A0(default_initfini_array_init_sections): Likewise. >>>> >>>> =A0 =A0 =A0 =A0* config/initfini-array.h: New. >>>> =A0 =A0 =A0 =A0* config/t-initfini-array: Likewise. >>>> >>> >>> No need for config/t-initfini-array. =A0Here is the updated patch. >>> >>> >>> -- >>> H.J. >>> ---- >>> 2011-07-22 =A0H.J. Lu =A0 >>> >>> =A0 =A0 =A0 =A0PR target/46770 >>> =A0 =A0 =A0 =A0* config.gcc (use_initfini_array): New variable. >>> =A0 =A0 =A0 =A0Use .init_arary/.fini_array if they are supported. >>> >>> =A0 =A0 =A0 =A0* crtstuff.c: Don't generate .ctors nor .dtors sections = if >>> =A0 =A0 =A0 =A0USE_INITFINI_ARRAY is defined. >>> >>> =A0 =A0 =A0 =A0* output.h (default_initfini_array_init_sections): New. >>> =A0 =A0 =A0 =A0* varasm.c (elf_init_array_section): Likewise. >>> =A0 =A0 =A0 =A0(elf_fini_array_section): Likewise. >>> =A0 =A0 =A0 =A0(get_elf_initfini_array_priority_section): Likewise. >>> =A0 =A0 =A0 =A0(default_elf_init_array_asm_out_constructor): Likewise. >>> =A0 =A0 =A0 =A0(default_elf_fini_array_asm_out_destructor): Likewise. >>> =A0 =A0 =A0 =A0(default_initfini_array_init_sections): Likewise. >>> >>> =A0 =A0 =A0 =A0* config/initfini-array.h: New. >>> >>> =A0 =A0 =A0 =A0* config/arm/arm.c (arm_asm_init_sections): Call >>> =A0 =A0 =A0 =A0default_initfini_array_init_sections. >>> =A0 =A0 =A0 =A0* config/avr/avr.c (avr_asm_init_sections): Likewise. >>> =A0 =A0 =A0 =A0* config/ia64/ia64.c (ia64_asm_init_sections): Likewise. >>> =A0 =A0 =A0 =A0* config/mep/mep.c (mep_asm_init_sections): Likewise. >>> =A0 =A0 =A0 =A0* config/microblaze/microblaze.c (microblaze_elf_asm_ini= t_sections): >>> =A0 =A0 =A0 =A0Likewise. >>> =A0 =A0 =A0 =A0* config/rs6000/rs6000.c (rs6000_elf_asm_init_sections):= Likewise. >>> =A0 =A0 =A0 =A0* config/stormy16/stormy16.c (xstormy16_asm_init_section= s): >>> =A0 =A0 =A0 =A0Likewise. >>> =A0 =A0 =A0 =A0* config/v850/v850.c (v850_asm_init_sections): Likewise. >>> >> >> >> >> -- >> H.J. >> > > > > -- > H.J. > --=20 H.J.