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  <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
This commit is contained in:
Iain Sandoe 2019-08-03 20:05:21 +00:00 committed by Iain Sandoe
parent 8e28d02d02
commit bd9a0dce18
2 changed files with 13 additions and 2 deletions

View 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.

View 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;
}