]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Darwin, backport codegen fix.
authorIain Sandoe <iain@sandoe.co.uk>
Sat, 3 Aug 2019 20:05:21 +0000 (20:05 +0000)
committerIain Sandoe <iains@gcc.gnu.org>
Sat, 3 Aug 2019 20:05:21 +0000 (20:05 +0000)
Darwin only supports "static" code in the kernel and
kernel extensions.  This check tries to prevent the case
that cascaded PIC/PIE options on the command line cause
non-pic to be selected.

2019-08-03  Iain Sandoe  <iain@sandoe.co.uk>

Backport from mainline
2019-07-07  Iain Sandoe  <iain@sandoe.co.uk>

* config/darwin.c (darwin_override_options): Make a final check on PIC
options.

From-SVN: r274048

gcc/ChangeLog
gcc/config/darwin.c

index f6d46b0a5da8907dc45e4a7d4fd77b2bf34b1a12..0a25d68add56f19520019994857cc2341c55e116 100644 (file)
@@ -3,6 +3,13 @@
        Backport from mainline
        2019-07-07  Iain Sandoe  <iain@sandoe.co.uk>
 
+       * config/darwin.c (darwin_override_options): Make a final check on PIC
+       options.
+
+2019-08-03  Iain Sandoe  <iain@sandoe.co.uk>
+
+       Backport from mainline
+       2019-07-07  Iain Sandoe  <iain@sandoe.co.uk>
        * config/darwin.c (darwin_override_options): Don't jam symbol stubs
        on for kernel code.
 
index 1141bc1823f50b951df1b02b699f8f0aa22cc7b1..b9862353843665eeea1f2712a36dfbb817f16bdf 100644 (file)
@@ -3243,6 +3243,8 @@ darwin_override_options (void)
       && write_symbols == DWARF2_DEBUG)
     flag_var_tracking_uninit = flag_var_tracking;
 
+  /* Final check on PCI options; for Darwin these are not dependent on the PIE
+     ones, although PIE does require PIC to support it.  */
   if (MACHO_DYNAMIC_NO_PIC_P)
     {
       if (flag_pic)
@@ -3251,9 +3253,11 @@ darwin_override_options (void)
                 " %<-fpie%> or %<-fPIE%>");
       flag_pic = 0;
     }
-  else if (flag_pic == 1)
+  else if (flag_pic == 1
+          || (flag_pic == 0 && !(flag_mkernel || flag_apple_kext)))
     {
-      /* Darwin's -fpic is -fPIC.  */
+      /* Darwin's -fpic is -fPIC.
+        We only support "static" code in the kernel and kernel exts.  */
       flag_pic = 2;
     }