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 <howa...@bromo.med.uc.edu>

        * 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 <howa...@bromo.med.uc.edu>

        * 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"

Reply via email to