Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to more ELF tests
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 22 Jun 2017 16:53:33 +0000 (09:53 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 22 Jun 2017 16:53:33 +0000 (09:53 -0700)
PR ld/21090
* testsuite/ld-gc/gc.ex: Compile tmpdir/pr14265.o with
$NOPIE_CFLAGS.
* testsuite/ld-i386/i386.exp: Pass $NOPIE_CFLAGS and
$NOPIE_LDFLAGS if non-PIE is required.
* testsuite/ld-i386/no-plt.exp (NOPIE_CFLAGS): New.
(NOPIE_LDFLAGS): Likewise.
Pass $NOPIE_LDFLAGS if non-PIE is required.
* testsuite/ld-shared/shared.exp: Compile tmpdir/sh1np.o with
$NOPIE_CFLAGS.

ld/ChangeLog
ld/testsuite/ld-gc/gc.exp
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/no-plt.exp
ld/testsuite/ld-shared/shared.exp

index bdc5853a7aa3fdd1acb7247d64a9570c549dccb7..b2603aeae11d0895279dd05d0e4c3bcee64d7322 100644 (file)
@@ -1,3 +1,16 @@
+2017-06-22  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/21090
+       * testsuite/ld-gc/gc.ex: Compile tmpdir/pr14265.o with
+       $NOPIE_CFLAGS.
+       * testsuite/ld-i386/i386.exp: Pass $NOPIE_CFLAGS and
+       $NOPIE_LDFLAGS if non-PIE is required.
+       * testsuite/ld-i386/no-plt.exp (NOPIE_CFLAGS): New.
+       (NOPIE_LDFLAGS): Likewise.
+       Pass $NOPIE_LDFLAGS if non-PIE is required.
+       * testsuite/ld-shared/shared.exp: Compile tmpdir/sh1np.o with
+       $NOPIE_CFLAGS.
+
 2017-06-22  H.J. Lu  <hongjiu.lu@intel.com>
 
        * NEWS: Mention -z shstk and GNU_PROPERTY_X86_FEATURE_1_SHSTK.
index 364c73bf5d4941120416427f2f060113adfdeea8..083b77c231b7d449f67f6b5dafc6d6e213bb4a95 100644 (file)
@@ -26,6 +26,9 @@ if ![check_gc_sections_available] {
 set cflags "-ffunction-sections -fdata-sections"
 set objfile "tmpdir/gc.o"
 
+# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
+global NOPIE_CFLAGS NOPIE_LDFLAGS
+
 if [istarget powerpc64*-*-*] {
     # otherwise with -mcmodel=medium gcc we get XPASSes.
     set cflags "$cflags -mminimal-toc"
@@ -144,7 +147,7 @@ if { [is_remote host] || [which $CC] != 0 } {
 }
 
 if { [is_remote host] || [which $CC] != 0 } {
-    ld_compile "$CC $CFLAGS $cflags" $srcdir/$subdir/pr14265.c tmpdir/pr14265.o
+    ld_compile "$CC $CFLAGS $cflags $NOPIE_CFLAGS" $srcdir/$subdir/pr14265.c tmpdir/pr14265.o
     run_dump_test "pr14265"
 }
 
index 1cecea4e38e6732196d96e108cc89126b9032c64..4bf6706c48dc958b12610ae6892d343360861f1a 100644 (file)
@@ -732,7 +732,7 @@ if { [isnative]
        ] \
        [list \
            "Build gotpc1" \
-           "-Wl,--as-needed tmpdir/gotpc1.o tmpdir/got1d.so" \
+           "$NOPIE_LDFLAGS -Wl,--as-needed tmpdir/gotpc1.o tmpdir/got1d.so" \
            "" \
            { dummy.s } \
            {{objdump {-dw} got1.dd}} \
@@ -994,7 +994,7 @@ if { [isnative]
        ] \
        [list \
            "Run got1" \
-           "tmpdir/got1d.so" \
+           "$NOPIE_LDFLAGS tmpdir/got1d.so" \
            "" \
            { got1a.S got1b.c got1c.c } \
            "got1" \
@@ -1107,14 +1107,14 @@ if { [isnative]
        ] \
     ]
 
-    undefined_weak "" ""
-    undefined_weak "-fPIE" ""
+    undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
+    undefined_weak "-fPIE" "$NOPIE_LDFLAGS"
     undefined_weak "-fPIE" "-pie"
-    undefined_weak "-fPIE" "-z nodynamic-undefined-weak"
+    undefined_weak "-fPIE" "-z nodynamic-undefined-weak $NOPIE_LDFLAGS"
     undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak"
 }
 
-global NOPIE_LDFLAGS
+global NOPIE_CFLAGS NOPIE_LDFLAGS
 
 # Must be native with the C compiler and working IFUNC support,
 if { [isnative]
index a37b9c400c525309510d8aa55ea94d108cc73c23..7839390c9c5ca9af0b8f80eb57e3233d303833c5 100644 (file)
@@ -39,6 +39,9 @@ if { [which $CC] == 0 } {
     return
 }
 
+# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
+global NOPIE_CFLAGS NOPIE_LDFLAGS
+
 run_cc_link_tests [list \
     [list \
        "Build no-plt-func1.o no-plt-main1.o" \
@@ -73,7 +76,7 @@ run_cc_link_tests [list \
     ] \
     [list \
        "No PLT (dynamic 1a)" \
-       "tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
+       "$NOPIE_LDFLAGS tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
         tmpdir/no-plt-func1.o tmpdir/no-plt-extern1a.o" \
        "" \
        {dummy.s} \
@@ -91,7 +94,7 @@ run_cc_link_tests [list \
     ] \
     [list \
        "No PLT (dynamic 1c)" \
-       "tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
+       "$NOPIE_LDFLAGS tmpdir/no-plt-check1a.o tmpdir/no-plt-main1.o \
         tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \
        "" \
        {dummy.s} \
@@ -136,7 +139,7 @@ run_cc_link_tests [list \
     ] \
     [list \
        "No PLT (dynamic 1h)" \
-       "tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
+       "$NOPIE_LDFLAGS tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
         tmpdir/no-plt-func1.o tmpdir/no-plt-extern1b.o" \
        "" \
        {dummy.s} \
@@ -145,7 +148,7 @@ run_cc_link_tests [list \
     ] \
     [list \
        "No PLT (dynamic 1i)" \
-       "tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
+       "$NOPIE_LDFLAGS tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
         tmpdir/no-plt-extern1b.o tmpdir/libno-plt-1a.so" \
        "" \
        {dummy.s} \
@@ -229,7 +232,7 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
        "No PLT (dynamic 1h)" \
-       "tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
+       "$NOPIE_LDFLAGS tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
         tmpdir/no-plt-func1.o tmpdir/no-plt-extern1b.o" \
        "" \
        {dummy.s} \
@@ -238,7 +241,7 @@ run_ld_link_exec_tests [list \
     ] \
     [list \
        "No PLT (dynamic 1i)" \
-       "tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
+       "$NOPIE_LDFLAGS tmpdir/no-plt-check1b.o tmpdir/no-plt-main1.o \
         tmpdir/no-plt-extern1b.o tmpdir/libno-plt-1a.so" \
        "" \
        {dummy.s} \
@@ -291,7 +294,7 @@ if { [check_ifunc_available] } {
     run_ld_link_exec_tests [list \
        [list \
            "Run pr20244-3a" \
-           "tmpdir/pr20244-3a.o tmpdir/pr20244-3b.o \
+           "$NOPIE_LDFLAGS tmpdir/pr20244-3a.o tmpdir/pr20244-3b.o \
             tmpdir/pr20244-3c.o tmpdir/pr20244-3d.o" \
            "" \
            { dummy.c } \
@@ -352,7 +355,7 @@ if { [check_ifunc_available] } {
        ] \
        [list \
            "Run pr20253-1f" \
-           "tmpdir/pr20253-1a.o" \
+           "$NOPIE_LDFLAGS tmpdir/pr20253-1a.o" \
            "" \
            { pr20253-1b.S pr20253-1c.S pr20253-1d.S } \
            "pr20253-1f" \
@@ -370,7 +373,7 @@ if { [check_ifunc_available] } {
        ] \
        [list \
            "Run pr20253-2a" \
-           "tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \
+           "$NOPIE_LDFLAGS tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \
             tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \
            "" \
            { dummy.s } \
@@ -388,7 +391,7 @@ if { [check_ifunc_available] } {
        ] \
        [list \
            "Run pr20253-2c" \
-           "tmpdir/pr20253-2a.o" \
+           "$NOPIE_LDFLAGS tmpdir/pr20253-2a.o" \
            "" \
            { pr20253-2b.S pr20253-2c.S pr20253-2d.S } \
            "pr20253-2c" \
index 93181dc06747867a135354d6f2c43a39ac5e5bc1..723b51cddf4cd085bfe1ecd86fdb22bb609faeff 100644 (file)
@@ -225,8 +225,8 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o]
     # will need to do more relocation work.  However, note that not
     # using -fpic will cause some of the tests to return different
     # results.  Make sure that PLT is used since PLT is expected.
-    global PLT_CFLAGS
-    if { ![ld_compile "$CC $PLT_CFLAGS $CFLAGS $SHCFLAG" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o]
+    global PLT_CFLAGS NOPIE_CFLAGS
+    if { ![ld_compile "$CC $PLT_CFLAGS $NOPIE_CFLAGS $CFLAGS $SHCFLAG" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o]
         || ![ld_compile "$CC $PLT_CFLAGS $CFLAGS $SHCFLAG" $srcdir/$subdir/sh2.c $tmpdir/sh2np.o] } {
        unresolved "shared (non PIC)"
     } else { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {