Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / dup-sect.exp
CommitLineData
82ccf5a5
JK
1# This testcase is part of GDB, the GNU debugger.
2
88b9d363 3# Copyright 2010-2022 Free Software Foundation, Inc.
82ccf5a5
JK
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.
27if {![istarget *-*-linux*]
28 && ![istarget *-*-gnu*]
29 && ![istarget *-*-elf*]
810cfdbb 30 && ![istarget arm*-*-eabi*]
82ccf5a5
JK
31 && ![istarget powerpc-*-eabi*]} {
32 return 0
33}
34
f76495c8 35standard_testfile .S
82ccf5a5
JK
36set srcmainfile start.c
37set executable ${testfile}
82ccf5a5
JK
38
39if {[build_executable ${testfile}.exp $executable [list ${srcfile} ${srcmainfile}] {}] == -1} {
40 return -1
41}
42
43set test "rename section"
4fa7d390 44set objcopy_program [gdb_find_objcopy]
82ccf5a5
JK
45set result [catch "exec $objcopy_program --rename-section sect2=sect1 $binfile" output]
46verbose "result is $result"
47verbose "output is $output"
48if {$result != 0} {
49 fail $test
50 return
51}
52pass $test
53
54set test "split"
55if {[gdb_gnu_strip_debug $binfile] != 0} {
56 fail $test
57} else {
58 pass $test
59}
60
61# gdb_gnu_strip_debug uses only --strip-debug and keeps the ELF symbol table
62# in $binfile.
63set test "strip"
64set strip_program [transform strip]
65set result [catch "exec $strip_program $binfile" output]
66verbose "result is $result"
67verbose "output is $output"
68if {$result != 0} {
69 fail $test
70 return
71}
72pass $test
73
74clean_restart $executable
75
76gdb_test "p/d *(const char *) &var1" " = 1" "var1 after strip"
77gdb_test "p/d *(const char *) &var2" " = 2" "var2 after strip"
This page took 1.384224 seconds and 4 git commands to generate.