This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch hjl/pr17841 created. glibc-2.21-152-g2a0b2d2
- From: hjl at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 3 Mar 2015 16:29:28 -0000
- Subject: GNU C Library master sources branch hjl/pr17841 created. glibc-2.21-152-g2a0b2d2
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, hjl/pr17841 has been created
at 2a0b2d28affdb91ecdb0900719ba2f9fb942d0ee (commit)
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=2a0b2d28affdb91ecdb0900719ba2f9fb942d0ee
commit 2a0b2d28affdb91ecdb0900719ba2f9fb942d0ee
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Mar 2 10:40:46 2015 -0800
Use -mno-copyreloc-in-pie to compile vismain.c
GCC 5 may use copy relocation in PIE on x86-64 if linker supports it.
But vismain.c, which is compiled as PIE, doesn't work with copy
relocation. This patch compiles vismain.c with -mno-copyreloc-in-pie
if -mcopyreloc-in-pie is available.
[BZ #17841]
* config.make.in (have-mcopyreloc-in-pie): New.
* configure.ac (libc_cv_mcopyreloc_in_pie): New. Set to yes if
-mcopyreloc-in-pie works. AC_SUBST.
* configure: Regenerated.
* elf/Makefile (CFLAGS-vismain.c): Add -mno-copyreloc-in-pie
if supported.
diff --git a/config.make.in b/config.make.in
index 635932f..5b14b64 100644
--- a/config.make.in
+++ b/config.make.in
@@ -55,6 +55,7 @@ old-glibc-headers = @old_glibc_headers@
unwind-find-fde = @libc_cv_gcc_unwind_find_fde@
have-forced-unwind = @libc_cv_forced_unwind@
have-fpie = @libc_cv_fpie@
+have-mcopyreloc-in-pie = @libc_cv_mcopyreloc_in_pie@
gnu89-inline-CFLAGS = @gnu89_inline@
have-ssp = @libc_cv_ssp@
have-selinux = @have_selinux@
diff --git a/configure b/configure
index ce69ca4..ee0ce76 100755
--- a/configure
+++ b/configure
@@ -629,6 +629,7 @@ libc_cv_ssp
fno_unit_at_a_time
libc_cv_output_format
libc_cv_hashstyle
+libc_cv_mcopyreloc_in_pie
libc_cv_fpie
libc_cv_z_execstack
libc_cv_z_combreloc
@@ -6103,6 +6104,27 @@ $as_echo "$libc_cv_fpie" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -mcopyreloc-in-pie" >&5
+$as_echo_n "checking for -mcopyreloc-in-pie... " >&6; }
+if ${libc_cv_mcopyreloc_in_pie+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if { ac_try='${CC-cc} -mcopyreloc-in-pie -xc /dev/null -S -o /dev/null'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then :
+ libc_cv_mcopyreloc_in_pie=yes
+else
+ libc_cv_mcopyreloc_in_pie=no
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_mcopyreloc_in_pie" >&5
+$as_echo "$libc_cv_mcopyreloc_in_pie" >&6; }
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --hash-style option" >&5
$as_echo_n "checking for --hash-style option... " >&6; }
if ${libc_cv_hashstyle+:} false; then :
diff --git a/configure.ac b/configure.ac
index 91a724b..f5bce8d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1427,6 +1427,13 @@ LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
AC_SUBST(libc_cv_fpie)
+AC_CACHE_CHECK(for -mcopyreloc-in-pie, libc_cv_mcopyreloc_in_pie, [dnl
+LIBC_TRY_CC_OPTION([-mcopyreloc-in-pie],
+ [libc_cv_mcopyreloc_in_pie=yes],
+ [libc_cv_mcopyreloc_in_pie=no])
+])
+AC_SUBST(libc_cv_mcopyreloc_in_pie)
+
AC_CACHE_CHECK(for --hash-style option,
libc_cv_hashstyle, [dnl
cat > conftest.c <<EOF
diff --git a/elf/Makefile b/elf/Makefile
index 711beed..2a7b9c1 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -220,8 +220,12 @@ tests += tst-pie1 tst-pie2
tests-pie += tst-pie1 tst-pie2
tests += vismain
tests-pie += vismain
+ifeq (yes,$(have-mcopyreloc-in-pie))
+CFLAGS-vismain.c = $(PIE-ccflag) -mno-copyreloc-in-pie
+else
CFLAGS-vismain.c = $(PIE-ccflag)
endif
+endif
modules-execstack-yes = tst-execstack-mod
extra-test-objs += $(addsuffix .os,$(strip $(modules-names)))
# We need this variable to be sure the test modules get the right CPPFLAGS.
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=157b304dd18e7ffb89921ea80b9fbebe9da18952
commit 157b304dd18e7ffb89921ea80b9fbebe9da18952
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Mar 2 14:53:11 2015 -0800
Compile archives with -fno-pie
When compiler defaults to PIE, we compile archives with -fno-pie. Since
archives won't be used with PIE, compile them with -fpie isn't necessary.
[BZ #17841]
* Makeconfig (no-pie-ccflag): New. Set to -fno-pie.
(pic-default): Don't define if $(no-pie-ccflag) is -fno-pie.
* Makerules (archive-objects): New. Set before including
extra-lib.mk.
($(archive-objects)): New. New rule to append $(no-pie-ccflag)
to CFLAGS.
* extra-lib.mk (archive-objects): New.
* crypt/Makefile (crypt-suffix): New.
($(objpfx)md5test): Replace ".o" with $(crypt-suffix).
($(objpfx)md5test-giant): Likewise.
($(objpfx)sha256test): Likewise.
($(objpfx)sha512test): Likewise.
diff --git a/Makeconfig b/Makeconfig
index 2da7639..db66246 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -889,11 +889,15 @@ override CXXFLAGS = $(c++-sysincludes) \
$(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
$(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
+# This can be changed by a sysdep makefile
+no-pie-ccflag = -fno-pie
# If everything is compiled with -fPIC (implicitly) we must tell this by
-# defining the PIC symbol.
+# defining the PIC symbol unless -fno-pie is used to compile archives.
ifeq (yes,$(build-pic-default))
+ifneq (-fno-pie,$(no-pie-ccflag))
pic-default = -DPIC
endif
+endif
# Enable object files for different versions of the library.
# Various things use $(object-suffixes) to know what all to make.
diff --git a/Makerules b/Makerules
index c79915f..75ecae1 100644
--- a/Makerules
+++ b/Makerules
@@ -705,6 +705,7 @@ headers := $(headers) $(sysdep_headers)
# replacing every ".c" in `sources' with a ".o".
override objects := $(addprefix $(objpfx),$(sources:.c=.o))
+archive-objects := $(objects)
# The makefile may define $(extra-libs) with `libfoo libbar'
# to build libfoo.a et al from the modules listed in $(libfoo-routines).
@@ -716,6 +717,9 @@ extra-libs-left := $(extra-libs)
include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
endif
+# Set "archive-objects" before including extra-lib.mk which will append
+# "archive-objects".
+$(archive-objects): CFLAGS += $(no-pie-ccflag)
# The makefile may define $(modules-names) to build additional modules.
# These are built with $(build-module), except any in $(modules-names-nobuild).
diff --git a/crypt/Makefile b/crypt/Makefile
index 34c4dd7..7da2735 100644
--- a/crypt/Makefile
+++ b/crypt/Makefile
@@ -58,10 +58,19 @@ md5-routines := md5 $(filter md5%,$(libcrypt-sysdep_routines))
sha256-routines := sha256 $(filter sha256%,$(libcrypt-sysdep_routines))
sha512-routines := sha512 $(filter sha512%,$(libcrypt-sysdep_routines))
-$(objpfx)md5test: $(patsubst %, $(objpfx)%.o,$(md5-routines))
-$(objpfx)md5test-giant: $(patsubst %, $(objpfx)%.o,$(md5-routines))
-$(objpfx)sha256test: $(patsubst %, $(objpfx)%.o,$(sha256-routines))
-$(objpfx)sha512test: $(patsubst %, $(objpfx)%.o,$(sha512-routines))
+# When compiler defaults to PIE, we compile archives with -fno-pie and
+# we can't link tests against .o files for archives. We need to link
+# against .os files for shared libraries.
+ifeq (yes,$(build-pie-default))
+crypt-suffix := .os
+else
+crypt-suffix := .o
+endif
+
+$(objpfx)md5test: $(patsubst %, $(objpfx)%$(crypt-suffix),$(md5-routines))
+$(objpfx)md5test-giant: $(patsubst %, $(objpfx)%$(crypt-suffix),$(md5-routines))
+$(objpfx)sha256test: $(patsubst %, $(objpfx)%$(crypt-suffix),$(sha256-routines))
+$(objpfx)sha512test: $(patsubst %, $(objpfx)%$(crypt-suffix),$(sha512-routines))
endif
ifeq (yes,$(build-shared))
diff --git a/extra-lib.mk b/extra-lib.mk
index b10748d..73b1e7f 100644
--- a/extra-lib.mk
+++ b/extra-lib.mk
@@ -27,6 +27,11 @@ extra-objs := $(extra-objs)
# The modules that go in $(lib).
all-$(lib)-routines := $($(lib)-routines) $($(lib)-sysdep_routines)
+# rpcsvc library is compiled with PIC.
+ifneq (librpcsvc,$(lib))
+archive-objects += $(addprefix $(objpfx),$(patsubst %,%.o,$(all-$(lib)-routines)))
+endif
+
# Add each flavor of library to the lists of things to build and install.
install-lib += $(foreach o,$(object-suffixes-$(lib)),$(lib:lib%=$(libtype$o)))
extra-objs += $(foreach o,$(filter-out .os .oS,$(object-suffixes-$(lib))),\
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=b13706de6259ffb4140b75e898038afe04b2074f
commit b13706de6259ffb4140b75e898038afe04b2074f
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Jan 14 06:29:04 2015 -0800
Support compilers defaulting to PIE
If PIE is the default, we need to build programs as PIE.
[BZ #17841]
* Makeconfig (+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.
diff --git a/Makeconfig b/Makeconfig
index 509b5bd..2da7639 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -442,6 +442,10 @@ endif
# Commands for linking programs with the C library.
ifndef +link
ifeq (yes,$(build-shared))
+ifeq (yes,$(build-pie-default))
++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 +466,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 ad4dd30..635932f 100644
--- a/config.make.in
+++ b/config.make.in
@@ -81,6 +81,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 7337823..ce69ca4 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
@@ -7169,6 +7170,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 8043a27..91a724b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2031,6 +2031,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)
-----------------------------------------------------------------------
hooks/post-receive
--
GNU C Library master sources