Add HOSTING_SLIBS and use it for -pie
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 26 Nov 2013 19:17:08 +0000 (11:17 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 26 Nov 2013 19:17:08 +0000 (11:17 -0800)
ld/

PR ld/16259
* Makefile.am (HOSTING_SLIBS): New.
* configure.host (HOSTING_SLIBS): New.  Used for PIE.
* configure.in (HOSTING_SLIBS): New AC_SUBST.
* Makefile.in: Regenerated.
* configure: Likewise.

ld/testsuite/

PR ld/16259
* config/default.exp (get_target_emul): Also set HOSTING_SLIBS.
* lib/ld-lib.exp (default_ld_link): Use HOSTING_SLIBS for -pie.

ld/ChangeLog
ld/Makefile.am
ld/Makefile.in
ld/configure
ld/configure.host
ld/configure.in
ld/testsuite/ChangeLog
ld/testsuite/config/default.exp
ld/testsuite/lib/ld-lib.exp

index 4582adb1a4e7d4ab15e12cd494f83e3f76284beb..310006b65307ffb054581f3e38a02132c1f72823 100644 (file)
@@ -1,3 +1,12 @@
+2013-11-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/16259
+       * Makefile.am (HOSTING_SLIBS): New.
+       * configure.host (HOSTING_SLIBS): New.  Used for PIE.
+       * configure.in (HOSTING_SLIBS): New AC_SUBST.
+       * Makefile.in: Regenerated.
+       * configure: Likewise.
+
 2013-11-22  Cory Fields  <cory@coryfields.com>
 
        * pe-dll.c (fill_edata): Only use a real timestamp if
index b2b2a6ebe3622635f981ee550b84abc07f98c7f7..9b3d00fa7d00f452113f02dbf2e406c2c830e8ff 100644 (file)
@@ -88,6 +88,7 @@ POD2MAN = pod2man --center="GNU Development Tools" \
 HOSTING_CRT0 = @HOSTING_CRT0@
 HOSTING_SCRT0 = @HOSTING_SCRT0@
 HOSTING_LIBS = @HOSTING_LIBS@
+HOSTING_SLIBS = @HOSTING_SLIBS@
 HOSTING_EMU = -m $(EMUL)
 
 # Setup the testing framework, if you have one
index b95a3d103de4d1d5671a84ed476f5312a808b5b2..abb5adda7258509336a441509dce206830979209 100644 (file)
@@ -231,6 +231,7 @@ HDEFINES = @HDEFINES@
 HOSTING_CRT0 = @HOSTING_CRT0@
 HOSTING_LIBS = @HOSTING_LIBS@
 HOSTING_SCRT0 = @HOSTING_SCRT0@
+HOSTING_SLIBS = @HOSTING_SLIBS@
 INCINTL = @INCINTL@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
index 63d17e27be507b5b3d5f2f5231bbf7e717c773fa..8452a13876555fa2c751e2087b9b100b1e9378cc 100755 (executable)
@@ -613,6 +613,7 @@ enable_initfini_array
 ENABLE_PLUGINS_FALSE
 ENABLE_PLUGINS_TRUE
 NATIVE_LIB_DIRS
+HOSTING_SLIBS
 HOSTING_LIBS
 HOSTING_SCRT0
 HOSTING_CRT0
@@ -12192,7 +12193,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12195 "configure"
+#line 12196 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12298,7 +12299,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12301 "configure"
+#line 12302 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16208,6 +16209,7 @@ do_compare="$gcc_cv_prog_cmp_skip"
 
 
 
+
 for ac_header in string.h strings.h stdlib.h unistd.h elf-hints.h limits.h locale.h sys/param.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
index c56f67debebab794c8e953c44fd9d4187a1a7da2..71f695d80aaf412e1b6a25a2415f478f6773ae78 100644 (file)
@@ -57,6 +57,7 @@ case "${host}" in
 *-*-linux*)
   HOSTING_CRT0='-dynamic-linker `${CC} --help --verbose 2>&1 | egrep "ld[^ ]*\.so" | sed -e "s,.*-dynamic-linker[      ][      ]*\(.*/ld[^ ]*\.so..\).*,\1,"` `${CC} --print-file-name=crt1.o` `${CC} --print-file-name=crti.o` `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else ${CC} --print-file-name=crtbegin.o; fi`'
   HOSTING_SCRT0='-dynamic-linker `${CC} --help --verbose 2>&1 | egrep "ld[^ ]*\.so" | sed -e "s,.*-dynamic-linker[     ][      ]*\(.*/ld[^ ]*\.so..\).*,\1,"` `${CC} --print-file-name=Scrt1.o` `${CC} --print-file-name=crti.o` `if [ -f ../gcc/crtbeginS.o ]; then echo ../gcc/crtbeginS.o; else ${CC} --print-file-name=crtbeginS.o; fi`'
