| # Copyright 2009 Free Software Foundation, Inc. |
| |
| # This program is free software; you can redistribute it and/or modify |
| # it under the terms of the GNU General Public License as published by |
| # the Free Software Foundation; either version 3 of the License, or |
| # (at your option) any later version. |
| # |
| # This program is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| # GNU General Public License for more details. |
| # |
| # You should have received a copy of the GNU General Public License |
| # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| |
| set testfile pie-support |
| set srcfile ${testfile}.c |
| set objfile ${objdir}/${subdir}/${testfile}.o |
| set binfile ${objdir}/${subdir}/${testfile} |
| |
| if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug additional_flags=-fpie}] != "" } { |
| untested "Couldn't compile test PIE object file." |
| return -1 |
| } |
| if { [gdb_compile "${objfile}" "${binfile}" executable {debug additional_flags=-pie}] != "" } { |
| untested "Couldn't compile test PIE binary." |
| return -1 |
| } |
| |
| # Get things started. |
| |
| gdb_exit |
| gdb_start |
| gdb_reinitialize_dir $srcdir/$subdir |
| |
| if [is_remote host] { |
| set binfile [remote_download host $binfile] |
| if { $binfile == "" } { |
| untested "Couldn't download remote test binary." |
| return -1 |
| } |
| } |
| |
| # The file command used to kill the remote target. For the benefit |
| # of the testsuite, preserve this behavior. |
| send_gdb "kill\n" |
| gdb_expect 120 { |
| -re "Kill the program being debugged. .y or n. $" { |
| send_gdb "y\n" |
| verbose "\t\tKilling previous program being debugged" |
| exp_continue |
| } |
| -re "$gdb_prompt $" { |
| # OK. |
| } |
| } |
| |
| gdb_test "file $binfile" "current binary is a PIE.*" "correctly detected PIE binary" |