diff options
Diffstat (limited to 'Makeconfig')
-rw-r--r-- | Makeconfig | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -1,4 +1,5 @@ # Copyright (C) 1991-2021 Free Software Foundation, Inc. +# Copyright (C) The GNU Toolchain Authors. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -376,19 +377,24 @@ LDFLAGS.so += $(hashstyle-LDFLAGS) LDFLAGS-rtld += $(hashstyle-LDFLAGS) endif -ifeq (yes,$(enable-static-pie)) +ifeq (no,$(build-pie-default)) +pie-default = $(no-pie-ccflag) +else # build-pie-default pic-default = -DPIC # Compile libc.a and libc_p.a with -fPIE/-fpie for static PIE. pie-default = $(pie-ccflag) + +ifeq (yes,$(enable-static-pie)) ifeq (yes,$(have-static-pie)) -default-pie-ldflag = -static-pie +static-pie-ldflag = -static-pie else # Static PIE can't have dynamic relocations in read-only segments since # static PIE is mapped into memory by kernel. --eh-frame-hdr is needed # for PIE to support exception. -default-pie-ldflag = -Wl,-pie,--no-dynamic-linker,--eh-frame-hdr,-z,text -endif -endif +static-pie-ldflag = -Wl,-pie,--no-dynamic-linker,--eh-frame-hdr,-z,text +endif # have-static-pie +endif # enable-static-pie +endif # build-pie-default # If lazy relocations are disabled, add the -z now flag. Use # LDFLAGS-lib.so instead of LDFLAGS.so, to avoid adding the flag to @@ -444,7 +450,7 @@ endif # Command for statically linking programs with the C library. ifndef +link-static +link-static-before-inputs = -nostdlib -nostartfiles -static \ - $(if $($(@F)-no-pie),$(no-pie-ldflag),$(default-pie-ldflag)) \ + $(if $($(@F)-no-pie),$(no-pie-ldflag),$(static-pie-ldflag)) \ $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ $(firstword $(CRT-$(@F)) $(csu-objpfx)$(real-static-start-installed-name)) \ $(+preinit) $(+prectorT) @@ -479,7 +485,7 @@ ifeq (yes,$(build-pie-default)) +link-tests-after-inputs = $(link-libc-tests) $(+link-pie-after-libc) +link-printers-tests = $(+link-pie-printers-tests) else # not build-pie-default -+link-before-inputs = -nostdlib -nostartfiles \ ++link-before-inputs = -nostdlib -nostartfiles $(no-pie-ldflag) \ $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \ $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-installed-name)) \ @@ -1040,6 +1046,7 @@ PIC-ccflag = -fPIC endif # This can be changed by a sysdep makefile pie-ccflag = -fpie +no-pie-ccflag = -fno-pie # This one should always stay like this unless there is a very good reason. PIE-ccflag = -fPIE ifeq (yes,$(build-profile)) |