From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4242 invoked by alias); 19 Aug 2011 08:17:57 -0000 Received: (qmail 4230 invoked by uid 22791); 19 Aug 2011 08:17:55 -0000 X-SWARE-Spam-Status: No, hits=-7.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 19 Aug 2011 08:17:36 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7J8Hadl004579 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 19 Aug 2011 04:17:36 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p7J8HYIs016669 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 19 Aug 2011 04:17:34 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p7J8HXbN004910; Fri, 19 Aug 2011 10:17:33 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p7J8HXA2004908; Fri, 19 Aug 2011 10:17:33 +0200 Date: Fri, 19 Aug 2011 10:05:00 -0000 From: Jakub Jelinek To: "H.J. Lu" Cc: GCC Patches Subject: Re: PING: PATCH: PR target/46770: Use .init_array/.fini_array sections Message-ID: <20110819081733.GB2687@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20110722123042.GB2687@tyan-ft48-01.lab.bos.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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/msg01551.txt.bz2 Sorry for the delay. > --- a/gcc/config.gcc > +++ b/gcc/config.gcc > @@ -186,6 +186,9 @@ > # configure_default_options > # Set to an initializer for configure_default_options > # in configargs.h, based on --with-cpu et cetera. > +# > +# use_initfini_array If set to yes, .init_array/.fini_array sections > +# will be used if they work. > > # The following variables are used in each case-construct to build up the > # outgoing variables: > @@ -238,6 +241,7 @@ default_gnu_indirect_function=no > target_gtfiles= > need_64bit_hwint= > need_64bit_isa= > +use_initfini_array=yes What is this for, when nothing ever sets it to anything but yes? If the $enable_initfini_array = yes test works, then there shouldn't be any need to override it on a per-target basis... > --- /dev/null > +++ b/gcc/config/initfini-array.h > @@ -0,0 +1,44 @@ > +/* 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 > + . */ > + > +#define USE_INITFINI_ARRAY > + > +#undef INIT_SECTION_ASM_OP > +#undef FINI_SECTION_ASM_OP > + > +/* FIXME: INIT_ARRAY_SECTION_ASM_OP and FINI_ARRAY_SECTION_ASM_OP > + aren't used in any assembly codes. But we have to define > + them to something. */ > +#define INIT_ARRAY_SECTION_ASM_OP Something > +#define FINI_ARRAY_SECTION_ASM_OP Something Can't you just define it to an empty string? And, a couple of targets define INIT_ARRAY_SECTION_ASM_OP/FINI_ARRAY_SECTION_ASM_OP, you either need to undef it first, or define only if it wasn't defined. > + > +#ifndef TARGET_ASM_INIT_SECTIONS > +#define TARGET_ASM_INIT_SECTIONS default_elf_initfini_array_init_sections > +#endif > +extern void default_elf_initfini_array_init_sections (void); Why do you need this (and the default_initfini_array_init_sections () call in all the backends)? Isn't it easier to just initialize the two global vars only when you are actually going to use them (if they are still NULL)? > --- a/gcc/varasm.c > +++ b/gcc/varasm.c > @@ -7350,4 +7350,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; > + > +void > +default_elf_initfini_array_init_sections (void) > +{ > + elf_init_array_section = get_unnamed_section (0, output_section_asm_op, > + "\t.section\t.init_array"); > + elf_fini_array_section = get_unnamed_section (0, output_section_asm_op, > + "\t.section\t.fini_array"); > +} Remove above function. > + > +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); > + } I'd just put here else { if (elf_init_array_section == NULL) elf_init_array_section = get_unnamed_section... if (elf_fini_array_section == NULL) elf_fini_array_section = get_unnamed_section... > + sec = constructor_p ? elf_init_array_section : elf_fini_array_section; } > +void > +default_initfini_array_init_sections (void) > +{ > +#ifdef USE_INITFINI_ARRAY > + default_elf_initfini_array_init_sections (); > +#endif > +} And remove this (and all callers etc.). On which targets has it been tested? Would be nice to test it at least on targets that define their own INIT_ARRAY_SECTION_ASM_OP (pa64-hpux, arm, m32c, rx) and on {i?86,x86_64,ia64}-linux and some solaris target. Jakub