# Expect script for ld-x86_64 tests
-# Copyright (C) 2002-2019 Free Software Foundation, Inc.
+# Copyright (C) 2002-2020 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
set emul "elf_x86_64"
}
-global ASFLAGS
set saved_ASFLAGS "$ASFLAGS"
set ASFLAGS "$ASFLAGS -mx86-used-note=no"
"--64" { pr19827a.S }}
{"Build pr19827b.so" "-melf_x86_64 -shared" ""
"--64" { pr19827b.S } {} "pr19827b.so"}
- {"Build pr19827" "-melf_x86_64 -pie tmpdir/pr19827a.o tmpdir/pr19827b.so" ""
+ {"Build pr19827"
+ "-melf_x86_64 -pie -z notext tmpdir/pr19827a.o tmpdir/pr19827b.so"
+ ""
"--64" { dummy.s } {{readelf {-rW} pr19827.rd}} "pr19827"}
- {"Build pr19827.so" "-melf_x86_64 -shared -Bsymbolic" ""
+ {"Build pr19827.so"
+ "-melf_x86_64 -shared -Bsymbolic -z notext" ""
"--64" { pr19827a.S } {{readelf {-rW} pr19827.rd}} "pr19827.so"}
{"Build pr19969.so" "-melf_x86_64 -shared" ""
"--64" { pr19969a.S } {} "pr19969.so"}
"--64" { pr20550a.s }}
{"Build pr20550b.so" "-melf_x86_64 -shared" ""
"--64" { pr20550b.s } {} "pr20550b.so"}
- {"Build pr20550" "-melf_x86_64 -pie tmpdir/pr20550a.o tmpdir/pr20550b.so" ""
+ {"Build pr20550"
+ "-melf_x86_64 -pie -z notext tmpdir/pr20550a.o tmpdir/pr20550b.so"
+ ""
"--64" { dummy.s } {} "pr20550"}
}
run_ld_link_tests $x86_64tests
-global link_output
-global ld
-
set test_name "Mixed x86_64 and i386 input test 1"
set test mixed1
if { ![ld_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
run_dump_test "pr24322a-x32"
run_dump_test "pr24322b"
run_dump_test "pr24322b-x32"
+run_dump_test "pr24458a"
+run_dump_test "pr24458a-x32"
+run_dump_test "pr24458b"
+run_dump_test "pr24458b-x32"
+run_dump_test "pr24458c"
+run_dump_test "pr24458c-x32"
+run_dump_test "pr24721"
+run_dump_test "pr24721-x32"
+run_dump_test "pr24905"
+run_dump_test "pr24905-x32"
+run_dump_test "align-branch-1"
+run_dump_test "pr25416-1a"
+run_dump_test "pr25416-2b"
+run_dump_test "pr25416-2a"
+run_dump_test "pr25416-2b"
+run_dump_test "pr25416-3"
+run_dump_test "pr25416-4"
+run_dump_test "pr26018"
if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
return
}
if ![ld_assemble $as "--x32 $srcdir/$subdir/start.s" tmpdir/startx32.o] {
- unresolved "Build ILP32 start.o"
+ fail "Build ILP32 start.o"
return
}
if ![ld_assemble $as "--32 $srcdir/$subdir/start.s" tmpdir/start32.o] {
- unresolved "Build ia32 start.o"
+ fail "Build ia32 start.o"
return
}
if ![ld_assemble $as "--64 $srcdir/$subdir/start.s" tmpdir/start64.o] {
- unresolved "Build LP64 start.o"
+ fail "Build LP64 start.o"
return
}
if ![ld_assemble $as "--x32 $srcdir/$subdir/foo.s" tmpdir/foox32.o] {
- unresolved "Build ILP32 foo.o"
+ fail "Build ILP32 foo.o"
return
}
if ![ld_assemble $as "--32 $srcdir/$subdir/foo.s" tmpdir/foo32.o] {
- unresolved "Build ia32 foo.o"
+ fail "Build ia32 foo.o"
return
}
if ![ld_assemble $as "--64 $srcdir/$subdir/foo.s" tmpdir/foo64.o] {
- unresolved "Build LP64 foo.o"
+ fail "Build LP64 foo.o"
return
}
run_dump_test "pr17935-2"
run_dump_test "pr18160"
run_dump_test "pr18176"
-run_dump_test "pr18801"
+run_dump_test "pr18801a"
+run_dump_test "pr18801b"
+run_dump_test "ifunc-textrel-1a"
+run_dump_test "ifunc-textrel-1b"
+run_dump_test "ifunc-textrel-2a"
+run_dump_test "ifunc-textrel-2b"
run_dump_test "pr18815"
run_dump_test "pr19013"
run_dump_test "pr19013-x32"
}
}
-# Add $PLT_CFLAGS if PLT is expected.
-global PLT_CFLAGS
-# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
-global NOPIE_CFLAGS NOPIE_LDFLAGS
-
# Must be native with the C compiler
-if { [isnative] && [which $CC] != 0 } {
- run_cc_link_tests {
- {"Helper X32 DSO from x86-64 object" "" "-m64 -fPIC -g"
- {simple.c} {} "libsimple.a"}
- }
+if { [isnative] && [check_compiler_available] } {
+ run_cc_link_tests [list \
+ [list \
+ "Helper X32 DSO from x86-64 object" "" \
+ "-m64 $NOSANTIZE_CFLAGS -fPIC -g" \
+ {simple.c} {} "libsimple.a" \
+ ] \
+ ]
set convertx32 "$objcopy -O elf32-x86-64 tmpdir/simple.o tmpdir/simple-x32.o"
send_log "$convertx32\n"
return
}
- run_ld_link_tests {
- {"X32 DSO from x86-64 object"
- "-shared -melf32_x86_64 tmpdir/simple-x32.o" ""
- "--x32 -mx86-used-note=yes"
- {dummy.s} {{readelf {-s --wide} x86-64-x32.rd}} "x86-64-x32"}
- }
+ run_ld_link_tests [list \
+ [list \
+ "X32 DSO from x86-64 object" \
+ "-shared -melf32_x86_64 tmpdir/simple-x32.o" \
+ "$NOSANTIZE_CFLAGS" \
+ "--x32 -mx86-used-note=yes" \
+ {dummy.s} {{readelf {-s --wide} x86-64-x32.rd}} \
+ "x86-64-x32" \
+ ] \
+ ]
run_cc_link_tests [list \
[list \
] \
[list \
"Build pr22001-1a" \
- "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+ "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed,-z,notext tmpdir/pr22001-1.so" \
"$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
{ pr22001-1b.c } \
{{error_output "pr22001-1a.err"}} \
] \
[list \
"Build pr21997-1a" \
- "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/pr21997-1.so" \
"$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
{ pr21997-1b.c } \
{{error_output "pr21997-1a.err"}} \
] \
[list \
"Build pr22791-1" \
- "-pie -Wl,--no-as-needed tmpdir/pr22791-1.so" \
+ "-pie -Wl,--no-as-needed,-z,notext tmpdir/pr22791-1.so" \
"$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
{ pr22791-1b.s } \
{{error_output "pr22791-1.err"}} \
]
if {[istarget "x86_64-*-linux*-gnux32"]} {
+ run_cc_link_tests [list \
+ [list \
+ "Build pr25416-5b.o (GDesc -maddress-mode=short)" \
+ "" \
+ "-Wa,-mx86-used-note=yes" \
+ { pr25416-5b.s } \
+ ] \
+ [list \
+ "Build pr25416-5b.so (GDesc -> IE -maddress-mode=short)" \
+ "-shared" \
+ "-fPIC -Wa,-mx86-used-note=yes" \
+ { pr25416-5b.s pr25416-5d.s } \
+ {} \
+ "pr25416-5b.so" \
+ ] \
+ [list \
+ "Build pr25416-5c.o (GDesc -maddress-mode=long)" \
+ "" \
+ "-Wa,-mx86-used-note=yes" \
+ { pr25416-5c.s } \
+ ] \
+ [list \
+ "Build pr25416-5c.so (GDesc -> IE -maddress-mode=long)" \
+ "-shared" \
+ "-fPIC -Wa,-mx86-used-note=yes" \
+ { pr25416-5c.s pr25416-5d.s } \
+ {} \
+ "pr25416-5c.so" \
+ ] \
+ [list \
+ "Build pr25416-5d.so (GDesc -maddress-mode=short)" \
+ "-shared" \
+ "-fPIC -Wa,-mx86-used-note=yes" \
+ { pr25416-5b.s pr25416-5e.s } \
+ {} \
+ "pr25416-5d.so" \
+ ] \
+ [list \
+ "Build pr25416-5d.o (IE -maddress-mode=short)" \
+ "" \
+ "-Wa,-mx86-used-note=yes" \
+ { pr25416-5d.s } \
+ ] \
+ ]
+
run_ld_link_exec_tests [list \
[list \
"Run pr22001-1b" \
- "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+ "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed,-z,notext tmpdir/pr22001-1.so" \
"-Wa,-mx86-used-note=yes" \
{ pr22001-1c.c } \
"pr22001-1b" \
] \
[list \
"Run pr21997-1b" \
- "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/pr21997-1.so" \
"-Wa,-mx86-used-note=yes" \
{ pr21997-1c.c } \
"pr21997-1b" \
"pass.out" \
"$NOPIE_CFLAGS" \
] \
+ [list \
+ "Run pr25416-5a (GDesc -> IE -maddress-mode=short)" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr25416-5b.so" \
+ "-Wa,-mx86-used-note=yes" \
+ { pr25416-5a.c } \
+ "pr25416-5a" \
+ "pass.out" \
+ "$NOPIE_CFLAGS" \
+ ] \
+ [list \
+ "Run pr25416-5b (GDesc -> LE -maddress-mode=short" \
+ "$NOPIE_LDFLAGS tmpdir/pr25416-5b.o tmpdir/pr25416-5d.o" \
+ "-Wa,-mx86-used-note=yes" \
+ { pr25416-5a.c } \
+ "pr25416-5b" \
+ "pass.out" \
+ "$NOPIE_CFLAGS" \
+ ] \
+ [list \
+ "Run pr25416-5c (GDesc -> IE -maddress-mode=long)" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr25416-5c.so" \
+ "-Wa,-mx86-used-note=yes" \
+ { pr25416-5a.c } \
+ "pr25416-5c" \
+ "pass.out" \
+ "$NOPIE_CFLAGS" \
+ ] \
+ [list \
+ "Run pr25416-5d (GDesc -> LE -maddress-mode=long)" \
+ "$NOPIE_LDFLAGS tmpdir/pr25416-5c.o tmpdir/pr25416-5d.o" \
+ "-Wa,-mx86-used-note=yes" \
+ { pr25416-5a.c } \
+ "pr25416-5d" \
+ "pass.out" \
+ "$NOPIE_CFLAGS" \
+ ] \
+ [list \
+ "Run pr25416-5e (GDesc -maddress-mode=short)" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr25416-5d.so" \
+ "-Wa,-mx86-used-note=yes" \
+ { pr25416-5a.c } \
+ "pr25416-5e" \
+ "pass.out" \
+ "$NOPIE_CFLAGS" \
+ ] \
+ [list \
+ "Run pr25416-5f (PIE GDesc -> LE -maddress-mode=short)" \
+ "-pie -Wl,-z,notext tmpdir/pr25416-5b.o tmpdir/pr25416-5d.o" \
+ "-Wa,-mx86-used-note=yes" \
+ { pr25416-5a.c } \
+ "pr25416-5f" \
+ "pass.out" \
+ ] \
+ [list \
+ "Run pr25416-5g (PIE GDesc -> LE -maddress-mode=long)" \
+ "-pie -Wl,-z,notext tmpdir/pr25416-5c.o tmpdir/pr25416-5d.o" \
+ "-Wa,-mx86-used-note=yes" \
+ { pr25416-5a.c } \
+ "pr25416-5g" \
+ "pass.out" \
+ ] \
]
} else {
run_cc_link_tests [list \
[list \
"Build pr22001-1b" \
- "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
+ "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed,-z,notext tmpdir/pr22001-1.so" \
"$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
{ pr22001-1c.c } \
{{error_output "pr22001-1b.err"}} \
] \
[list \
"Build pr21997-1b" \
- "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
+ "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/pr21997-1.so" \
"$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
{ pr21997-1c.c } \
{{error_output "pr21997-1b.err"}} \
"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt \
-z noseparate-code -z max-page-size=0x200000" \
- "-Wa,-mx86-used-note=yes" \
+ "-Wa,-mx86-used-note=yes $NOCF_PROTECTION_CFLAGS" \
{ plt-main5.c } \
{{objdump {-drw} plt-main-bnd.dd}} \
"plt-main-bnd" \
"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt -pie \
-z noseparate-code -z max-page-size=0x200000" \
- "-fPIC -Wa,-mx86-used-note=yes" \
+ "-fPIC -Wa,-mx86-used-note=yes $NOCF_PROTECTION_CFLAGS" \
{ plt-main5.c } \
{{objdump {-drw} plt-main-bnd.dd}} \
"plt-main-pie-bnd" \
"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt -z now \
-z noseparate-code -z max-page-size=0x200000" \
- "-Wa,-mx86-used-note=yes" \
+ "-Wa,-mx86-used-note=yes $NOCF_PROTECTION_CFLAGS" \
{ plt-main5.c } \
{{readelf {-SW} plt-main-bnd-now.rd} {objdump {-drw} plt-main-bnd.dd}} \
"plt-main-bnd-now" \
"tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
tmpdir/plt-main4.o tmpdir/libplt-lib.so -z bndplt -z now -pie \
-z noseparate-code -z max-page-size=0x200000" \
- "-fPIC -Wa,-mx86-used-note=yes" \
+ "-fPIC -Wa,-mx86-used-note=yes $NOCF_PROTECTION_CFLAGS" \
{ plt-main5.c } \
{{readelf {-SW} plt-main-bnd-now.rd} {objdump {-drw} plt-main-bnd.dd}} \
"plt-main-pie-bnd-now" \
]
# Linux only tests
-global LD_CLASS
if { "$LD_CLASS" == "64bit" } then {
# This test needs 64-bit linker.
run_dump_test "pr17618"