| OLD | NEW |
| 1 # Copyright (C) 2003, 2005, 2007-2012 Free Software Foundation, Inc. | 1 # Copyright (C) 2003-2013 Free Software Foundation, Inc. |
| 2 # | 2 # |
| 3 # This program is free software; you can redistribute it and/or modify | 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 | 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 | 5 # the Free Software Foundation; either version 3 of the License, or |
| 6 # (at your option) any later version. | 6 # (at your option) any later version. |
| 7 # | 7 # |
| 8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
| 12 # | 12 # |
| 13 # You should have received a copy of the GNU General Public License | 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/>. | 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 # | 15 # |
| 16 | 16 |
| 17 # Tests for shared object file relocation. If two shared objects have | 17 # Tests for shared object file relocation. If two shared objects have |
| 18 # the same load address (actually, overlapping load spaces), one of | 18 # the same load address (actually, overlapping load spaces), one of |
| 19 # them gets relocated at load-time. Check that gdb gets the right | 19 # them gets relocated at load-time. Check that gdb gets the right |
| 20 # values for the debugging and minimal symbols. | 20 # values for the debugging and minimal symbols. |
| 21 | 21 |
| 22 if {[skip_shlib_tests]} { | 22 if {[skip_shlib_tests]} { |
| 23 return 0 | 23 return 0 |
| 24 } | 24 } |
| 25 | 25 |
| 26 # | 26 # |
| 27 # This file uses shreloc.c, shreloc1.c and shreloc2.c | 27 # This file uses shreloc.c, shreloc1.c and shreloc2.c |
| 28 # | 28 # |
| 29 | 29 |
| 30 | 30 |
| 31 set workdir ${objdir}/${subdir} | 31 standard_testfile .c shreloc1.c shreloc2.c |
| 32 set testfile "shreloc" | 32 |
| 33 set libfile1 "shreloc1" | 33 set srcfile $srcdir/$subdir/$srcfile |
| 34 set libfile2 "shreloc2" | 34 set lib1src $srcdir/$subdir/$srcfile2 |
| 35 set srcfile $srcdir/$subdir/$testfile.c | 35 set lib2src $srcdir/$subdir/$srcfile3 |
| 36 set lib1src $srcdir/$subdir/$libfile1.c | 36 set binfile [standard_output_file $testfile] |
| 37 set lib2src $srcdir/$subdir/$libfile2.c | 37 set lib1_sl [standard_output_file shreloc1.sl] |
| 38 set binfile $objdir/$subdir/$testfile | 38 set lib2_sl [standard_output_file shreloc2.sl] |
| 39 set lib1_sl $objdir/$subdir/$libfile1.sl | |
| 40 set lib2_sl $objdir/$subdir/$libfile2.sl | |
| 41 | 39 |
| 42 if [get_compiler_info] { | 40 if [get_compiler_info] { |
| 43 return -1 | 41 return -1 |
| 44 } | 42 } |
| 45 | 43 |
| 46 set lib_opts "debug" | 44 set lib_opts "debug" |
| 47 set exec_opts [list debug shlib=$lib1_sl shlib=$lib2_sl] | 45 set exec_opts [list debug shlib=$lib1_sl shlib=$lib2_sl] |
| 48 | 46 |
| 49 if {([istarget "*pc-cygwin"] || [istarget "*pc-mingw32"]) } { | 47 if {([istarget "*pc-cygwin"] || [istarget "*pc-mingw32"]) } { |
| 50 lappend lib_opts "ldflags=-Wl,--image-base,0x04000000" | 48 lappend lib_opts "ldflags=-Wl,--image-base,0x04000000" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 66 } elseif { [gdb_compile_shlib $lib2src $lib2_sl $lib_opts] != ""} { | 64 } elseif { [gdb_compile_shlib $lib2src $lib2_sl $lib_opts] != ""} { |
| 67 untested "Could not build $lib1_s2." | 65 untested "Could not build $lib1_s2." |
| 68 return -1 | 66 return -1 |
| 69 } elseif { [gdb_compile $srcfile $binfile executable $exec_opts] != ""} { | 67 } elseif { [gdb_compile $srcfile $binfile executable $exec_opts] != ""} { |
| 70 untested "Could not build $binfile." | 68 untested "Could not build $binfile." |
| 71 return -1 | 69 return -1 |
| 72 } | 70 } |
| 73 | 71 |
| 74 # Start with a fresh gdb. | 72 # Start with a fresh gdb. |
| 75 | 73 |
| 76 gdb_exit | 74 clean_restart $binfile |
| 77 gdb_start | |
| 78 gdb_reinitialize_dir $srcdir/$subdir | |
| 79 gdb_load ${workdir}/shreloc | |
| 80 gdb_load_shlibs $lib1_sl $lib2_sl | 75 gdb_load_shlibs $lib1_sl $lib2_sl |
| 81 | 76 |
| 82 # Load up the shared objects | 77 # Load up the shared objects |
| 83 if ![runto_main] then { | 78 if ![runto_main] then { |
| 84 fail "Can't run to main" | 79 fail "Can't run to main" |
| 85 return 0 | 80 return 0 |
| 86 } | 81 } |
| 87 | 82 |
| 88 proc get_var_address { var } { | 83 proc get_var_address { var } { |
| 89 global gdb_prompt hex | 84 global gdb_prompt hex |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 foreach addr ${addr_list} { | 214 foreach addr ${addr_list} { |
| 220 if { ${prev} == ${addr} } { | 215 if { ${prev} == ${addr} } { |
| 221 return 0 | 216 return 0 |
| 222 } | 217 } |
| 223 set prev ${addr} | 218 set prev ${addr} |
| 224 } | 219 } |
| 225 | 220 |
| 226 return 1 | 221 return 1 |
| 227 } | 222 } |
| 228 | 223 |
| 229 set msymfile "${workdir}/shreloc.txt" | 224 if [is_remote host] { |
| 225 set msymfile shreloc.txt |
| 226 } else { |
| 227 set msymfile [standard_output_file shreloc.txt] |
| 228 } |
| 230 | 229 |
| 231 if [send_gdb_discard "maint print msymbols ${msymfile}"] { | 230 if [send_gdb_discard "maint print msymbols ${msymfile}"] { |
| 232 if {[check_different "static_var_\[12\]" "${msymfile}"]} { | 231 if {[check_different "static_var_\[12\]" "${msymfile}"]} { |
| 233 pass "(msymbol) relocated static vars have different addresses" | 232 pass "(msymbol) relocated static vars have different addresses" |
| 234 } else { | 233 } else { |
| 235 fail "(msymbol) relocated static vars have different addresses" | 234 fail "(msymbol) relocated static vars have different addresses" |
| 236 } | 235 } |
| 237 | 236 |
| 238 if {[check_different "extern_var_\[12\]" "${msymfile}"]} { | 237 if {[check_different "extern_var_\[12\]" "${msymfile}"]} { |
| 239 pass "(msymbol) relocated extern vars have different addresses" | 238 pass "(msymbol) relocated extern vars have different addresses" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 255 # relocated. | 254 # relocated. |
| 256 # | 255 # |
| 257 # A better approach would be include absolute symbols via the assembler. | 256 # A better approach would be include absolute symbols via the assembler. |
| 258 # | 257 # |
| 259 if {[check_same "_minor_os_version__" "${msymfile}"]} { | 258 if {[check_same "_minor_os_version__" "${msymfile}"]} { |
| 260 pass "Absolute symbols not relocated" | 259 pass "Absolute symbols not relocated" |
| 261 } else { | 260 } else { |
| 262 fail "Absolute symbols not relocated" | 261 fail "Absolute symbols not relocated" |
| 263 } | 262 } |
| 264 } | 263 } |
| OLD | NEW |