gdb/
[binutils-gdb.git] / gdb / testsuite / gdb.base / break-interp.exp
1 # Copyright 2010 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 # This test only works on GNU/Linux.
17 if { ![isnative] || [is_remote host] || ![istarget *-linux*] || [skip_shlib_tests]} {
18 continue
19 }
20
21 set test "break-interp"
22 set binprefix ${objdir}/${subdir}/${test}
23 # Only to get the $interp_system name.
24 set srcfile_test "start.c"
25 set binfile_test ${test}-test
26 set binfile_lib ${objdir}/${subdir}/${test}.so
27 set srcfile "${test}-main.c"
28 set srcfile_lib "${test}-lib.c"
29
30 if [get_compiler_info ${binfile_lib}] {
31 return -1
32 }
33
34 # Use -soname so that it is listed with " => " by ldd and this testcase makes
35 # a copy of ${binfile_lib} for each prelink variant.
36
37 if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug additional_flags=-Wl,-soname,${test}.so]] != ""} {
38 return -1
39 }
40
41 if {[build_executable ${test}.exp $binfile_test ${srcfile_test} {}] == -1} {
42 return -1
43 }
44
45 # Return the interpreter filename string.
46 # Return "" if no interpreter was found.
47 proc section_get {exec section} {
48 global objdir
49 global subdir
50 set tmp "${objdir}/${subdir}/break-interp.interp"
51 set objcopy_program [transform objcopy]
52
53 set command "exec $objcopy_program -O binary --set-section-flags $section=A --change-section-address $section=0 -j $section $exec $tmp"
54 verbose -log "command is $command"
55 set result [catch $command output]
56 verbose -log "result is $result"
57 verbose -log "output is $output"
58 if {$result == 1} {
59 return ""
60 }
61 set fi [open $tmp]
62 fconfigure $fi -translation binary
63 set data [read $fi]
64 close $fi
65 #file delete $tmp
66 # .interp has size $len + 1 but .gnu_debuglink contains garbage after \000.
67 set len [string first \000 $data]
68 if {$len < 0} {
69 verbose -log "section $section not found"
70 return ""
71 }
72 set retval [string range $data 0 [expr $len - 1]]
73 verbose -log "section $section is <$retval>"
74 return $retval
75 }
76
77 # Note: The separate debug info file content build-id/crc32 are not verified
78 # contrary to the GDB search algorithm skipping non-matching ones.
79 proc system_debug_get {exec} {
80 global debug_root
81
82 set exec_build_id_debug [build_id_debug_filename_get $exec]
83 set debug_base "[file tail $exec].debug"
84 set exec_dir [file dirname $exec]
85
86 # isfile returns 1 even for symlinks to files.
87 set retval $debug_root/$exec_build_id_debug
88 if [file isfile $retval] {
89 return $retval
90 }
91 set retval $exec_dir/$debug_base
92 if [file isfile $retval] {
93 return $retval
94 }
95 set retval $exec_dir/.debug/$debug_base
96 if [file isfile $retval] {
97 return $retval
98 }
99 set retval $debug_root/$exec_dir/$debug_base
100 if [file isfile $retval] {
101 return $retval
102 }
103 return ""
104 }
105
106 gdb_exit
107 gdb_start
108 set debug_root ""
109 set test "show debug-file-directory"
110 gdb_test_multiple $test $test {
111 -re "The directory where separate debug symbols are searched for is \"(.*)\".\r\n$gdb_prompt $" {
112 set debug_root $expect_out(1,string)
113 }
114 }
115
116 set interp_system [section_get ${objdir}/${subdir}/$binfile_test .interp]
117 set interp_system_debug [system_debug_get $interp_system]
118 verbose -log "$interp_system has debug $interp_system_debug"
119
120 proc prelinkNO_run {arg} {
121 set command "exec /usr/sbin/prelink -uN $arg"
122 verbose -log "command is $command"
123 set result [catch $command output]
124 verbose -log "result is $result"
125 verbose -log "output is $output"
126 return [list $result $output]
127 }
128
129 proc prelinkNO {arg {name {}}} {
130 if {$name == ""} {
131 set name [file tail $arg]
132 }
133 set test "unprelink $name"
134 set run [prelinkNO_run $arg]
135 set result [lindex $run 0]
136 set output [lindex $run 1]
137 if {$result == 0 && $output == ""} {
138 verbose -log "$name has been now unprelinked"
139 set run [prelinkNO_run $arg]
140 set result [lindex $run 0]
141 set output [lindex $run 1]
142 }
143 # Last line does miss the trailing \n.
144 if {$result == 1 && [regexp {^(/usr/sbin/prelink[^\r\n]*: [^ ]* does not have .gnu.prelink_undo section\n?)*$} $output]} {
145 pass $test
146 return 1
147 } else {
148 fail $test
149 return 0
150 }
151 }
152
153 proc prelinkYES {arg {name ""}} {
154 if {$name == ""} {
155 set name [file tail $arg]
156 }
157
158 # Try to unprelink it first so that if it has been already prelinked before
159 # we get different address now and the result is not affected by the
160 # previous $arg state..
161 prelinkNO $arg "$name pre-unprelink"
162
163 set test "prelink $name"
164 set command "exec /usr/sbin/prelink -qNR --no-exec-shield $arg"
165 verbose -log "command is $command"
166 set result [catch $command output]
167 verbose -log "result is $result"
168 verbose -log "output is $output"
169 if {$result == 0 && $output == ""} {
170 pass $test
171 return 1
172 } elseif {$result == 1 \
173 && [string match -nocase "*: Not enough room to add .dynamic entry" $output]} {
174 # Linker should have reserved some entries for prelink.
175 xfail $test
176 return 0
177 } else {
178 fail $test
179 return 0
180 }
181 }
182
183 # Resolve symlinks.
184 proc symlink_resolve {file} {
185 set loop 0
186 while {[file type $file] == "link"} {
187 set target [file readlink $file]
188 if {[file pathtype $target] == "relative"} {
189 set src2 [file dirname $file]/$target
190 } else {
191 set src2 $target
192 }
193 verbose -log "Resolved symlink $file targetting $target as $src2"
194 set file $src2
195
196 set loop [expr $loop + 1]
197 if {$loop > 30} {
198 fail "Looping symlink resolution for $file"
199 return ""
200 }
201 }
202 return $file
203 }
204
205 proc copy {src dest} {
206 set src [symlink_resolve $src]
207 # Test name would contain build-id hash for symlink-unresolved $src.
208 set test "copy [file tail $src] to [file tail $dest]"
209 set command "file copy -force $src $dest"
210 verbose -log "command is $command"
211 if [catch $command] {
212 fail $test
213 return 0
214 } else {
215 pass $test
216 return 1
217 }
218 }
219
220 proc strip_debug {dest} {
221 set test "strip [file tail $dest]"
222 set strip_program [transform strip]
223 set command "exec $strip_program --strip-debug $dest"
224 verbose -log "command is $command"
225 if [catch $command] {
226 fail $test
227 return 0
228 } else {
229 pass $test
230 return 1
231 }
232 }
233
234 # `runto' does not check we stopped really at the function we specified.
235 # DISPLACEMENT can be "NONE", "ZERO" or "NONZERO"
236 proc reach {func command displacement} {
237 global gdb_prompt expect_out
238
239 global pf_prefix
240 set old_ldprefix $pf_prefix
241 lappend pf_prefix "reach-$func:"
242
243 if [gdb_breakpoint $func allow-pending] {
244 set test "reach"
245 set test_displacement "seen displacement message as $displacement"
246 gdb_test_multiple $command $test {
247 -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
248 # Missing "$gdb_prompt $" is intentional.
249 if {$expect_out(1,string) == "0x0"} {
250 set case "ZERO"
251 } else {
252 set case "NONZERO"
253 }
254 if {$displacement == $case} {
255 pass $test_displacement
256 # Permit multiple such messages.
257 set displacement "FOUND-$displacement"
258 } elseif {$displacement != "FOUND-$case"} {
259 fail $test_displacement
260 }
261 exp_continue
262 }
263 -re "Breakpoint \[0-9\]+, $func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" {
264 pass $test
265 }
266 -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in $func \\(\\).*\r\n$gdb_prompt $" {
267 pass $test
268 }
269 }
270 if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
271 fail $test_displacement
272 }
273 }
274
275 set pf_prefix $old_ldprefix
276 }
277
278 proc test_core {file displacement} {
279 global srcdir subdir gdb_prompt expect_out
280
281 set corefile [core_find $file {} "segv"]
282 if {$corefile == ""} {
283 return
284 }
285
286 global pf_prefix
287 set old_ldprefix $pf_prefix
288 lappend pf_prefix "core:"
289
290 gdb_exit
291 gdb_start
292 # Clear it to never find any separate debug infos in $debug_root.
293 gdb_test_no_output "set debug-file-directory" \
294 "set debug-file-directory for core"
295 gdb_reinitialize_dir $srcdir/$subdir
296 gdb_load $file
297
298 # Print the "PIE (Position Independent Executable) displacement" message.
299 gdb_test_no_output "set verbose on"
300
301 set test "core loaded"
302 set test_displacement "seen displacement message as $displacement"
303 gdb_test_multiple "core-file $corefile" $test {
304 -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
305 # Missing "$gdb_prompt $" is intentional.
306 if {$expect_out(1,string) == "0x0"} {
307 set case "ZERO"
308 } else {
309 set case "NONZERO"
310 }
311 if {$displacement == $case} {
312 pass $test_displacement
313 # Permit multiple such messages.
314 set displacement "FOUND-$displacement"
315 } elseif {$displacement != "FOUND-$case"} {
316 fail $test_displacement
317 }
318 exp_continue
319 }
320 -re "Core was generated by .*\r\n#0 .*$gdb_prompt $" {
321 # Do not check the binary filename as it may be truncated.
322 pass $test
323 }
324 }
325 if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
326 fail $test_displacement
327 }
328
329 gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "core main bt"
330
331 set pf_prefix $old_ldprefix
332 }
333
334 proc test_attach_gdb {file pid displacement prefix} {
335 global gdb_prompt expect_out
336
337 global pf_prefix
338 set old_ldprefix $pf_prefix
339 lappend pf_prefix "$prefix:"
340
341 gdb_exit
342 gdb_start
343
344 # Print the "PIE (Position Independent Executable) displacement" message.
345 gdb_test_no_output "set verbose on"
346
347 if {$file != ""} {
348 gdb_test "file $file" "Reading symbols from .*done\\." "file"
349 }
350
351 set test "attach"
352 gdb_test_multiple "attach $pid" $test {
353 -re "Attaching to (program: .*, )?process $pid\r\n" {
354 # Missing "$gdb_prompt $" is intentional.
355 pass $test
356 }
357 }
358
359 set test "attach final prompt"
360 set test_displacement "seen displacement message as $displacement"
361 gdb_test_multiple "" $test {
362 -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
363 # Missing "$gdb_prompt $" is intentional.
364 if {$expect_out(1,string) == "0x0"} {
365 set case "ZERO"
366 } else {
367 set case "NONZERO"
368 }
369 if {$displacement == $case} {
370 pass $test_displacement
371 # Permit multiple such messages.
372 set displacement "FOUND-$displacement"
373 } elseif {$displacement != "FOUND-$case"} {
374 fail $test_displacement
375 }
376 exp_continue
377 }
378 -re "$gdb_prompt $" {
379 pass $test
380 }
381 }
382 if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
383 fail $test_displacement
384 }
385
386 gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "attach main bt"
387 gdb_exit
388
389 set pf_prefix $old_ldprefix
390 }
391
392 proc test_attach {file displacement {relink_args ""}} {
393 global board_info
394
395 gdb_exit
396
397 set test "sleep function started"
398
399 set command "${file} sleep"
400 set res [remote_spawn host $command];
401 if { $res < 0 || $res == "" } {
402 perror "Spawning $command failed."
403 fail $test
404 return
405 }
406 set pid [exp_pid -i $res]
407 gdb_expect {
408 -re "sleeping\r\n" {
409 pass $test
410 }
411 eof {
412 fail "$test (eof)"
413 return
414 }
415 timeout {
416 fail "$test (timeout)"
417 return
418 }
419 }
420
421 if {$relink_args == ""} {
422 test_attach_gdb "" $pid $displacement "attach"
423 } else {
424 # These could be rather passed as arguments.
425 global exec interp_saved interp
426
427 foreach relink {YES NO} {
428 if {[prelink$relink $relink_args [file tail $exec]]
429 && [copy $interp_saved $interp]} {
430 # /proc/PID/exe cannot be loaded as it is "EXECNAME (deleted)".
431 test_attach_gdb $exec $pid $displacement "attach-relink$relink"
432 }
433 }
434 }
435
436 remote_exec host "kill -9 $pid"
437 }
438
439 proc test_ld {file ifmain trynosym displacement} {
440 global srcdir subdir gdb_prompt expect_out
441
442 # First test normal `file'-command loaded $FILE with symbols.
443
444 gdb_exit
445 gdb_start
446 # Clear it to never find any separate debug infos in $debug_root.
447 gdb_test_no_output "set debug-file-directory"
448 gdb_reinitialize_dir $srcdir/$subdir
449 gdb_load $file
450
451 # Print the "PIE (Position Independent Executable) displacement" message.
452 gdb_test_no_output "set verbose on"
453
454 reach "dl_main" "run segv" $displacement
455
456 gdb_test "bt" "#0 +\[^\r\n\]*\\mdl_main\\M.*" "dl bt"
457
458 if $ifmain {
459 # Displacement message will be printed the second time on initializing
460 # the linker from svr4_special_symbol_handling. If any ANOFFSET has
461 # been already set as non-zero the detection will no longer be run.
462 if {$displacement == "NONZERO"} {
463 set displacement_main "NONE"
464 } else {
465 set displacement_main $displacement
466 }
467 reach "main" continue $displacement_main
468
469 reach "libfunc" continue "NONE"
470
471 gdb_test "bt" "#0 +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#1 +\[^\r\n\]*\\mmain\\M.*" "main bt"
472
473 test_core $file $displacement
474
475 test_attach $file $displacement
476 }
477
478 if !$trynosym {
479 return
480 }
481
482 global pf_prefix
483 set old_ldprefix $pf_prefix
484 lappend pf_prefix "symbol-less:"
485
486 # Test also `exec-file'-command loaded $FILE - therefore without symbols.
487 # SYMBOL_OBJFILE is not available and only EXEC_BFD must be used.
488
489 gdb_exit
490 gdb_start
491 # Clear it to never find any separate debug infos in $debug_root.
492 gdb_test_no_output "set debug-file-directory"
493 gdb_reinitialize_dir $srcdir/$subdir
494
495 # Print the "PIE (Position Independent Executable) displacement" message.
496 gdb_test_no_output "set verbose on"
497
498 # Test no (error) message has been printed by `exec-file'.
499 set escapedfile [string_to_regexp $file]
500 gdb_test "exec-file $file" "exec-file $escapedfile" "load"
501
502 if $ifmain {
503 reach "dl_main" run $displacement
504
505 set test "info files"
506 set entrynohex ""
507 gdb_test_multiple $test $test {
508 -re "\r\n\[\t \]*Entry point:\[\t \]*0x(\[0-9a-f\]+)\r\n.*$gdb_prompt $" {
509 set entrynohex $expect_out(1,string)
510 pass $test
511 }
512 }
513 if {$entrynohex != ""} {
514 gdb_test "break *0x$entrynohex" "" "break at entry point"
515 gdb_test "continue" "\r\nBreakpoint \[0-9\]+, 0x0*$entrynohex in .*" "entry point reached"
516 }
517 } else {
518 # There is no symbol to break at ld.so. Moreover it can exit with an
519 # error code.
520
521 set test "ld.so exit"
522 set test_displacement "seen displacement message as $displacement"
523 gdb_test_multiple "run" $test {
524 -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
525 # Missing "$gdb_prompt $" is intentional.
526 if {$expect_out(1,string) == "0x0"} {
527 set case "ZERO"
528 } else {
529 set case "NONZERO"
530 }
531 if {$displacement == $case} {
532 pass $test_displacement
533 # Permit multiple such messages.
534 set displacement "FOUND-$displacement"
535 } elseif {$displacement != "FOUND-$case"} {
536 fail $test_displacement
537 }
538 exp_continue
539 }
540 -re "Program exited (normally|with code \[0-9\]+)\\.\r\n$gdb_prompt $" {
541 # Do not check the binary filename as it may be truncated.
542 pass $test
543 }
544 }
545 if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
546 fail $test_displacement
547 }
548 }
549
550 set pf_prefix $old_ldprefix
551 }
552
553 # Create separate binaries for each testcase - to make the possible reported
554 # problem reproducible after the whole test run finishes.
555
556 set old_ldprefix $pf_prefix
557 foreach ldprelink {NO YES} {
558 foreach ldsepdebug {NO IN SEP} {
559 # Skip running the ldsepdebug test if we do not have system separate
560 # debug info available.
561 if {$interp_system_debug == "" && $ldsepdebug == "SEP"} {
562 continue
563 }
564
565 set ldname "LDprelink${ldprelink}debug${ldsepdebug}"
566 set interp $binprefix-$ldname
567
568 # prelink needs to always prelink all the dependencies to do any file
569 # modifications of its files. ld.so also needs all the dependencies to
570 # be prelinked to omit the relocation process. In-memory file offsets
571 # are not dependent whether ld.so went the prelink way or through the
572 # relocation process.
573 #
574 # For GDB we are not interested whether prelink succeeds as it is
575 # transparent to GDB. GDB is being tested for differences of file
576 # offsets vs. in-memory offsets. So we have to prelink even ld.so for
577 # the BIN modification to happen but we need to restore the original
578 # possibly unprelinked ld.so to test all the combinations for GDB.
579 set interp_saved ${interp}-saved
580
581 set pf_prefix $old_ldprefix
582 lappend pf_prefix "$ldname:"
583
584 if {$ldsepdebug == "NO"} {
585 copy $interp_system $interp
586 # Never call strip-debug before unprelink:
587 # prelink: ...: Section .note.gnu.build-id created after prelinking
588 if ![prelinkNO $interp] {
589 continue
590 }
591 strip_debug $interp
592 } elseif {$ldsepdebug == "IN" && $interp_system_debug == ""} {
593 copy $interp_system $interp
594 } elseif {$ldsepdebug == "IN" && $interp_system_debug != ""} {
595 copy $interp_system $interp
596 copy $interp_system_debug "${interp}.debug"
597 # eu-unstrip: DWARF data in '...' not adjusted for prelinking bias; consider prelink -u
598 if {![prelinkNO $interp] || ![prelinkNO "${interp}.debug"]} {
599 continue
600 }
601 set test "eu-unstrip unprelinked:[file tail $interp_system] + [file tail $interp_system_debug] to [file tail $interp]"
602 set command "exec eu-unstrip -o $interp $interp ${interp}.debug"
603 verbose -log "command is $command"
604 if [catch $command] {
605 setup_xfail *-*-*
606 fail $test
607 continue
608 } else {
609 pass $test
610 }
611 } elseif {$ldsepdebug == "SEP" && $interp_system_debug == ""} {
612 copy $interp_system $interp
613 # eu-unstrip: DWARF data in '...' not adjusted for prelinking bias; consider prelink -u
614 if ![prelinkNO $interp] {
615 continue
616 }
617 gdb_gnu_strip_debug $interp
618 } elseif {$ldsepdebug == "SEP" && $interp_system_debug != ""} {
619 copy $interp_system $interp
620 copy $interp_system_debug "${interp}.debug"
621 }
622
623 if {$ldsepdebug == "SEP"} {
624 if ![prelinkNO "${interp}.debug"] {
625 continue
626 }
627 } else {
628 file delete "${interp}.debug"
629 }
630
631 if ![prelink$ldprelink $interp] {
632 continue
633 }
634 if {$ldprelink == "NO"} {
635 set displacement "NONZERO"
636 } else {
637 set displacement "ZERO"
638 }
639 test_ld $interp 0 [expr {$ldsepdebug == "NO"}] $displacement
640
641 if ![copy $interp $interp_saved] {
642 continue
643 }
644 set old_binprefix $pf_prefix
645 foreach binprelink {NO YES} {
646 foreach binsepdebug {NO IN SEP} {
647 # "ATTACH" is like "YES" but it is modified during run.
648 # It cannot be used for problem reproducibility after the
649 # testcase ends.
650 foreach binpie {NO YES ATTACH} {
651 # This combination is not possible, non-PIE (fixed address)
652 # binary cannot be prelinked to any (other) address.
653 if {$binprelink == "YES" && $binpie == "NO"} {
654 continue
655 }
656
657 set binname "BINprelink${binprelink}debug${binsepdebug}pie${binpie}"
658 set exec $binprefix-$binname
659 set dir ${exec}.d
660
661 set pf_prefix $old_binprefix
662 lappend pf_prefix "$binname:"
663
664 set opts "additional_flags=-Wl,--dynamic-linker,$interp,-rpath,$dir"
665 lappend opts "additional_flags=-Wl,$binfile_lib,-rpath,[file dirname $binfile_lib]"
666 if {$binsepdebug != "NO"} {
667 lappend opts {debug}
668 }
669 if {$binpie != "NO"} {
670 lappend opts {additional_flags=-fPIE -pie}
671 }
672 if {[build_executable ${test}.exp [file tail $exec] $srcfile $opts] == -1} {
673 continue;
674 }
675 if {$binsepdebug == "SEP"} {
676 gdb_gnu_strip_debug $exec
677 }
678
679 # Supply a self-sufficent directory $dir with the required
680 # libraries. To make an executable properly prelinked all
681 # its dependencies on libraries must be also prelinked. If
682 # some of the system libraries is currently not prelinked
683 # we have no right to prelink (modify it) at its current
684 # system place.
685
686 file delete -force $dir
687 file mkdir $dir
688
689 set command "ldd $exec"
690 set test "ldd [file tail $exec]"
691 set result [catch "exec $command" output]
692 verbose -log "result of $command is $result"
693 verbose -log "output of $command is $output"
694 if {$result != 0 || $output == ""} {
695 fail $test
696 } else {
697 pass $test
698 }
699
700 # gdb testsuite will put there also needless -lm.
701 set test "$test output contains libc"
702 set libc [regexp -all -inline -line {^.* => (/[^ ]+).*$} $output]
703 if {[llength $libc] == 0} {
704 fail $test
705 } else {
706 pass $test
707 }
708
709 set dests {}
710 for {set i 1} {$i < [llength $libc]} {incr i 2} {
711 set abspath [lindex $libc $i]
712 set dest "$dir/[file tail $abspath]"
713 copy $abspath $dest
714 lappend dests $dest
715 }
716
717 if {$binpie == "NO"} {
718 set displacement "NONE"
719 } elseif {$binprelink == "NO"} {
720 set displacement "NONZERO"
721 } else {
722 set displacement "ZERO"
723 }
724
725 set relink_args "--dynamic-linker=$interp --ld-library-path=$dir $exec $interp [concat $dests]"
726 if {[prelink$binprelink $relink_args [file tail $exec]]
727 && [copy $interp_saved $interp]} {
728 if {$binpie != "ATTACH"} {
729 test_ld $exec 1 [expr {$binsepdebug == "NO"}] $displacement
730 } else {
731 # If the file has been randomly prelinked it must
732 # be "NONZERO". We could see "ZERO" only if it was
733 # unprelinked and it is now running at the same
734 # address - which is 0 but executable can never run
735 # at address 0.
736
737 set displacement "NONZERO"
738 test_attach $exec $displacement $relink_args
739
740 # ATTACH means that executables and libraries have
741 # been modified after they have been run. They
742 # cannot be reused for problem reproducibility after
743 # the testcase ends in the ATTACH case. Therefore
744 # they are rather deleted not to confuse after the
745 # run finishes.
746 set exec_debug [system_debug_get $exec]
747 if {$exec_debug != ""} {
748 # `file delete [glob "${exec_debug}*"]' does not work.
749 foreach f [glob "${exec_debug}*"] {
750 file delete $f
751 }
752 }
753 file delete -force $dir
754 # `file delete [glob "${exec}*"]' does not work.
755 foreach f [glob "${exec}*"] {
756 file delete $f
757 }
758 }
759 }
760 }
761 }
762 }
763
764 file delete $interp_saved
765 }
766 }
767 set pf_prefix $old_ldprefix