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 hl/pie/static created. glibc-2.25-758-g8e68fdc


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, hl/pie/static has been created
        at  8e68fdc8a054d75f0de620863657dc5f506d67f0 (commit)

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

commit 8e68fdc8a054d75f0de620863657dc5f506d67f0
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jul 17 13:53:52 2017 -0700

    Dummy _dl_setup_static_pie

diff --git a/csu/libc-start.c b/csu/libc-start.c
index 6720617..6f47524 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
@@ -183,6 +183,10 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
         }
     }
 
+# if HAVE_STATIC_PIE
+  _dl_setup_static_pie ();
+# endif
+
   /* Initialize very early so that tunables can use it.  */
   __libc_init_secure ();
 
diff --git a/elf/dl-support.c b/elf/dl-support.c
index c22be85..a9935ab 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -304,6 +304,17 @@ _dl_aux_init (ElfW(auxv_t) *av)
 }
 #endif
 
+#if HAVE_STATIC_PIE
+void
+internal_function
+_dl_setup_static_pie (void)
+{
+  ElfW(Addr) load = elf_machine_load_address ();
+
+  _dl_main_map.l_addr = load;
+}
+#endif
+
 
 void
 internal_function
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 4508365..39d1891 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -1006,6 +1006,10 @@ extern void _dl_determine_tlsoffset (void) internal_function attribute_hidden;
    stack protector, among other things).  */
 void __libc_setup_tls (void);
 
+/* Set up static executable with PIE.  */
+void _dl_setup_static_pie (void)
+     internal_function __attribute__ ((visibility ("hidden")));
+
 /* Initialization of libpthread for statically linked applications.
    If libpthread is not linked in, this is an empty function.  */
 void __pthread_initialize_minimal (void) weak_function;

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

commit 759ceaf5d11d6179b152dcbd374bd5478221e021
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jul 17 08:54:40 2017 -0700

    Define pie-default/default-pie-ldflag for --enable-static-pie
    
    1. Add $(pie-default) to CFLAGS-.o and CFLAGS-.op.
    2. Add $(default-pie-ldflag) to +link-static-before-libc.
    3. Define static-start-installed-name to S$(start-installed-name).
    4. Define +prectorT/+postctorT to $(+prectorS)/$(+postctorS).

diff --git a/Makeconfig b/Makeconfig
index 80aed2a..618d0f9 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -364,8 +364,12 @@ start-installed-name = crt1.o
 # On systems that do not need a special startfile for statically linked
 # binaries, simply set it to the normal name.
 ifndef static-start-installed-name
+ifeq (yes,$(have-static-pie))
+static-start-installed-name = S$(start-installed-name)
+else
 static-start-installed-name = $(start-installed-name)
 endif
+endif
 
 ifeq (yesyes,$(build-shared)$(have-z-combreloc))
 combreloc-LDFLAGS = -Wl,-z,combreloc
@@ -386,6 +390,12 @@ LDFLAGS.so += $(hashstyle-LDFLAGS)
 LDFLAGS-rtld += $(hashstyle-LDFLAGS)
 endif
 
+ifeq (yes,$(have-static-pie))
+pic-default = -DPIC
+pie-default = -fPIE
+default-pie-ldflag = -pie -Wl,--no-dynamic-linker
+endif
+
 # If lazy relocations are disabled, add the -z now flag.  Use
 # LDFLAGS-lib.so instead of LDFLAGS.so, to avoid adding the flag to
 # test modules.
@@ -435,6 +445,7 @@ endif
 # Command for statically linking programs with the C library.
 ifndef +link-static
 +link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \
+	      $(default-pie-ldflag) \
 	      $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F))  \
 	      $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
 	      $(+preinit) $(+prectorT) \
@@ -651,8 +662,13 @@ endif
 +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
 +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
 # Variants of the two previous definitions for statically linking programs.
