From patchwork Wed Nov 13 22:28:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Granberg X-Patchwork-Id: 291067 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 81D942C0082 for ; Thu, 14 Nov 2013 09:30:47 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=bn6X6m1KSRJSVIRx 325jPrF9pbqokLvAIgBQ3ZZ3MeNaK6GdwCWR8KG22A0Usu74gqLuPSDKKsqQZOS0 Wgh9zwBDgpYcnf3NLdxYuFN/noKnqzWNaTlcANwUfzSktPb20ztmUzplfKosS4El vbaYy9XC2093Z5RHYENepQH+UOk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=/j4d8C3NEntB4QgseNrar1 qmQdE=; b=dtuJCLIb2YH6bzslmgPjG0uz1Pvcxd1iS77q7lKo/i66m97Wtq/1eH AlrAmQfOSzuvKCiGyzlg0aFODo59gwzM7I9qfa1t94zTnLZFIi37tINsxAEQI6Ml na3fQAlAdo+njypn3JHsynH4f+5u7mGzSb/FUD9tNLWCl4leKkkqs= Received: (qmail 25989 invoked by alias); 13 Nov 2013 22:30:38 -0000 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 Received: (qmail 25979 invoked by uid 89); 13 Nov 2013 22:30:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: smtp.gentoo.org Received: from Unknown (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 13 Nov 2013 22:29:16 +0000 Received: from laptop1.gw.ume.nu (ip1-67.bon.riksnet.se [77.110.8.67]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: zorry) by smtp.gentoo.org (Postfix) with ESMTPSA id 0C30F33F36E for ; Wed, 13 Nov 2013 22:29:08 +0000 (UTC) From: Magnus Granberg To: gcc-patches@gcc.gnu.org Subject: [PATCH][1-3] New configure option to enable Position independent executable as default. Date: Wed, 13 Nov 2013 23:28:45 +0100 Message-ID: <2766864.K73NFjqEQA@laptop1.gw.ume.nu> User-Agent: KMail/4.11 (Linux/3.11.6-hardened-r2; KDE/4.11.0; x86_64; ; ) MIME-Version: 1.0 X-IsSubscribed: yes Hi This patchset will add a new configure options --enable-default-pie. With the new option enable will make it pass -fPIE and -pie from the gcc and g++ frontend. Have only add the support for two targets but should work on more targes. In configure.ac we add the new option. We can't compile the compiler or the crt stuff with -fPIE it will brake the PCH and the crtbegin and crtend files. The disabling is done in the Makefiles. The needed spec is added to DRIVER_SELF_SPECS. We disable all the profiling test for the linking will fail.Tested on x86_64 linux (Gentoo). /Magnus Granberg Changlog 2013-11-10 Magnus Granberg /gcc * config/gnu-user.h: Define PIE_DRIVER_SELF_SPECS for PIE as default and GNU_DRIVER_SELF_SPECS. * config/i386/gnu-user-common.h: Define DRIVER_SELF_SPECS * configure.ac: Add new option that enable PIE as default. * configure, config.in: Rebuild. * Makefile.in: Disable PIE when building the compiler. * doc/install.texi: Add the new configure option default PIE. * doc/invoke.texi: Add note for the new configure option default PIE. * testsuite/gcc/default-pie.c: New test for new configure option --enale-default-pie * testsuite/gcc.dg/other/anon5.C: Add skip test as it fail to link on effective_target default_pie. * testsuite/lib/target-supports.exp (check_profiling_available): We can't use profiling on effective target default_pie. (check_effective_target_pie): Add check_effective_target_default_pie. /libgcc * Makefile.in: Disable PIE when building the crtbegin/end files. ---- --- a/gcc/testsuite/gcc.dg/default-pie.c 2013-11-09 21:07:16.741479728 +0100 +++ b/gcc/testsuite/gcc.dg/default-pie.c 2013-11-09 21:05:07.801479218 +0100 @@ -0,0 +1,12 @@ +/* { dg-do compile { target *-*-linux* *-*-gnu* } } */ +/* { dg-require-effective-target default_pie } */ +/* { dg-options "-O2" } */ +int foo (void); + +int +main (void) +{ + return foo (); +} + +/* { dg-final { scan-assembler "foo@PLT" } } */ --- a/gcc/testsuite/g++.dg/other/anon5.C 2012-11-10 15:34:42.000000000 +0100 +++ b/gcc/testsuite/g++.dg/other/anon5.C 2013-11-09 14:49:52.281390127 +0100 @@ -1,5 +1,6 @@ // PR c++/34094 // { dg-do link { target { ! { *-*-darwin* *-*-hpux* *-*-solaris2.* } } } } +// { dg-skip-if "" { default_pie } { "*" } { "" } } // { dg-options "-g" } // Ignore additional message on powerpc-ibm-aix // { dg-prune-output "obtain more information" } */ --- a/gcc/testsuite/lib/target-supports.exp 2013-10-01 11:18:30.000000000 +0200 +++ b/gcc/testsuite/lib/target-supports.exp 2013-10-25 22:01:46.743388469 +0200 @@ -474,6 +474,11 @@ proc check_profiling_available { test_wh } } + # Profiling don't work with default -fPIE -pie. + if { [check_effective_target_default_pie] } { + return 0 + } + # Support for -p on solaris2 relies on mcrt1.o which comes with the # vendor compiler. We cannot reliably predict the directory where the # vendor compiler (and thus mcrt1.o) is installed so we can't @@ -839,6 +844,14 @@ proc check_effective_target_pie { } { return 0 } +# Return 1 if -pie, -fPIE are default enable, 0 otherwise. + +proc check_effective_target_default_pie { } { + global ENABLE_DEFAULT_PIE + return [info exists ENABLE_DEFAULT_PIE] + return 0 +} + # Return true if the target supports -mpaired-single (as used on MIPS). proc check_effective_target_mpaired_single { } {