| # Copyright 2017 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/>. |
| |
| # PR 21126 |
| # strip may completely nullify the PT_GNU_RELRO segment header. |
| # Seeing this bug requires exec_bfd to be from the non-stripped binary, |
| # with the in-memory image being from the stripped binary. And it seems |
| # to require clang-built executables, not sure what the difference is that |
| # triggers the complete nullification. |
| |
| load_lib gdbserver-support.exp |
| |
| standard_testfile server.c |
| |
| if { [skip_gdbserver_tests] } { |
| return 0 |
| } |
| |
| if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug additional_flags=-fpie "ldflags=-pie -Wl,-z,relro"}]} { |
| return -1 |
| } |
| |
| set stripped_binfile ${binfile}.stripped |
| |
| set strip_program [transform strip] |
| remote_file host delete ${stripped_binfile} |
| if [run_on_host "strip" "$strip_program" "-g -o ${stripped_binfile} $binfile"] { |
| return -1 |
| } |
| |
| clean_restart ${binfile} |
| |
| # Make sure we're disconnected, in case we're testing with an |
| # extended-remote board, therefore already connected. |
| gdb_test "disconnect" ".*" |
| |
| set remote_binfile [gdb_remote_download target $stripped_binfile] |
| gdbserver_start_extended |
| |
| gdb_test_no_output "set remote exec-file $remote_binfile" "set remote exec-file" |
| |
| # If we can run to main, we're good. |
| runto main message |