2011-02-21 Michael Snyder <msnyder@vmware.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / dup-sect.exp
1 # This testcase is part of GDB, the GNU debugger.
2
3 # Copyright 2010, 2011 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 # Test inappropriate offseting of multiple sections with the same name.
19 # When kept in object file (before final executable link) it still works.
20 # When separate debug info file is not used it still works.
21 # When the ELF symbol table is kept in the main binary it still works.
22 # Used .S file as in .c file we would need __attriute__((section)) which is
23 # a GCC extension.
24
25 # This test can only be run on targets which support ELF and use gas.
26 # For now pick a sampling of likely targets.
27 if {![istarget *-*-linux*]
28 && ![istarget *-*-gnu*]
29 && ![istarget *-*-elf*]
30 && ![istarget arm*-*-eabi*]
31 && ![istarget arm*-*-symbianelf*]
32 && ![istarget powerpc-*-eabi*]} {
33 return 0
34 }
35
36 set testfile dup-sect
37 set srcfile ${testfile}.S
38 set srcmainfile start.c
39 set executable ${testfile}
40 set binfile ${objdir}/${subdir}/${executable}
41
42 if {[build_executable ${testfile}.exp $executable [list ${srcfile} ${srcmainfile}] {}] == -1} {
43 return -1
44 }
45
46 set test "rename section"
47 set objcopy_program [transform objcopy]
48 set result [catch "exec $objcopy_program --rename-section sect2=sect1 $binfile" output]
49 verbose "result is $result"
50 verbose "output is $output"
51 if {$result != 0} {
52 fail $test
53 return
54 }
55 pass $test
56
57 set test "split"
58 if {[gdb_gnu_strip_debug $binfile] != 0} {
59 fail $test
60 } else {
61 pass $test
62 }
63
64 # gdb_gnu_strip_debug uses only --strip-debug and keeps the ELF symbol table
65 # in $binfile.
66 set test "strip"
67 set strip_program [transform strip]
68 set result [catch "exec $strip_program $binfile" output]
69 verbose "result is $result"
70 verbose "output is $output"
71 if {$result != 0} {
72 fail $test
73 return
74 }
75 pass $test
76
77 clean_restart $executable
78
79 gdb_test "p/d *(const char *) &var1" " = 1" "var1 after strip"
80 gdb_test "p/d *(const char *) &var2" " = 2" "var2 after strip"
This page took 0.039333 seconds and 4 git commands to generate.