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-414-gca1f728


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  ca1f728cbefd6955735087e45d80620113623b3b (commit)

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

commit ca1f728cbefd6955735087e45d80620113623b3b
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.
    	* math/Makefile (LDFLAGS-atest-exp): New.
    	(LDFLAGS-atest-sincos): Likewise.
    	(LDFLAGS-atest-exp2): Likewise.

diff --git a/Makeconfig b/Makeconfig
index 831604a..f9c3b5e 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -891,11 +891,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.
@@ -951,6 +955,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))),\
diff --git a/math/Makefile b/math/Makefile
index 9a3cf32..5cc5593 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -246,4 +246,7 @@ gmp-objs = $(patsubst %,$(common-objpfx)stdlib/%.o,\
 $(objpfx)atest-exp: $(gmp-objs)
 $(objpfx)atest-sincos: $(gmp-objs)
 $(objpfx)atest-exp2: $(gmp-objs)
+LDFLAGS-atest-exp = $(no-pie-ldflag)
+LDFLAGS-atest-sincos = $(no-pie-ldflag)
+LDFLAGS-atest-exp2 = $(no-pie-ldflag)
 $(objpfx)test-fenv-tls: $(shared-thread-library)

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=1ea33bb5517516d1d1005b953c92a071454e66d5

commit 1ea33bb5517516d1d1005b953c92a071454e66d5
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jan 14 06:29:04 2015 -0800

    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/Makeconfig b/Makeconfig
index d32a0fd..831604a 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/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 1e4138b..45cc7cb 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 <<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)

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


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]