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.
This commit is contained in:
H.J. Lu 2015-06-25 02:37:04 -07:00
parent 45a8f0e662
commit cc08749b2d
7 changed files with 65 additions and 11 deletions

View File

@ -1,3 +1,15 @@
2015-06-25 H.J. Lu <hongjiu.lu@intel.com>
[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 <roland@hack.frob.com>
* nptl/descr.h (struct pthread): Change type of field setxid_futex

View File

@ -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)

22
NEWS
View File

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

View File

@ -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@

21
configure vendored
View File

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

View File

@ -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)

View File

@ -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)