This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch hjl/pr17841/master created. glibc-2.21-174-gf9a8dda


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/master has been created
        at  f9a8dda341d1493d7666b5242a0ae42c385bc632 (commit)

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=f9a8dda341d1493d7666b5242a0ae42c385bc632

commit f9a8dda341d1493d7666b5242a0ae42c385bc632
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.
    	(test-object-suffix): New.
    	* 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 ($(objpfx)md5test): Replace ".o" with
    	$(test-object-suffix).
    	($(objpfx)md5test-giant): Likewise.
    	($(objpfx)sha256test): Likewise.
    	($(objpfx)sha512test): Likewise.

diff --git a/Makeconfig b/Makeconfig
index 095f40e..7158a0a 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -903,11 +903,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.
@@ -963,6 +967,15 @@ CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
 libtype.oS = lib%_nonshared.a
 endif
 
+# 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))
+test-object-suffix := .os
+else
+test-object-suffix := .o
+endif
+
 # The assembler can generate debug information too.
 ifndef ASFLAGS
 ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
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..7cf7a59 100644
--- a/crypt/Makefile
+++ b/crypt/Makefile
@@ -58,10 +58,10 @@ 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))
+$(objpfx)md5test: $(patsubst %, $(objpfx)%$(test-object-suffix),$(md5-routines))
+$(objpfx)md5test-giant: $(patsubst %, $(objpfx)%$(test-object-suffix),$(md5-routines))
+$(objpfx)sha256test: $(patsubst %, $(objpfx)%$(test-object-suffix),$(sha256-routines))
+$(objpfx)sha512test: $(patsubst %, $(objpfx)%$(test-object-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=5307cac2785efd24eef5a21b6ee6e83a4ed46ac7

commit 5307cac2785efd24eef5a21b6ee6e83a4ed46ac7
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 (no-pie-ldflag): New.
    	(+link): Renamed to ...
    	(+link-no-pie): This.  Add $(no-pie-ldflag).
    	(+link-tests): Renamed to ...
    	(++link-no-pie-tests): This.  Add $(no-pie-ldflag).
    	(+link): New.  Set to $(+link-no-pie) or $(+link-pie), depend on
    	if PIE is default.
    	(+link-tests): New.  Set to $(+link-pie-tests) or
    	$(+link-no-pie-tests), depend on if PIE is default.
    	* Rules (binaries-no-pie-tests): New.
    	(binaries-no-pie-notests): Likewise.
    	($(addprefix $(objpfx),$(binaries-no-pie-tests))): Likewise.
    	($(addprefix $(objpfx),$(binaries-no-pie-notests))): Likewise.
    	* 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 (tests-no-pie): Set to tst-dlopen-aout.
    	(tests): Replace tst-dlopen-aout with $(tests-no-pie).
    	* math/Makefile (tests): Replace atest-exp atest-sincos
    	atest-exp2 with $(tests-no-pie).
    	(tests-no-pie): New.

diff --git a/Makeconfig b/Makeconfig
index 4e336a4..095f40e 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -387,6 +387,12 @@ LDFLAGS.so += $(hashstyle-LDFLAGS)
 LDFLAGS-rtld += $(hashstyle-LDFLAGS)
 endif
 
+ifeq (yes,$(build-pie-default))
+no-pie-ldflag = -no-pie
+else
+no-pie-ldflag =
+endif
+
 # Command to run after every final link (executable or shared object).
 # This is invoked with $(call after-link,...), so it should operate on
 # the file $1.  This can be set to do some sort of post-processing on
@@ -453,15 +459,23 @@ ifeq (yes,$(build-shared))
 			   $(common-objpfx)libc% $(+postinit),$^) \
 	      $(link-extra-libs)
 +link-after-libc = $(+postctor) $(+postinit)
-define +link
-$(+link-before-libc) $(rtld-LDFLAGS) $(link-libc) $(+link-after-libc)
+define +link-no-pie
+$(+link-before-libc) $(rtld-LDFLAGS) $(no-pie-ldflag) $(link-libc) \
+		     $(+link-after-libc)
 $(call after-link,$@)
 endef
-define +link-tests
-$(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
-		     $(+link-after-libc)
+define +link-no-pie-tests
+$(+link-before-libc) $(rtld-tests-LDFLAGS)  $(no-pie-ldflag) \
+		     $(link-libc-tests) $(+link-after-libc)
 $(call after-link,$@)
 endef
+ifeq (yes,$(build-pie-default))
++link = $(+link-pie)
++link-tests = $(+link-pie-tests)
+else
++link = $(+link-no-pie)
++link-tests = $(+link-no-pie-tests)
+endif
 else
 +link = $(+link-static)
 +link-tests = $(+link-static-tests)
diff --git a/Rules b/Rules
index 829beac..abef119 100644
--- a/Rules
+++ b/Rules
@@ -123,6 +123,8 @@ else
 binaries-pie-tests =
 binaries-pie-notests =
 endif
+binaries-no-pie-tests = $(tests-no-pie) $(xtests-no-pie)
+binaries-no-pie-notests = $(others-no-pie)
 else
 binaries-all-notests =
 binaries-all-tests = $(tests) $(xtests) $(test-srcs)
@@ -168,6 +170,20 @@ $(addprefix $(objpfx),$(binaries-pie-notests)): %: %.o \
 	$(+link-pie)
 endif
 
+ifneq "$(strip $(binaries-no-pie-tests))" ""
+$(addprefix $(objpfx),$(binaries-no-pie-tests)): %: %.o \
+  $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
+  $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
+	$(+link-no-pie-tests)
+endif
+
+ifneq "$(strip $(binaries-no-pie-notests))" ""
+$(addprefix $(objpfx),$(binaries-no-pie-notests)): %: %.o \
+  $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
+  $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
+	$(+link-no-pie)
+endif
+
 ifneq "$(strip $(binaries-static-notests))" ""
 $(addprefix $(objpfx),$(binaries-static-notests)): %: %.o \
   $(sort $(filter $(common-objpfx)lib%,$(link-libc-static))) \
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@
diff --git a/configure b/configure
index 79864b7..15b1c43 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
@@ -7299,6 +7300,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 39f3e86..c7f7246 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2063,6 +2063,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 e852b5f..d5b3eb5 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -149,7 +149,10 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
 	 tst-ptrguard1
 #	 reldep9
 ifeq ($(build-hardcoded-path-in-tests),yes)
-tests += tst-dlopen-aout
+# tst-dlopen-aout fails as PIE since it tests dlopen on ET_EXEC.  Make
+# sure that it is built as non-PIE.
+tests-no-pie = tst-dlopen-aout
+tests += $(tests-no-pie)
 endif
 test-srcs = tst-pathopt
 selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null)
diff --git a/math/Makefile b/math/Makefile
index 3904e41..401fd8d 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -86,12 +86,15 @@ routines = $(calls) $(calls:=f) $(long-c-$(long-double-fcts))
 long-c-yes = $(calls:=l)
 
 # Rules for the test suite.
-tests = test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-test \
+tests = test-matherr test-fenv basic-test \
 	test-misc test-fpucw test-fpucw-ieee tst-definitions test-tgmath \
 	test-tgmath-ret bug-nextafter bug-nexttoward bug-tgmath1 \
 	test-tgmath-int test-tgmath2 test-powl tst-CMPLX tst-CMPLX2 test-snan \
 	test-fenv-tls test-fenv-preserve test-fenv-return test-fenvinline \
-	$(tests-static)
+	$(tests-static) $(tests-no-pie)
+# These tests can't be built as PIE since they are linked against
+# $(gmp-objs) which may not be compiled with PIE/PIC.
+tests-no-pie = atest-exp atest-sincos atest-exp2
 tests-static = test-fpucw-static test-fpucw-ieee-static
 # We do the `long double' tests only if this data type is available and
 # distinct from `double'.

-----------------------------------------------------------------------


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]