xref: /netbsd-src/external/gpl3/gdb/dist/gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.exp (revision 867d70fc718005c0918b8b8b2f9d7f2d52d0a0db)
1# Copyright 2018-2020 Free Software Foundation, Inc.
2
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
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
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/>.
15
16# This file is part of the gdb testsuite
17
18#
19# PR gdb/21695
20# This tests if gdb can display line information of relocated symbols in the
21# case where executable text section was at address zero before relocation.
22#
23
24standard_testfile .c
25
26if [get_compiler_info] {
27    return -1
28}
29
30# Build executable with stripped startup code and text section starting at zero
31
32set opts {debug "additional_flags=-nostdlib -emain -Wl,-Ttext=0x00 -Wl,-N"}
33
34if {[build_executable $testfile.exp $testfile $srcfile $opts] == -1} {
35    untested "failed to compile"
36    return -1
37}
38
39clean_restart
40
41# Load symbols at an offset 0xffff0000 using add-symbol-file
42
43gdb_test "add-symbol-file $binfile 0xffff0000" \
44    "Reading symbols from .*" \
45    "add-symbol-file" \
46    "add symbol table from file \".*\" at.*\\(y or n\\) " "y"
47
48# Check if we are able to read offset adjusted line information of main
49
50gdb_test "info line main" \
51	"Line.*starts at address 0xffff0000.*and ends at.*"
52