Skip PIE indirect5 and indirect6 tests on i386

On i386, since GOT reference is needed to access global symbols in PIE,
those symbols are made dynamic.  Crash happens when there is a reference
to the same global symbol with a different symbol type in a shared
object.  Since mixing different types of the same symbol doesn't work in
general, this patch skips those tests on i386 as well as compiles non-PIE
indirect5 and indirect6 tests with $NOPIE_LDFLAGS and $NOPIE_CFLAGS.

	PR ld/21402
	* testsuite/ld-elf/indirect.exp: Pass $NOPIE_LDFLAGS and
	$NOPIE_CFLAGS to non-PIE indirect5 and indirect6 tests.  Skip
	PIE indirect5 and indirect6 tests on i386.
This commit is contained in:
H.J. Lu 2017-04-20 12:33:55 -07:00
parent 0fad29560e
commit afe9edbf48
2 changed files with 22 additions and 8 deletions

View File

@ -1,3 +1,10 @@
2017-04-20 H.J. Lu <hongjiu.lu@intel.com>
PR ld/21402
* testsuite/ld-elf/indirect.exp: Pass $NOPIE_LDFLAGS and
$NOPIE_CFLAGS to non-PIE indirect5 and indirect6 tests. Skip
PIE indirect5 and indirect6 tests on i386.
2017-04-20 Maciej W. Rozycki <macro@imgtec.com>
* testsuite/ld-mips-elf/mips-elf.exp: Join `__ehdr_start' tests.

View File

@ -129,6 +129,8 @@ set testname "Indirect symbol 2"
set cmd "$ld -shared -o tmpdir/indirect2.so tmpdir/indirect2.o"
check_link_message "$cmd" [list $string2 $string] "$testname"
global NOPIE_CFLAGS NOPIE_LDFLAGS
set run_tests {
{"Run with libindirect3c.so 1"
"-Wl,--no-as-needed tmpdir/indirect3a.o tmpdir/indirect3b.o tmpdir/libindirect3c.so" ""
@ -155,17 +157,17 @@ set run_tests {
"-Wl,--no-as-needed tmpdir/libindirect4c.so tmpdir/indirect4b.o tmpdir/indirect4a.o" ""
{dummy.c} "indirect4d" "indirect4.out"}
{"Run indirect5 1"
"-Wl,--no-as-needed tmpdir/libindirect5.so" ""
{indirect5a.c} "indirect5a" "indirect5.out"}
"$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libindirect5.so" ""
{indirect5a.c} "indirect5a" "indirect5.out" "$NOPIE_CFLAGS"}
{"Run indirect5 2"
"-Wl,--no-as-needed tmpdir/indirect5a.o tmpdir/libindirect5.so" ""
{dummy.c} "indirect5b" "indirect5.out"}
"$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/indirect5a.o tmpdir/libindirect5.so" ""
{dummy.c} "indirect5b" "indirect5.out" "$NOPIE_CFLAGS"}
{"Run indirect6 1"
"-Wl,--no-as-needed tmpdir/libindirect5.so" ""
{indirect6a.c} "indirect6a" "indirect5.out"}
"$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libindirect5.so" ""
{indirect6a.c} "indirect6a" "indirect5.out" "$NOPIE_CFLAGS"}
{"Run indirect6 2"
"-Wl,--no-as-needed tmpdir/indirect6a.o tmpdir/libindirect5.so" ""
{dummy.c} "indirect6b" "indirect5.out"}
"$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/indirect6a.o tmpdir/libindirect5.so" ""
{dummy.c} "indirect6b" "indirect5.out" "$NOPIE_CFLAGS"}
{"Run with libpr18720c.so 1"
"-Wl,--no-as-needed tmpdir/pr18720a.o tmpdir/pr18720b.o tmpdir/libpr18720c.so" ""
{check-ptr-eq.c} "pr18720a" "pr18720.out"}
@ -220,6 +222,11 @@ foreach t [list indirect5a indirect5b indirect6a indirect6b] {
}
}
# PR ld/21402: i386 doesn't support mixing different symbol types in PIE.
if {[istarget "i?86-*-*"]} {
return
}
send_log "$CC -fPIE -pie $srcdir/$subdir/main.c -o tmpdir/pie"
catch "exec $CC -fPIE -pie $srcdir/$subdir/main.c -o tmpdir/pie" exec_output
send_log "$exec_output"