From patchwork Sat Dec 3 15:25:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jack Howarth X-Patchwork-Id: 129086 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 1663FB6F76 for ; Sun, 4 Dec 2011 02:25:44 +1100 (EST) Received: (qmail 25552 invoked by alias); 3 Dec 2011 15:25:41 -0000 Received: (qmail 25519 invoked by uid 22791); 3 Dec 2011 15:25:38 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from bromo.med.uc.edu (HELO bromo.med.uc.edu) (129.137.3.146) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Sat, 03 Dec 2011 15:25:24 +0000 Received: from bromo.med.uc.edu (localhost.localdomain [127.0.0.1]) by bromo.med.uc.edu (Postfix) with ESMTP id C15D1B005D; Sat, 3 Dec 2011 10:25:23 -0500 (EST) Received: (from howarth@localhost) by bromo.med.uc.edu (8.14.3/8.14.3/Submit) id pB3FPNLC009333; Sat, 3 Dec 2011 10:25:23 -0500 Date: Sat, 3 Dec 2011 10:25:23 -0500 From: Jack Howarth To: gcc-patches@gcc.gnu.org Cc: mikestump@comcast.net, iains@gcc.gnu.org Subject: [PATCH] pass -no_pie to LINK_GCC_C_SEQUENCE_SPEC on darwin Message-ID: <20111203152523.GA9331@bromo.med.uc.edu> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) 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 FSF gcc currently doesn't handle -fno-pie and friends properly under Lion. The darwin11 linker now defaults to -pie and must be explicitly passed -no_pie in such cases. The following patch extends LINK_GCC_C_SEQUENCE_SPEC to handle those instances which should pass -no_pie to the linker. The gcc.dg/darwin-segaddr.c testcase is also fixed by explicitly passing -fno-pie on dg-options since the test is meaningless for PIE. These patches also eliminate the excessive error failure currently since in gcc.dg/20020312-2.c as -fno-pic will now pass -no_pie to the linker which eliminates the linker warning... ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in _f from /var/tmp//ccVNy9V9.o. To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie Bootstrap and regression tested on x86_64-apple-darwin11. http://gcc.gnu.org/ml/gcc-testresults/2011-12/msg00287.html Okay for gcc trunk and backports to gcc-4_5-branch/gcc-4_6-branch? Jack Note that when -mmacosx-version-min=10.6 is used under Lion, the linker doesn't default to -pie so only the case of targeting 10.7 or later has to be considered. gcc/ 2011-12-03 Jack Howarth * gcc/config/darwin10.h (LINK_GCC_C_SEQUENCE_SPEC): Pass -no_pie for non-PIC code when targeting 10.7 or later. gcc/testsuite/ 2011-12-03 Jack Howarth * gcc.dg/darwin-segaddr.c: Use -no-pie. Index: gcc/testsuite/gcc.dg/darwin-segaddr.c =================================================================== --- gcc/testsuite/gcc.dg/darwin-segaddr.c (revision 181953) +++ gcc/testsuite/gcc.dg/darwin-segaddr.c (working copy) @@ -1,7 +1,7 @@ /* Check that -segaddr gets through and works. */ /* { dg-do run { target *-*-darwin* } } */ -/* { dg-options "-O0 -segaddr __TEST 0x200000" { target { *-*-darwin* && { ! lp64 } } } } */ -/* { dg-options "-O0 -segaddr __TEST 0x110000000" { target { *-*-darwin* && lp64 } } } */ +/* { dg-options "-O0 -segaddr __TEST 0x200000 -fno-pie" { target { *-*-darwin* && { ! lp64 } } } } */ +/* { dg-options "-O0 -segaddr __TEST 0x110000000 -fno-pie" { target { *-*-darwin* && lp64 } } } */ extern void abort (); Index: gcc/config/darwin10.h =================================================================== --- gcc/config/darwin10.h (revision 181953) +++ gcc/config/darwin10.h (working copy) @@ -26,7 +26,9 @@ along with GCC; see the file COPYING3. #define LINK_GCC_C_SEQUENCE_SPEC \ "%:version-compare(>= 10.6 mmacosx-version-min= -no_compact_unwind) \ %{!static:%{!static-libgcc: \ - %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } %G %L" + %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \ + %{fno-pic|fno-PIC|fno-pie|fno-PIE|fapple-kext|mkernel|static|mdynamic-no-pic: \ + %:version-compare(>= 10.7 mmacosx-version-min= -no_pie) } %G %L" #undef DEF_MIN_OSX_VERSION #define DEF_MIN_OSX_VERSION "10.6"