From: Iain Sandoe Date: Sat, 3 Aug 2019 20:05:21 +0000 (+0000) Subject: Darwin, backport codegen fix. X-Git-Tag: releases/gcc-9.2.0~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd9a0dce18bb248c09dba44dc842c90f0f251993;p=thirdparty%2Fgcc.git Darwin, backport codegen fix. 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 Backport from mainline 2019-07-07 Iain Sandoe * config/darwin.c (darwin_override_options): Make a final check on PIC options. From-SVN: r274048 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f6d46b0a5da8..0a25d68add56 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -3,6 +3,13 @@ Backport from mainline 2019-07-07 Iain Sandoe + * config/darwin.c (darwin_override_options): Make a final check on PIC + options. + +2019-08-03 Iain Sandoe + + Backport from mainline + 2019-07-07 Iain Sandoe * config/darwin.c (darwin_override_options): Don't jam symbol stubs on for kernel code. diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 1141bc1823f5..b98623538436 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -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; }