]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Darwin] Make a final check on PIC options.
authorIain Sandoe <iain@sandoe.co.uk>
Wed, 4 Sep 2019 19:30:44 +0000 (19:30 +0000)
committerIain Sandoe <iains@gcc.gnu.org>
Wed, 4 Sep 2019 19:30:44 +0000 (19:30 +0000)
Final check on PCI options; for Darwin these are not dependent on the PIE
ones, although PIE does require PIC to support it. Specifically, for Darwin,
'-fPIC -fno-PIE' should result in the same as '-fno-PIE -fPIC'.

This is a workaround for the situation in which a 'stock-built' GCC is
unable to bootstrap m32 Darwin unless it's done '-mdynamic-no-pic'. So
this fixes a bootstrap fail in that case.

2019-09-04  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: r275386

gcc/ChangeLog
gcc/config/darwin.c

index 12ad854dca4f83a824a894996e500c4d938662e6..06dfed12c377d6d2ab597bba42ff738bd0f2b7da 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-09-04  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 6159b38acd70c4255d5fe938f587f64967ed0067..26875e97a6c98ec521816db9de81d4c64daf8cd0 100644 (file)
@@ -3204,6 +3204,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)
@@ -3212,9 +3214,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;
     }