diff options
-rw-r--r-- | Makeconfig | 6 | ||||
-rw-r--r-- | config.make.in | 1 | ||||
-rwxr-xr-x | configure | 21 | ||||
-rw-r--r-- | configure.ac | 13 | ||||
-rw-r--r-- | elf/Makefile | 1 |
5 files changed, 42 insertions, 0 deletions
@@ -442,6 +442,11 @@ endif # Commands for linking programs with the C library. ifndef +link ifeq (yes,$(build-shared)) +ifeq (yes,$(build-pie-default)) +no-pie-ldflag = -no-pie ++link = $(+link-pie) ++link-tests = $(+link-pie-tests) +else +link-before-libc = $(CC) -nostdlib -nostartfiles -o $@ \ $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \ @@ -462,6 +467,7 @@ $(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \ $(+link-after-libc) $(call after-link,$@) endef +endif else +link = $(+link-static) +link-tests = $(+link-static-tests) diff --git a/config.make.in b/config.make.in index 5a18dae..a9f5696 100644 --- a/config.make.in +++ b/config.make.in @@ -82,6 +82,7 @@ nss-crypt = @libc_cv_nss_crypt@ # Configuration options. build-shared = @shared@ build-pic-default= @libc_cv_pic_default@ +build-pie-default= @libc_cv_pie_default@ build-profile = @profile@ build-static-nss = @static_nss@ add-ons = @add_ons@ @@ -596,6 +596,7 @@ mach_interface_list DEFINES static_nss profile +libc_cv_pie_default libc_cv_pic_default shared static @@ -7317,6 +7318,26 @@ fi $as_echo "$libc_cv_pic_default" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -fPIE is default" >&5 +$as_echo_n "checking whether -fPIE is default... " >&6; } +if ${libc_cv_pie_default+:} false; then : + $as_echo_n "(cached) " >&6 +else + libc_cv_pie_default=yes +cat > conftest.c <<EOF +#if defined __PIE__ || defined __pie__ || defined PIE || defined pie +# error PIE is default. +#endif +EOF +if eval "${CC-cc} -S conftest.c 2>&5 1>&5"; then + libc_cv_pie_default=no +fi +rm -f conftest.* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_pie_default" >&5 +$as_echo "$libc_cv_pie_default" >&6; } + + diff --git a/configure.ac b/configure.ac index ff66b87..7e9383a 100644 --- a/configure.ac +++ b/configure.ac @@ -2075,6 +2075,19 @@ fi rm -f conftest.*]) AC_SUBST(libc_cv_pic_default) +AC_CACHE_CHECK([whether -fPIE is default], libc_cv_pie_default, +[libc_cv_pie_default=yes +cat > conftest.c <<EOF +#if defined __PIE__ || defined __pie__ || defined PIE || defined pie +# error PIE is default. +#endif +EOF +if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then + libc_cv_pie_default=no +fi +rm -f conftest.*]) +AC_SUBST(libc_cv_pie_default) + AC_SUBST(profile) AC_SUBST(static_nss) diff --git a/elf/Makefile b/elf/Makefile index dedf3c7..d4421e9 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -150,6 +150,7 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \ # reldep9 ifeq ($(build-hardcoded-path-in-tests),yes) tests += tst-dlopen-aout +LDFLAGS-tst-dlopen-aout = $(no-pie-ldflag) endif test-srcs = tst-pathopt selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null) |