aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ld-elf/sec64k.exp31
-rw-r--r--ld/testsuite/ld-elf/shared.exp14
-rw-r--r--ld/testsuite/ld-scripts/map-address.exp37
-rw-r--r--ld/testsuite/ld-scripts/map-stats.d5
-rw-r--r--ld/testsuite/ld-shared/shared.exp34
-rw-r--r--ld/testsuite/ld-vsb/vsb.exp16
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp4
7 files changed, 96 insertions, 45 deletions
diff --git a/ld/testsuite/ld-elf/sec64k.exp b/ld/testsuite/ld-elf/sec64k.exp
index 8dcb021..deb46d3 100644
--- a/ld/testsuite/ld-elf/sec64k.exp
+++ b/ld/testsuite/ld-elf/sec64k.exp
@@ -168,9 +168,9 @@ if [catch { set ofd [open "tmpdir/$test2.d" w] } x] {
return
}
-# too big for avr, d10v and msp
-# lack of fancy orphan section handling causes overlap on fr30 and iq2000
-# bfin and lm32 complain about relocations in read-only sections
+# Too big for avr, d10v and msp.
+# Lack of fancy orphan section handling causes overlap on fr30 and iq2000.
+# bfin and lm32 complain about relocations in read-only sections.
if { ![istarget "d10v-*-*"]
&& ![istarget "avr-*-*"]
&& ![istarget "msp*-*-*"]
@@ -179,7 +179,13 @@ if { ![istarget "d10v-*-*"]
&& ![istarget "bfin-*-linux*"]
&& ![istarget "lm32-*-linux*"]
&& ![istarget "pru-*-*"] } {
+
+ # Create a 64ksec.d test control file...
+
+ # List the input files.
foreach sfile $sfiles { puts $ofd "#source: $sfile" }
+
+ # Add any needed linker command line options.
if { [istarget spu*-*-*] } {
puts $ofd "#ld: --local-store 0:0"
} elseif { [istarget "i?86-*-linux*"] || [istarget "x86_64-*-linux*"] } {
@@ -187,10 +193,20 @@ if { ![istarget "d10v-*-*"]
} else {
puts $ofd "#ld:"
}
- #force z80 target to compile for eZ80 in ADL mode
+
+ # Enable the accumulation of internal linker statistics in a separate file.
+ # Enabled this way as you cannot have multiple #ld: options in a .d file.
+ # The + character causes the file to opened in append mode, so that multiple
+ # runs of this test will accumulate data over time. Thus allowing regular
+ # testers to see changes in the performance of the linker.
+ puts $ofd "#ld_after_inputfiles: --stats=+tmpdir/$test2.stats"
+
+ # Force z80 target to compile for eZ80 in ADL mode.
if { [istarget "z80-*-*"] } then {
puts $ofd "#as: -ez80-adl"
}
+
+ # Add a test of the linked binary.
puts $ofd "#readelf: -W -wN -Ss"
puts $ofd "There are 660.. section headers.*:"
puts $ofd "#..."
@@ -199,6 +215,7 @@ if { ![istarget "d10v-*-*"]
puts $ofd " \\\[65279\\\] \\.foo\\.\[0-9\]+ .*"
puts $ofd " \\\[65280\\\] \\.foo\\.\[0-9\]+ .*"
puts $ofd "#..."
+
if { [is_elf_unused_section_symbols ] } {
puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+660...*"
puts $ofd "#..."
@@ -209,6 +226,7 @@ if { ![istarget "d10v-*-*"]
puts $ofd " 66...: \[0-9a-f\]+\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+660.. bar_66000$"
}
puts $ofd "#..."
+
# Global symbols are not in "alphanumeric" order, so we just check
# that the first and the last are present in any order (assuming no
# duplicates).
@@ -217,9 +235,14 @@ if { ![istarget "d10v-*-*"]
puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$"
puts $ofd "#pass"
close $ofd
+
+ # Now run the constructed test file.
run_dump_test "tmpdir/$test2"
+
+ # Leave the test file around in case the user wants to examine it.
}
+# Tidy up.
for { set i 1 } { $i < $max_sec / $secs_per_file } { incr i } {
catch "exec rm -f tmpdir/dump$i.o" status
}
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index bf8952a..09669b5 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -1618,12 +1618,12 @@ if { [istarget *-*-linux*]
] \
[list \
"Run pr21964-4" \
- "" \
+ "$NOPIE_LDFLAGS" \
"" \
{pr21964-4.c} \
"pr21964-4" \
"pass.out" \
- "" \
+ "$NOPIE_CFLAGS" \
"" \
"" \
"-ldl" \
@@ -1664,7 +1664,7 @@ proc mix_pic_and_non_pic {xfails cflags ldflags exe} {
run_ld_link_exec_tests [list \
[list \
- "Run $exe fun defined" \
+ "Run $exe fun undefined" \
"-Wl,--no-as-needed,-rpath,tmpdir $ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so" \
"" \
{ pr19719a.c pr19719c.c } \
@@ -1682,19 +1682,19 @@ proc mix_pic_and_non_pic {xfails cflags ldflags exe} {
}
if ![isnative] {
- unsupported "Run $exe fun undefined"
+ unsupported "Run $exe fun defined"
return
}
set exec_output [run_host_cmd "tmpdir/$exe" ""]
if {![string match "PASS\n" $exec_output]} {
- fail "Run $exe fun undefined"
+ fail "Run $exe fun defined"
} else {
- pass "Run $exe fun undefined"
+ pass "Run $exe fun defined"
}
}
-mix_pic_and_non_pic [list "arm*-*-*"] "" "" "pr19719"
+mix_pic_and_non_pic [list "arm*-*-*"] "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS" "pr19719"
mix_pic_and_non_pic [] "-fPIE" "-pie" "pr19719pie"
set AFLAGS_PIE ""
diff --git a/ld/testsuite/ld-scripts/map-address.exp b/ld/testsuite/ld-scripts/map-address.exp
index 2291302..776fed4 100644
--- a/ld/testsuite/ld-scripts/map-address.exp
+++ b/ld/testsuite/ld-scripts/map-address.exp
@@ -130,19 +130,38 @@ if { [is_elf_format] } {
$IMAGE_BASE tmpdir/map-address.o \
-Map=tmpdir/map-locals.map --print-map-locals"]} {
fail $testname
- return
- }
- if [is_remote host] then {
- remote_upload host "tmpdir/map-locals.map"
- }
+ } else {
- # Some ELF targets do not preserve their local symbols.
- setup_xfail "d30v-*-*" "dlx-*-*" "pj-*-*" "s12z-*-*" "xgate-*-*"
+ if [is_remote host] then {
+ remote_upload host "tmpdir/map-locals.map"
+ }
+
+ # Some ELF targets do not preserve their local symbols.
+ setup_xfail "d30v-*-*" "dlx-*-*" "pj-*-*" "s12z-*-*" "xgate-*-*"
+ if {[regexp_diff \
+ "tmpdir/map-locals.map" \
+ "$srcdir/$subdir/map-locals.d"]} {
+ fail $testname
+ } else {
+ pass $testname
+ }
+ }
+}
+
+set testname "map with resource usage"
+
+if {![ld_link $ld tmpdir/map-address \
+ "$LDFLAGS -T $srcdir/$subdir/map-address.t \
+ $IMAGE_BASE tmpdir/map-address.o \
+ -Map=tmpdir/map-locals.map \
+ --stats=tmpdir/map-stats.map"]} {
+ fail $testname
+} else {
if {[regexp_diff \
- "tmpdir/map-locals.map" \
- "$srcdir/$subdir/map-locals.d"]} {
+ "tmpdir/map-stats.map" \
+ "$srcdir/$subdir/map-stats.d"]} {
fail $testname
} else {
pass $testname
diff --git a/ld/testsuite/ld-scripts/map-stats.d b/ld/testsuite/ld-scripts/map-stats.d
new file mode 100644
index 0000000..ba9adf8
--- /dev/null
+++ b/ld/testsuite/ld-scripts/map-stats.d
@@ -0,0 +1,5 @@
+#...
+Stats: phase.*
+Stats: name.*
+Stats: ALL.*
+#pass
diff --git a/ld/testsuite/ld-shared/shared.exp b/ld/testsuite/ld-shared/shared.exp
index bdbe9a9..a8ddac2 100644
--- a/ld/testsuite/ld-shared/shared.exp
+++ b/ld/testsuite/ld-shared/shared.exp
@@ -121,6 +121,7 @@ proc shared_test { progname testname main sh1 sh2 dat args } {
global tmpdir
if [llength $args] { set shldflags [lindex $args 0] } else { set shldflags "" }
+ if { [llength $args] >= 2 } { set ldflags [lindex $args 1] } else { set ldflags "" }
# Build the shared library.
set shared -shared
@@ -146,7 +147,7 @@ proc shared_test { progname testname main sh1 sh2 dat args } {
set rpath /lib:$tmpdir
set exportflag " -Wl,-bexpall"
}
- if ![ld_link $CC_FOR_TARGET $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so $exportflag"] {
+ if ![ld_link $CC_FOR_TARGET $tmpdir/$progname "-Wl,-rpath,$rpath $ldflags $tmpdir/$main $tmpdir/$progname.so $exportflag"] {
fail "$testname"
return
}
@@ -205,7 +206,9 @@ if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then {
verbose "Using $picflag to compile PIC code"
# Compile the main program.
-if ![ld_compile "$CC_FOR_TARGET $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
+global PLT_CFLAGS NOPIE_CFLAGS NOPIE_LDFLAGS
+verbose "Using $NOPIE_CFLAGS to compile and $NOPIE_LDFLAGS to link non PIC code"
+if ![ld_compile "$CC_FOR_TARGET $NOPIE_CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
unsupported "shared (non PIC)"
unsupported "shared"
} else {
@@ -215,12 +218,11 @@ if ![ld_compile "$CC_FOR_TARGET $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.
# 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 NOPIE_CFLAGS
if { ![ld_compile "$CC_FOR_TARGET $PLT_CFLAGS $NOPIE_CFLAGS $SHCFLAG" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o]
- || ![ld_compile "$CC_FOR_TARGET $PLT_CFLAGS $SHCFLAG" $srcdir/$subdir/sh2.c $tmpdir/sh2np.o] } {
+ || ![ld_compile "$CC_FOR_TARGET $PLT_CFLAGS $NOPIE_CFLAGS $SHCFLAG" $srcdir/$subdir/sh2.c $tmpdir/sh2np.o] } {
unsupported "shared (non PIC)"
} else { if { [is_xcoff_format] } {
- shared_test shnp "shared (nonPIC)" mainnp.o sh1np.o sh2np.o xcoff
+ shared_test shnp "shared (non PIC)" mainnp.o sh1np.o sh2np.o xcoff "" $NOPIE_LDFLAGS
} else {
# Solaris defaults to -z text.
setup_xfail "*-*-solaris2*"
@@ -243,7 +245,7 @@ if ![ld_compile "$CC_FOR_TARGET $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.
setup_xfail "arm*-*-linux*"
}
setup_xfail "aarch64*-*-linux*"
- shared_test shnp "shared (non PIC)" mainnp.o sh1np.o sh2np.o shared
+ shared_test shnp "shared (non PIC)" mainnp.o sh1np.o sh2np.o shared "" $NOPIE_LDFLAGS
# Test ELF shared library relocations with a non-zero load
# address for the library. Near as I can tell, the R_*_RELATIVE
@@ -273,7 +275,7 @@ if ![ld_compile "$CC_FOR_TARGET $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.
setup_xfail "*-*-solaris2*"
shared_test shnp "shared (non PIC, load offset)" \
mainnp.o sh1np.o sh2np.o shared \
- "-Wl,-T,$srcdir/$subdir/elf-offset.ld,--hash-style=sysv"
+ "-Wl,-T,$srcdir/$subdir/elf-offset.ld,--hash-style=sysv" $NOPIE_LDFLAGS
} }
# Now compile the code using -fpic.
@@ -283,13 +285,13 @@ if ![ld_compile "$CC_FOR_TARGET $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.
unsupported "shared"
} else {
if { [is_xcoff_format] } {
- shared_test shp "shared" mainnp.o sh1p.o sh2p.o xcoff
+ shared_test shp "shared" mainnp.o sh1p.o sh2p.o xcoff "" $NOPIE_LDFLAGS
} else {
- shared_test shp "shared" mainnp.o sh1p.o sh2p.o shared
- ld_compile "$CC_FOR_TARGET -DSYMBOLIC_TEST $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o
+ shared_test shp "shared" mainnp.o sh1p.o sh2p.o shared "" $NOPIE_LDFLAGS
+ ld_compile "$CC_FOR_TARGET $NOPIE_CFLAGS -DSYMBOLIC_TEST $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o
ld_compile "$CC_FOR_TARGET -DSYMBOLIC_TEST $SHCFLAG $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o
- shared_test shp "shared -Bsymbolic" mainnp.o sh1p.o sh2p.o symbolic "-Bsymbolic"
- ld_compile "$CC_FOR_TARGET $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o
+ shared_test shp "shared -Bsymbolic" mainnp.o sh1p.o sh2p.o symbolic "-Bsymbolic" $NOPIE_LDFLAGS
+ ld_compile "$CC_FOR_TARGET $NOPIE_CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o
ld_compile "$CC_FOR_TARGET $SHCFLAG $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o
}
}
@@ -302,7 +304,7 @@ if ![ld_compile "$CC_FOR_TARGET $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdi
} else {
if { [file exists $tmpdir/sh1np.o ] && [ file exists $tmpdir/sh2np.o ] } {
if { [is_xcoff_format] } {
- shared_test shmpnp "shared (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o xcoff
+ shared_test shmpnp "shared (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o xcoff "" $NOPIE_LDFLAGS
} else {
# Solaris defaults to -z text.
setup_xfail "*-*-solaris2*"
@@ -325,7 +327,7 @@ if ![ld_compile "$CC_FOR_TARGET $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdi
setup_xfail "arm*-*-linux*"
}
setup_xfail "aarch64*-*-linux*"
- shared_test shmpnp "shared (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o shared
+ shared_test shmpnp "shared (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o shared "" $NOPIE_LDFLAGS
}
} else {
unsupported "shared (PIC main, non PIC so)"
@@ -333,9 +335,9 @@ if ![ld_compile "$CC_FOR_TARGET $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdi
if { [file exists $tmpdir/sh1p.o ] && [ file exists $tmpdir/sh2p.o ] } {
if { [is_xcoff_format] } {
- shared_test shmpp "shared (PIC main)" mainp.o sh1p.o sh2p.o xcoff
+ shared_test shmpp "shared (PIC main)" mainp.o sh1p.o sh2p.o xcoff "" $NOPIE_LDFLAGS
} else {
- shared_test shmpp "shared (PIC main)" mainp.o sh1p.o sh2p.o shared
+ shared_test shmpp "shared (PIC main)" mainp.o sh1p.o sh2p.o shared "" $NOPIE_LDFLAGS
}
} else {
unsupported "shared (PIC main)"
diff --git a/ld/testsuite/ld-vsb/vsb.exp b/ld/testsuite/ld-vsb/vsb.exp
index 9a61e9d..e44ac39 100644
--- a/ld/testsuite/ld-vsb/vsb.exp
+++ b/ld/testsuite/ld-vsb/vsb.exp
@@ -134,6 +134,7 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
global tmpdir
if [llength $args] { set shldflags [lindex $args 0] } else { set shldflags "" }
+ if { [llength $args] >= 2 } { set ldflags [lindex $args 1] } else { set ldflags "" }
# Build the shared library.
set shared -shared
@@ -169,7 +170,7 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
set rpath /lib:$tmpdir
set exportflag " -Wl,-bexpall"
}
- if ![ld_link $CC_FOR_TARGET $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so $exportflag"] {
+ if ![ld_link $CC_FOR_TARGET $tmpdir/$progname "-Wl,-rpath,$rpath $ldflags $tmpdir/$main $tmpdir/$progname.so $exportflag"] {
if { [ string match $visibility "hidden" ]
&& [regexp "undefined reference to \`\.?visibility\'" $link_output]
&& [regexp "undefined reference to \`visibility_var\'" $link_output] } {
@@ -235,6 +236,7 @@ proc visibility_run {visibility} {
global shared_needs_pic
global PLT_CFLAGS
global NOPIE_CFLAGS
+ global NOPIE_LDFLAGS
global COMPRESS_LDFLAG
global NOSANITIZE_CFLAGS
global NOLTO_CFLAGS
@@ -284,7 +286,7 @@ proc visibility_run {visibility} {
} else {
# Compile the main program. Make sure that PLT is used since PLT
# is expected.
- if ![ld_compile "$CC_FOR_TARGET -g $PLT_CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
+ if ![ld_compile "$CC_FOR_TARGET -g $NOPIE_CFLAGS $PLT_CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
unsupported "visibility ($visibility) (non PIC)"
unsupported "visibility ($visibility)"
} else {
@@ -343,7 +345,7 @@ proc visibility_run {visibility} {
setup_xfail "*-*-beos*"
}
- visibility_test $visibility vnp "visibility ($visibility) (non PIC)" mainnp.o sh1np.o sh2np.o $datfile
+ visibility_test $visibility vnp "visibility ($visibility) (non PIC)" mainnp.o sh1np.o sh2np.o $datfile "" $NOPIE_LDFLAGS
# Test ELF shared library relocations with a non-zero load
# address for the library. Near as I can tell, the R_*_RELATIVE
@@ -395,7 +397,7 @@ proc visibility_run {visibility} {
if { ![is_xcoff_format] } {
visibility_test $visibility vnp "visibility ($visibility) (non PIC, load offset)" \
mainnp.o sh1np.o sh2np.o $datfile \
- "-Wl,-T,$srcdir/$subdir/elf-offset.ld,--hash-style=sysv"
+ "-Wl,-T,$srcdir/$subdir/elf-offset.ld,--hash-style=sysv" $NOPIE_LDFLAGS
}
}
@@ -411,7 +413,7 @@ proc visibility_run {visibility} {
setup_xfail $target_triplet
}
}
- visibility_test $visibility vp "visibility ($visibility)" mainnp.o sh1p.o sh2p.o $datfile $COMPRESS_LDFLAG
+ visibility_test $visibility vp "visibility ($visibility)" mainnp.o sh1p.o sh2p.o $datfile $COMPRESS_LDFLAG $NOPIE_LDFLAGS
}
}}
@@ -466,7 +468,7 @@ proc visibility_run {visibility} {
setup_xfail "*-*-beos*"
}
- visibility_test $visibility vmpnp "visibility ($visibility) (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o $datfile
+ visibility_test $visibility vmpnp "visibility ($visibility) (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o $datfile "" $NOPIE_LDFLAGS
} else {
unsupported "visibility (PIC main, non PIC so)"
}
@@ -488,7 +490,7 @@ proc visibility_run {visibility} {
setup_xfail "*-*-beos*"
}
- visibility_test $visibility vmpp "visibility ($visibility) (PIC main)" mainp.o sh1p.o sh2p.o $datfile
+ visibility_test $visibility vmpp "visibility ($visibility) (PIC main)" mainp.o sh1p.o sh2p.o $datfile "" $NOPIE_LDFLAGS
} else {
unsupported "visibility ($visibility) (PIC main)"
}
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 01d6459..52c4d5e 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -2168,9 +2168,9 @@ if { [isnative] && [check_compiler_available] } {
}
undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
- undefined_weak "-fPIE" ""
+ undefined_weak "-fPIE" "$NOPIE_LDFLAGS"
undefined_weak "-fPIE" "-pie"
- undefined_weak "-fPIE" "-Wl,-z,nodynamic-undefined-weak"
+ undefined_weak "-fPIE" "$NOPIE_LDFLAGS -Wl,-z,nodynamic-undefined-weak"
undefined_weak "-fPIE" "-pie -Wl,-z,nodynamic-undefined-weak"
}