+ifeq (yes,$(have-static-pie))
++prectorT = $(+prectorS)
++postctorT = $(+postctorS)
+else
 +prectorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o`
 +postctorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
+endif
 csu-objpfx = $(common-objpfx)csu/
 elf-objpfx = $(common-objpfx)elf/
 
@@ -973,7 +989,7 @@ libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
 all-object-suffixes := .o .os .oS
 object-suffixes :=
 CPPFLAGS-.o = $(pic-default)
-CFLAGS-.o = $(filter %frame-pointer,$(+cflags))
+CFLAGS-.o = $(filter %frame-pointer,$(+cflags)) $(pie-default)
 libtype.o := lib%.a
 object-suffixes += .o
 ifeq (yes,$(build-shared))
@@ -998,7 +1014,7 @@ ifeq (yes,$(build-profile))
 all-object-suffixes += .op
 object-suffixes += .op
 CPPFLAGS-.op = -DPROF $(pic-default)
-CFLAGS-.op = -pg
+CFLAGS-.op = -pg $(pie-default)
 libtype.op = lib%_p.a
 endif
 

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

commit 862a91da1618222422449f862b8ef330261b55c3
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jul 17 08:36:45 2017 -0700

    Add --enable-static-pie

diff --git a/config.h.in b/config.h.in
index 21a7b15..7982eb3 100644
--- a/config.h.in
+++ b/config.h.in
@@ -249,6 +249,9 @@
 /* Build glibc with tunables support.  */
 #define HAVE_TUNABLES 0
 
+/* Build glibc with static executables as PIE.  */
+#define HAVE_STATIC_PIE 0
+
 /* Some compiler options may now allow to use ebp in __asm__ (used mainly
    in i386 6 argument syscall issue).  */
 #define CAN_USE_REGISTER_ASM_EBP 0
diff --git a/configure b/configure
index 6d7aa3c..8b7e3f2 100755
--- a/configure
+++ b/configure
@@ -765,6 +765,7 @@ with_default_link
 enable_sanity_checks
 enable_shared
 enable_profile
+enable_static_pie
 enable_timezone_tools
 enable_hardcoded_path_in_tests
 enable_stackguard_randomization
@@ -1422,6 +1423,7 @@ Optional Features:
                           in special situations) [default=yes]
   --enable-shared         build shared library [default=yes if GNU ld]
   --enable-profile        build profiled library [default=no]
+  --enable-static-pie     build static executables as PIE [default=no]
   --disable-timezone-tools
                           do not install timezone tools [default=install]
   --enable-hardcoded-path-in-tests
@@ -3370,6 +3372,13 @@ else
   profile=no
 fi
 
+# Check whether --enable-static-pie was given.
+if test "${enable_static_pie+set}" = set; then :
+  enableval=$enable_static_pie; static_pie=$enableval
+else
+  static_pie=no
+fi
+
 # Check whether --enable-timezone-tools was given.
 if test "${enable_timezone_tools+set}" = set; then :
   enableval=$enable_timezone_tools; enable_timezone_tools=$enableval
@@ -6890,6 +6899,18 @@ fi
 $as_echo "$libc_cv_pie_default" >&6; }
 
 
+# The linker must support --no-dynamic-linker if --enable-static-pie is
+# used.
+if test "$static_pie" = yes; then
+  if test "$libc_cv_no_dynamic_linker" != yes; then
+    as_fn_error $? "linker support for --no-dynamic-linker needed" "$LINENO" 5
+  fi
+  $as_echo "#define HAVE_STATIC_PIE 1" >>confdefs.h
+
+fi
+config_vars="$config_vars
+have-static-pie = $static_pie"
+
 
 
 
diff --git a/configure.ac b/configure.ac
index 021c792..aa57519 100644
--- a/configure.ac
+++ b/configure.ac
@@ -176,6 +176,11 @@ AC_ARG_ENABLE([profile],
 			     [build profiled library @<:@default=no@:>@]),
 	      [profile=$enableval],
 	      [profile=no])
+AC_ARG_ENABLE([static-pie],
+	      AC_HELP_STRING([--enable-static-pie],
+			     [build static executables as PIE @<:@default=no@:>@]),
+	      [static_pie=$enableval],
+	      [static_pie=no])
 AC_ARG_ENABLE([timezone-tools],
 	      AC_HELP_STRING([--disable-timezone-tools],
 			     [do not install timezone tools @<:@default=install@:>@]),
@@ -1950,6 +1955,16 @@ fi
 rm -f conftest.*])
 AC_SUBST(libc_cv_pie_default)
 
+# The linker must support --no-dynamic-linker if --enable-static-pie is
+# used.
+if test "$static_pie" = yes; then
+  if test "$libc_cv_no_dynamic_linker" != yes; then
+    AC_MSG_ERROR([linker support for --no-dynamic-linker needed])
+  fi
+  AC_DEFINE(HAVE_STATIC_PIE)
+fi
+LIBC_CONFIG_VAR([have-static-pie], [$static_pie])
+
 AC_SUBST(profile)
 AC_SUBST(static_nss)
 

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

commit 3f32b755d6b613dc12bd28c8e9c47cf37dc752aa
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jul 17 08:17:32 2017 -0700

    Check if linker supports --no-dynamic-linker

diff --git a/config.h.in b/config.h.in
index 2241857..21a7b15 100644
--- a/config.h.in
+++ b/config.h.in
@@ -177,6 +177,9 @@
 /* Define if the linker defines __ehdr_start.  */
 #undef HAVE_EHDR_START
 
+/* Define if the linker supports --no-dynamic-linker.  */
+#undef HAVE_NO_DYNAMIC_LINKER
+
 /*
  */
 
diff --git a/configure b/configure
index d8e1c50..6d7aa3c 100755
--- a/configure
+++ b/configure
@@ -5958,6 +5958,44 @@ fi
 $as_echo "$libc_linker_feature" >&6; }
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker that supports --no-dynamic-linker" >&5
+$as_echo_n "checking for linker that supports --no-dynamic-linker... " >&6; }
+libc_linker_feature=no
+if test x"$gnu_ld" = x"yes"; then
+  libc_linker_check=`$LD -v --help 2>/dev/null | grep "\--no-dynamic-linker"`
+  if test -n "$libc_linker_check"; then
+    cat > conftest.c <<EOF
+int _start (void) { return 42; }
+EOF
+    if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
+				-Wl,--no-dynamic-linker -nostdlib -nostartfiles
+				-fPIC -shared -o conftest.so conftest.c
+				1>&5'
+  { { 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_linker_feature=yes
+    fi
+    rm -f conftest*
+  fi
+fi
+if test $libc_linker_feature = yes; then
+  libc_cv_no_dynamic_linker=yes
+else
+  libc_cv_no_dynamic_linker=no
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_linker_feature" >&5
+$as_echo "$libc_linker_feature" >&6; }
+if test $libc_cv_no_dynamic_linker = yes; then
+  $as_echo "#define HAVE_NO_DYNAMIC_LINKER 1" >>confdefs.h
+
+fi
+config_vars="$config_vars
+have-no-dynamic-linker = $libc_cv_no_dynamic_linker"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fpie" >&5
 $as_echo_n "checking for -fpie... " >&6; }
 if ${libc_cv_fpie+:} false; then :
diff --git a/configure.ac b/configure.ac
index 77456aa..021c792 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1439,6 +1439,15 @@ LIBC_LINKER_FEATURE([-z execstack], [-Wl,-z,execstack],
 		    [libc_cv_z_execstack=yes], [libc_cv_z_execstack=no])
 AC_SUBST(libc_cv_z_execstack)
 
+LIBC_LINKER_FEATURE([--no-dynamic-linker],
+		    [-Wl,--no-dynamic-linker],
+		    [libc_cv_no_dynamic_linker=yes],
+		    [libc_cv_no_dynamic_linker=no])
+if test $libc_cv_no_dynamic_linker = yes; then
+  AC_DEFINE(HAVE_NO_DYNAMIC_LINKER)
+fi
+LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
+
 AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
 LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
 ])

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


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]