From: H.J. Lu Date: Thu, 25 Jun 2015 09:37:04 +0000 (-0700) Subject: Support compilers defaulting to PIE X-Git-Tag: glibc-2.22~133 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cc08749b2d1c68284b25b157fbbe1ff219495cae;p=thirdparty%2Fglibc.git Support compilers defaulting to PIE To support building glibc with GCC 6 configured with --enable-default-pie, which generates PIE by default, we need to build programs as PIE. But elf/tst-dlopen-aout must not be built as PIE since it tests dlopen on ET_EXEC file and PIE is ET_DYN. [BZ #17841] * Makeconfig (no-pie-ldflag): New. (+link): Set to $(+link-pie) if default to PIE. (+link-tests): Set to $(+link-pie-tests) if default to PIE. * config.make.in (build-pie-default): New. * configure.ac (libc_cv_pie_default): New. Set to yes if -fPIE is default. AC_SUBST. * configure: Regenerated. * elf/Makefile (LDFLAGS-tst-dlopen-aout): New. --- diff --git a/ChangeLog b/ChangeLog index f9cf634a44f..7fe8b821960 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2015-06-25 H.J. Lu + + [BZ #17841] + * Makeconfig (no-pie-ldflag): New. + (+link): Set to $(+link-pie) if default to PIE. + (+link-tests): Set to $(+link-pie-tests) if default to PIE. + * config.make.in (build-pie-default): New. + * configure.ac (libc_cv_pie_default): New. Set to yes if -fPIE + is default. AC_SUBST. + * configure: Regenerated. + * elf/Makefile (LDFLAGS-tst-dlopen-aout): New. + 2015-06-24 Roland McGrath * nptl/descr.h (struct pthread): Change type of field setxid_futex diff --git a/Makeconfig b/Makeconfig index 0f4b5497c1b..7b46323bd28 100644 --- a/Makeconfig +++ b/Makeconfig @@ -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/NEWS b/NEWS index 727e21f7704..58f85e79bb8 100644 --- a/NEWS +++ b/NEWS @@ -14,17 +14,17 @@ Version 2.22 16526, 16538, 16560, 16704, 16783, 16850, 17053, 17090, 17195, 17269, 17293, 17322, 17403, 17523, 17542, 17569, 17581, 17588, 17596, 17620, 17621, 17628, 17631, 17692, 17711, 17715, 17776, 17779, 17792, 17836, - 17912, 17916, 17930, 17932, 17944, 17949, 17964, 17965, 17967, 17969, - 17977, 17978, 17987, 17991, 17996, 17998, 17999, 18007, 18019, 18020, - 18029, 18030, 18032, 18034, 18036, 18038, 18039, 18042, 18043, 18046, - 18047, 18049, 18068, 18080, 18093, 18100, 18104, 18110, 18111, 18116, - 18125, 18128, 18138, 18185, 18196, 18197, 18206, 18210, 18211, 18217, - 18219, 18220, 18221, 18234, 18244, 18245, 18247, 18287, 18319, 18324, - 18333, 18346, 18371, 18397, 18409, 18410, 18412, 18418, 18422, 18434, - 18444, 18468, 18469, 18470, 18479, 18483, 18495, 18496, 18497, 18498, - 18507, 18512, 18513, 18519, 18520, 18522, 18527, 18528, 18529, 18530, - 18532, 18533, 18534, 18536, 18539, 18540, 18542, 18544, 18545, 18546, - 18547, 18553, 18558, 18569, 18583, 18585, 18586, 18593, 18594. + 17841, 17912, 17916, 17930, 17932, 17944, 17949, 17964, 17965, 17967, + 17969, 17977, 17978, 17987, 17991, 17996, 17998, 17999, 18007, 18019, + 18020, 18029, 18030, 18032, 18034, 18036, 18038, 18039, 18042, 18043, + 18046, 18047, 18049, 18068, 18080, 18093, 18100, 18104, 18110, 18111, + 18116, 18125, 18128, 18138, 18185, 18196, 18197, 18206, 18210, 18211, + 18217, 18219, 18220, 18221, 18234, 18244, 18245, 18247, 18287, 18319, + 18324, 18333, 18346, 18371, 18397, 18409, 18410, 18412, 18418, 18422, + 18434, 18444, 18468, 18469, 18470, 18479, 18483, 18495, 18496, 18497, + 18498, 18507, 18512, 18513, 18519, 18520, 18522, 18527, 18528, 18529, + 18530, 18532, 18533, 18534, 18536, 18539, 18540, 18542, 18544, 18545, + 18546, 18547, 18553, 18558, 18569, 18583, 18585, 18586, 18593, 18594. * Cache information can be queried via sysconf() function on s390 e.g. with _SC_LEVEL1_ICACHE_SIZE as argument. diff --git a/config.make.in b/config.make.in index 5a18daed24c..a9f5696077a 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@ diff --git a/configure b/configure index 1e4138b524e..45cc7cba2bf 100755 --- a/configure +++ b/configure @@ -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 <&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 ff66b875e3b..7e9383a7f0b 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 <&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 4ea3ccf4410..f21276c0064 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -151,6 +151,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)