From patchwork Fri Feb 17 13:51:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 141823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D2458B6F9D for ; Sat, 18 Feb 2012 00:52:15 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1330091536; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:To:Cc:Subject:References:Date:In-Reply-To: Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=oBVkwbFwBeQAN2450rZ8e4SGH24=; b=ISaxi45uDize60hLE/lyznF9cHv27rP4WHNSTDrsdA+yU2ZFIf/rEspzqPkoLu wfY9G00d72F8OUI2479hBVIfgS+7f0Svp0EI9KRuyD6lx1YLYmZh4o+HHU96UIFP kY6K076k2dVFAHW5APc8lmvuE6m0VvLuUpaa5BZWNsIiE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=EjG9GSS4XQl62c/CTbFJwWUd4NOuWnSO7mVs3ojpR7PAQYdkg6/8vqG0vWXg5L /yojnA8TiUWKC8G7cyQhc98iZGBx7zY9RYL/pLB74q+y6zMAMCUS/zhFnegxAUD/ ZtMAA9n5x9eppjCSNBFItwUcCmLKJxd0fyZF/S0VvBhX0=; Received: (qmail 4894 invoked by alias); 17 Feb 2012 13:52:10 -0000 Received: (qmail 4882 invoked by uid 22791); 17 Feb 2012 13:52:07 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL, BAYES_50, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 17 Feb 2012 13:51:54 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id A9C6846E; Fri, 17 Feb 2012 14:51:52 +0100 (CET) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id MdpDKnB91SQC; Fri, 17 Feb 2012 14:51:47 +0100 (CET) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 954BF46D; Fri, 17 Feb 2012 14:51:47 +0100 (CET) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.5+Sun/8.14.5/Submit) id q1HDpke3011715; Fri, 17 Feb 2012 14:51:46 +0100 (MET) From: Rainer Orth To: Richard Guenther Cc: Paolo Bonzini , Jakub Jelinek , Alexandre Oliva , "H.J. Lu" , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix up --enable-initfini-array autodetection in configure (PR bootstrap/50237) References: <20120118232441.GO18768@tyan-ft48-01.lab.bos.redhat.com> <4F26CBFD.7060608@gnu.org> Date: Fri, 17 Feb 2012 14:51:46 +0100 In-Reply-To: (Rainer Orth's message of "Thu, 16 Feb 2012 21:33:24 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Rainer Orth writes: > Richard Guenther writes: > >> I'm not sure about the varasm.c change - it's definitely not a no-op >> (callback will be not set, and the flags will be different). Certainly > > As I've demonstrated in my response to H.J., the effect with gas is none. > >> the current code is inconsistent wrt the priority != DEFAULT_INIT_PRIORITY >> case, not sure why, but you don't make it consistent either because >> you don't change that case to SECTION_NOTYPE either. I'd be fine > > I didn't find a need for that, but agree that the inconsistency is > disturbing. default_section_type_flags suggests that SECTION_NOTYPE > should be set for .init_array and friends, but it's only used by > get_named_section. > >> with it with both calls using SECTION_NOTYPE, but would like to >> know what the callback difference is about. > > I don't think the callback is needed, which is effectively a > > printf ("\t.section\t.init_array"); > > Looking at it, this is e.g. wrong for Sun as on SPARC, which requires > the section name to be in double quotes. Here's the revised patch which consistently sets SECTION_NOTYPE. Bootstrapped without regressions on i386-pc-solaris2.11 with gas/gld and x86_64-unknown-linux-gnu, ok for mainline? Rainer 2012-01-20 Rainer Orth PR target/50166 * acinclude.m4 (gcc_AC_INITFINI_ARRAY): Require gcc_SUN_LD_VERSION. Define _start. Remove -e 0 from $gcc_cv_ld invocation. Only use __GLIBC_PREREQ if defined. Enable on Solaris since Solaris 8 patch. (gcc_SUN_LD_VERSION): New macro. * configure.ac (ld_ver) <*-*-solaris2*>: Refer to gcc_SUN_LD_VERSION for version number format. * configure: Regenerate. * varasm.c (get_elf_initfini_array_priority_section): Set SECTION_NOTYPE for non-default priority. Use get_section instead of get_unnamed_section to emit .init_array/.fini_array with default priority. # HG changeset patch # Parent 4dc36b1ff03f2d688613f3edbf1d0724079888d3 Enable initfini array support on Solaris diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4 --- a/gcc/acinclude.m4 +++ b/gcc/acinclude.m4 @@ -1,4 +1,5 @@ -dnl Copyright (C) 2005, 2006, 2007, 2008, 2011 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 +dnl Free Software Foundation, Inc. dnl dnl This file is part of GCC. dnl @@ -370,7 +371,8 @@ fi fi]) AC_DEFUN([gcc_AC_INITFINI_ARRAY], -[AC_ARG_ENABLE(initfini-array, +[AC_REQUIRE([gcc_SUN_LD_VERSION])dnl +AC_ARG_ENABLE(initfini-array, [ --enable-initfini-array use .init_array/.fini_array sections], [], [ AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support, @@ -427,9 +429,11 @@ int (*fp) (void) __attribute__ ((section .balign 4 .byte 'H', 'H', 'H', 'H' .text +.globl _start +_start: 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_ld -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 \ @@ -442,14 +446,38 @@ changequote([,])dnl fi AC_PREPROC_IFELSE([AC_LANG_SOURCE([ #ifndef __ELF__ -#error Not an ELF OS +# error Not an ELF OS #endif #include -#if defined __GLIBC_PREREQ && __GLIBC_PREREQ (2, 4) +#if defined __GLIBC_PREREQ +# if __GLIBC_PREREQ (2, 4) +# else +# error GLIBC 2.4 required +# endif #else -#error The C library not known to support .init_array/.fini_array +# if defined __sun__ && defined __svr4__ + /* Solaris ld.so.1 supports .init_array/.fini_array since Solaris 8. */ +# else +# error The C library not known to support .init_array/.fini_array +# endif #endif -])],, [gcc_cv_initfini_array=no]);; +])],[ + case "${target}" in + *-*-solaris2.8*) + # .init_array/.fini_array support was introduced in Solaris 8 + # patches 109147-08 (sparc) and 109148-08 (x86). Since ld.so.1 and + # ld are guaranteed to be updated in lockstep, we can check ld -V + # instead. Unfortunately, proper ld version numbers were only + # introduced in rev. -14, so we check for that. + if test "$gcc_cv_sun_ld_vers_minor" -lt 272; then + gcc_cv_initfini_array=no + fi + ;; + *-*-solaris2.9* | *-*-solaris2.1[[0-9]]*) + # .init_array/.fini_array support is present since Solaris 9 FCS. + ;; + esac +], [gcc_cv_initfini_array=no]);; esac else AC_MSG_CHECKING(cross compile... guessing) @@ -569,6 +597,43 @@ if test $[$2] = yes; then $7 fi])]) +dnl gcc_SUN_LD_VERSION +dnl +dnl Determines Sun linker version numbers, setting gcc_cv_sun_ld_vers to +dnl the complete version number and gcc_cv_sun_ld_vers_{major, minor} to +dnl the corresponding fields. +dnl +dnl ld and ld.so.1 are guaranteed to be updated in lockstep, so ld version +dnl numbers can be used in ld.so.1 feature checks even if a different +dnl linker is configured. +dnl +AC_DEFUN([gcc_SUN_LD_VERSION], +[changequote(,)dnl +if test "x${build}" = "x${target}" && test "x${build}" = "x${host}"; then + case "${target}" in + *-*-solaris2*) + # + # Solaris 2 ld -V output looks like this for a regular version: + # + # ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1699 + # + # but test versions add stuff at the end: + # + # ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1701:onnv-ab196087-6931056-03/25/10 + # + gcc_cv_sun_ld_ver=`/usr/ccs/bin/ld -V 2>&1` + if echo "$gcc_cv_sun_ld_ver" | grep 'Solaris Link Editors' > /dev/null; then + gcc_cv_sun_ld_vers=`echo $gcc_cv_sun_ld_ver | sed -n \ + -e 's,^.*: 5\.[0-9][0-9]*-\([0-9]\.[0-9][0-9]*\).*$,\1,p'` + gcc_cv_sun_ld_vers_major=`expr "$gcc_cv_sun_ld_vers" : '\([0-9]*\)'` + gcc_cv_sun_ld_vers_minor=`expr "$gcc_cv_sun_ld_vers" : '[0-9]*\.\([0-9]*\)'` + fi + ;; + esac +fi +changequote([,])dnl +]) + dnl GCC_TARGET_TEMPLATE(KEY) dnl ------------------------ dnl Define KEY as a valid configure key on the target machine. diff --git a/gcc/configure.ac b/gcc/configure.ac --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2296,15 +2296,11 @@ if test $in_tree_ld != yes ; then else case "${target}" in *-*-solaris2*) + # See acinclude.m4 (gcc_SUN_LD_VERSION) for the version number + # format. # - # Solaris 2 ld -V output looks like this for a regular version: - # - # ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1699 - # - # but test versions add stuff at the end: - # - # ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1701:onnv-ab196087-6931056-03/25/10 - # + # Don't reuse gcc_gv_sun_ld_vers_* in case a linker other than + # /usr/ccs/bin/ld has been configured. ld_ver=`$gcc_cv_ld -V 2>&1` if echo "$ld_ver" | grep 'Solaris Link Editors' > /dev/null; then ld_vers=`echo $ld_ver | sed -n \ diff --git a/gcc/varasm.c b/gcc/varasm.c --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -7661,7 +7661,7 @@ get_elf_initfini_array_priority_section sprintf (buf, "%s.%.5u", constructor_p ? ".init_array" : ".fini_array", priority); - sec = get_section (buf, SECTION_WRITE, NULL_TREE); + sec = get_section (buf, SECTION_WRITE | SECTION_NOTYPE, NULL_TREE); } else { @@ -7669,16 +7669,16 @@ get_elf_initfini_array_priority_section { if (elf_init_array_section == NULL) elf_init_array_section - = get_unnamed_section (0, output_section_asm_op, - "\t.section\t.init_array"); + = get_section (".init_array", + SECTION_WRITE | SECTION_NOTYPE, NULL_TREE); 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"); + = get_section (".fini_array", + SECTION_WRITE | SECTION_NOTYPE, NULL_TREE); sec = elf_fini_array_section; } }