+  HOSTING_SLIBS='-L`dirname \`${CC} --print-file-name=libc.so\`` '"$HOSTING_LIBS"' `if [ -f ../gcc/crtendS.o ]; then echo ../gcc/crtendS.o; else ${CC} --print-file-name=crtendS.o; fi` `${CC} --print-file-name=crtn.o`'
   HOSTING_LIBS='-L`dirname \`${CC} --print-file-name=libc.so\`` '"$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} --print-file-name=crtend.o; fi` `${CC} --print-file-name=crtn.o`'
   ;;
 
@@ -249,3 +250,9 @@ esac
 if test -z "$HOSTING_SCRT0"; then
   HOSTING_SCRT0="$HOSTING_CRT0"
 fi
+
+# Provide default HOSTING_SLIBS.  Each host should define a proper one
+# if needed.
+if test -z "$HOSTING_SLIBS"; then
+  HOSTING_SLIBS="$HOSTING_SLIBS"
+fi
index 2af3dfc2fd5f635b4504abd59acdd61954d846ee..619c15161cf73497880b10143502aafbd1397c42 100644 (file)
@@ -187,6 +187,7 @@ AC_SUBST(HDEFINES)
 AC_SUBST(HOSTING_CRT0)
 AC_SUBST(HOSTING_SCRT0)
 AC_SUBST(HOSTING_LIBS)
+AC_SUBST(HOSTING_SLIBS)
 AC_SUBST(NATIVE_LIB_DIRS)
 
 AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h elf-hints.h limits.h locale.h sys/param.h)
index bbd8eb35be0762082de9434fe5985c04c8295ebd..3ccefaf19a204fda75e461d575b3073c48e83934 100644 (file)
@@ -1,3 +1,9 @@
+2013-11-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/16259
+       * config/default.exp (get_target_emul): Also set HOSTING_SLIBS.
+       * lib/ld-lib.exp (default_ld_link): Use HOSTING_SLIBS for -pie.
+
 2013-11-26  Will Newton  <will.newton@linaro.org>
 
        * ld-aarch64/aarch64-elf.exp: Add ifunc-22.
index d540f1992a7716dce8d55d4479a11bdf53798e6b..1d3ce6a03f1462704a17c87f17bdb9524068d7e6 100644 (file)
@@ -139,11 +139,11 @@ proc get_target_emul {} {
 }
 
 if [isnative] {
-    foreach x {HOSTING_CRT0 HOSTING_SCRT0 HOSTING_LIBS} {
+    foreach x {HOSTING_CRT0 HOSTING_SCRT0 HOSTING_LIBS HOSTING_SLIBS} {
        get_link_files $x
     }
 } else {
-    foreach x {HOSTING_CRT0 HOSTING_SCRT0 HOSTING_LIBS} { set $x "" }
+    foreach x {HOSTING_CRT0 HOSTING_SCRT0 HOSTING_LIBS HOSTING_SLIBS} { set $x "" }
 }
 if ![info exists HOSTING_EMU] { set HOSTING_EMU "-m [get_target_emul]" }
 
index 67c429ffec581ecab5826e670520556a0c588227..8df42ae85eda281df270c7d6ce747f6ee5c1569f 100644 (file)
@@ -179,6 +179,7 @@ proc default_ld_link { ld target objects } {
     global HOSTING_CRT0
     global HOSTING_SCRT0
     global HOSTING_LIBS
+    global HOSTING_SLIBS
     global LIBS
     global host_triplet
     global link_output
@@ -186,10 +187,11 @@ proc default_ld_link { ld target objects } {
 
     if { [ string match "* -pie *" $objects ] } {
        set objs "$HOSTING_SCRT0 $objects"
+       set libs "$LIBS $HOSTING_SLIBS"
     } else {
        set objs "$HOSTING_CRT0 $objects"
+       set libs "$LIBS $HOSTING_LIBS"
     }
-    set libs "$LIBS $HOSTING_LIBS"
 
     if [is_endian_output_format $objects] then {
        set flags [big_or_little_endian]