diff options
Diffstat (limited to 'libctf/testsuite/lib/ctf-lib.exp')
-rw-r--r-- | libctf/testsuite/lib/ctf-lib.exp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libctf/testsuite/lib/ctf-lib.exp b/libctf/testsuite/lib/ctf-lib.exp index 64d2a40..4df6619 100644 --- a/libctf/testsuite/lib/ctf-lib.exp +++ b/libctf/testsuite/lib/ctf-lib.exp @@ -20,6 +20,51 @@ load_file $srcdir/../../ld/testsuite/lib/ld-lib.exp +# Returns true if the target linker deduplicates CTF. +proc check_ctf_linker_dedup { } { + global ctf_linker_dedup_saved + + if {![info exists ctf_linker_dedup_saved]} { + set ctf_linker_dedup_saved 0 + + if ([check_ctf_available]) { + global objdump srcdir + + set basename "tmpdir/ctf_linker_dedups[pid]" + compile_one_cc $srcdir/libctf-lookup/ambiguous-struct-A.c ${basename}-A.o "-gctf -fPIC -c" + compile_one_cc $srcdir/libctf-lookup/ambiguous-struct-B.c ${basename}-B.o "-gctf -fPIC -c" + compile_one_cc "${basename}-A.o ${basename}-B.o" $basename.so "-gctf -fPIC -shared" + if {! [remote_file host exists $basename.so] } { + return 0 + } + + # Don't use run_host_cmd: it dumps the entire output into the log, + # even on success. + set cmdret [remote_exec host [concat sh -c [list "$objdump --ctf $basename.so >dump.out 2>dump.err"]] "" "/dev/null"] + set cmdret [lindex $cmdret 0] + remote_upload host "dump.out" + remote_upload host "dump.err" + set dump_out [prune_warnings [file_contents "dump.out"]] + set dump_err [prune_warnings [file_contents "dump.err"]] + remote_file host delete "dump.out" "dump.err" + remote_file build delete "dump.out" "dump.err" + + if {$cmdret != 0} { + verbose -log "failed with $cmdret: stderr: $dump_err" + verbose -log "output: $dump_out" + return 0; + } + + remote_file host delete $basename.so ${basename}-A.o ${basename}-B.o + if [regexp {CTF archive member: } $dump_out] { + set ctf_linker_dedup_saved 1 + } + } + } + return $ctf_linker_dedup_saved +} + + proc run_native_host_cmd { command } { global link_output global ld |