diff options
Diffstat (limited to 'ld/testsuite')
-rw-r--r-- | ld/testsuite/ld-elf/sec64k.exp | 31 | ||||
-rw-r--r-- | ld/testsuite/ld-pe/secidx.d | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/lto-20.ver | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/lto-20a.c | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/lto-20b.c | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/lto.exp | 42 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/pr32846a.c | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/pr32846b.c | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/pr32846c.c | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/pr32846d.c | 12 | ||||
-rw-r--r-- | ld/testsuite/ld-plugin/pr32846e.c | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-scripts/map-address.exp | 37 | ||||
-rw-r--r-- | ld/testsuite/ld-scripts/map-stats.d | 5 |
13 files changed, 152 insertions, 17 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-pe/secidx.d b/ld/testsuite/ld-pe/secidx.d index 184cc9f..d0e52c9 100644 --- a/ld/testsuite/ld-pe/secidx.d +++ b/ld/testsuite/ld-pe/secidx.d @@ -1,11 +1,11 @@ tmpdir/secidx\.x: +file format pei-.* -Contents of section .text: +Contents of section \.text: .*1000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<< .*1010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>>< .*1020 3c3c3c3c 3e3e3e3e 3e909090 <<<<>>>>>... -Contents of section .data: +Contents of section \.data: .*2000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<< .*2010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>>< .*2020 3e3e3e3e 01001101 00110100 11010011 >>>>............ @@ -15,13 +15,13 @@ Contents of section .data: .*2060 3c3c3c3c 3c3c3c3c 3e3e3e3e 01001102 <<<<<<<<>>>>.... .*2070 00110300 113c3c3c 3c3c3c3c 3c000000 .....<<<<<<<<... .*2080 3c3c3c3e 3e3e3e3e 3e000000 <<<>>>>>>... -Contents of section .rdata: +Contents of section \.rdata: .*3000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<< .*3010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>>< .*3020 3e3e3e3e 00000000 00000000 00000000 >>>>............ .*3030 3c3c3c3e 3e3e3e3e 3e000000 ffffffff <<<>>>>>>....... .*3040 00000000 ffffffff 00000000 ............ -Contents of section .idata: +Contents of section \.idata: .*4000 00000000 00000000 00000000 00000000 ................ .*4010 00000000 .... #... diff --git a/ld/testsuite/ld-plugin/lto-20.ver b/ld/testsuite/ld-plugin/lto-20.ver new file mode 100644 index 0000000..ac906ac --- /dev/null +++ b/ld/testsuite/ld-plugin/lto-20.ver @@ -0,0 +1 @@ +FOO { global: foo; }; diff --git a/ld/testsuite/ld-plugin/lto-20a.c b/ld/testsuite/ld-plugin/lto-20a.c new file mode 100644 index 0000000..3d6dac9 --- /dev/null +++ b/ld/testsuite/ld-plugin/lto-20a.c @@ -0,0 +1,2 @@ +extern int foo (); +int main () { return foo (); } diff --git a/ld/testsuite/ld-plugin/lto-20b.c b/ld/testsuite/ld-plugin/lto-20b.c new file mode 100644 index 0000000..ba123cb --- /dev/null +++ b/ld/testsuite/ld-plugin/lto-20b.c @@ -0,0 +1,11 @@ +extern int printf (const char *, ...); +int foo () +{ +#ifdef SHARED + printf ("PASS\n"); + return 0; +#else + printf ("FAIL\n"); + return 1; +#endif +} diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp index 556bbe9..3a56fb5 100644 --- a/ld/testsuite/ld-plugin/lto.exp +++ b/ld/testsuite/ld-plugin/lto.exp @@ -477,6 +477,12 @@ set lto_link_elf_tests [list \ [list {liblto-19.so} \ {-shared tmpdir/lto-19b.o tmpdir/liblto-19.a} {-O2 -fPIC} \ {dummy.c} {} {liblto-19.so}] \ + [list {liblto-20_static.a} \ + {} {-fPIC} \ + {lto-20b.c} {} {liblto-20_static.a}] \ + [list {liblto-20.so} \ + {-shared -Wl,--version-script=lto-20.ver} {-DSHARED -fPIC} \ + {lto-20b.c} {} {liblto-20.so}] \ [list {pr26806.so} \ {-shared} {-fpic -O2 -flto} \ {pr26806.c} {{nm {-D} pr26806.d}} {pr26806.so}] \ @@ -880,6 +886,10 @@ set lto_run_elf_shared_tests [list \ {-Wl,--as-needed,-R,tmpdir} {} \ {lto-19c.c} {lto-19.exe} {pass.out} {-flto -O2} {c} {} \ {tmpdir/liblto-19.so tmpdir/liblto-19.a}] \ + [list {lto-20} \ + {-Wl,--as-needed,-R,tmpdir} {} \ + {lto-20a.c} {lto-20.exe} {pass.out} {-flto} {c} {} \ + {tmpdir/liblto-20.so tmpdir/liblto-20_static.a -Wl,--no-as-needed}] \ [list {pr31482a} \ {-Wl,--no-as-needed,-R,tmpdir} {} \ {pr31482a.c} {pr31482a.exe} {pass.out} {-flto} {c} {} \ @@ -1202,6 +1212,38 @@ if { [is_elf_format] } { if { [is_elf_format] && [check_lto_shared_available] } { run_ld_link_exec_tests $lto_run_elf_shared_tests + if { [check_lto_fat_available] } { + run_cc_link_tests [list \ + [list \ + "Build libpr32846a.a" \ + "$plug_opt" "-fPIC -O2 -flto $lto_no_fat" \ + {pr32846a.c pr32846b.c} {} "libpr32846a.a" \ + ] \ + [list \ + "Build libpr32846b.a" \ + "$plug_opt" "-fPIC -O2 -flto $lto_no_fat" \ + {pr32846a.c pr32846b.c pr32846c.c} {} "libpr32846b.a" \ + ] \ + [list \ + "Build pr32846d.o" \ + "$plug_opt" "-fPIC -O2 -flto $lto_no_fat" \ + {pr32846d.c} {} \ + ] \ + [list \ + "Build pr32846e.o" \ + "$plug_opt" "-fPIC -O2 -flto $lto_no_fat" \ + {pr32846e.c} {} \ + ] \ + [list \ + "Build pr32846" \ + "-shared -fPIC -O2 -flto $lto_no_fat -Wl,--no-undefined \ + tmpdir/pr32846d.o tmpdir/libpr32846a.a \ + tmpdir/libpr32846b.a tmpdir/pr32846e.o" \ + "-O2 -fPIC -flto $lto_no_fat" \ + {dummy.c} {} "pr32846" \ + ] \ + ] \ + } } proc pr20103 {cflags libs} { diff --git a/ld/testsuite/ld-plugin/pr32846a.c b/ld/testsuite/ld-plugin/pr32846a.c new file mode 100644 index 0000000..8c16171 --- /dev/null +++ b/ld/testsuite/ld-plugin/pr32846a.c @@ -0,0 +1,6 @@ +extern void mkdir_p (void); +void +mkdir_parents (void) +{ + mkdir_p (); +} diff --git a/ld/testsuite/ld-plugin/pr32846b.c b/ld/testsuite/ld-plugin/pr32846b.c new file mode 100644 index 0000000..9776a37 --- /dev/null +++ b/ld/testsuite/ld-plugin/pr32846b.c @@ -0,0 +1,4 @@ +void +hash_new (void) +{ +} diff --git a/ld/testsuite/ld-plugin/pr32846c.c b/ld/testsuite/ld-plugin/pr32846c.c new file mode 100644 index 0000000..f87cffb --- /dev/null +++ b/ld/testsuite/ld-plugin/pr32846c.c @@ -0,0 +1,6 @@ +extern void hash_new (void); +void +kmod_new (void) +{ + hash_new(); +} diff --git a/ld/testsuite/ld-plugin/pr32846d.c b/ld/testsuite/ld-plugin/pr32846d.c new file mode 100644 index 0000000..c6f4102 --- /dev/null +++ b/ld/testsuite/ld-plugin/pr32846d.c @@ -0,0 +1,12 @@ +extern void kmod_new (void); +extern void mkdir_parents (void); +void +do_lsmod (void) +{ + kmod_new (); +} +void +do_static_nodes (void) +{ + mkdir_parents(); +} diff --git a/ld/testsuite/ld-plugin/pr32846e.c b/ld/testsuite/ld-plugin/pr32846e.c new file mode 100644 index 0000000..c4e5e56 --- /dev/null +++ b/ld/testsuite/ld-plugin/pr32846e.c @@ -0,0 +1,4 @@ +void +mkdir_p (void) +{ +} 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 |