aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/dwarf2/read.c10
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-zero-range-shlib.c21
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-zero-range.c24
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp185
4 files changed, 232 insertions, 8 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index acabee3..bac02b5 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -13631,7 +13631,6 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
/* Base address selection entry. */
gdb::optional<CORE_ADDR> base;
const gdb_byte *buffer;
- CORE_ADDR baseaddr;
bool overflow = false;
ULONGEST addr_index;
struct dwarf2_section_info *rnglists_section;
@@ -13648,8 +13647,6 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
}
buffer = rnglists_section->buffer + offset;
- baseaddr = objfile->text_section_offset ();
-
while (1)
{
/* Initialize it due to a false compiler warning. */
@@ -13791,7 +13788,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
/* A not-uncommon case of bad debug info.
Don't pollute the addrmap with bad data. */
- if (range_beginning + baseaddr == 0
+ if (range_beginning == 0
&& !per_objfile->per_bfd->has_section_at_zero)
{
complaint (_(".debug_rnglists entry has start address of zero"
@@ -13833,7 +13830,6 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag,
gdb::optional<CORE_ADDR> base;
unsigned int dummy;
const gdb_byte *buffer;
- CORE_ADDR baseaddr;
if (cu_header->version >= 5)
return dwarf2_rnglists_process (offset, cu, tag, callback);
@@ -13849,8 +13845,6 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag,
}
buffer = per_objfile->per_bfd->ranges.buffer + offset;
- baseaddr = objfile->text_section_offset ();
-
while (1)
{
CORE_ADDR range_beginning, range_end;
@@ -13901,7 +13895,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, dwarf_tag tag,
/* A not-uncommon case of bad debug info.
Don't pollute the addrmap with bad data. */
- if (range_beginning + baseaddr == 0
+ if (range_beginning == 0
&& !per_objfile->per_bfd->has_section_at_zero)
{
complaint (_(".debug_ranges entry has start address of zero"
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-zero-range-shlib.c b/gdb/testsuite/gdb.dwarf2/dw2-zero-range-shlib.c
new file mode 100644
index 0000000..1ddc8d6
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-zero-range-shlib.c
@@ -0,0 +1,21 @@
+/*
+ Copyright 2021 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/>. */
+
+void
+foo (void)
+{
+ asm ("foo_label: .globl foo_label");
+}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-zero-range.c b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.c
new file mode 100644
index 0000000..894a04d
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.c
@@ -0,0 +1,24 @@
+/*
+ Copyright 2021 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/>. */
+
+extern void foo (void);
+
+int
+main (void)
+{
+ asm ("main_label: .globl main_label");
+ foo ();
+}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
new file mode 100644
index 0000000..4f2ac0f
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
@@ -0,0 +1,185 @@
+# Copyright 2021 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/>.
+
+# Check that the ".debug_ranges entry has start address of zero" complaint
+# is triggered for a loaded shared lib.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+if {![dwarf2_support]} {
+ verbose "Skipping $gdb_test_file_name."
+ return 0
+}
+
+if {[skip_shlib_tests]} {
+ return 0
+}
+
+standard_testfile .c -shlib.c -dw.S
+
+# Test with both a .debug_ranges section (DWARF 4) and a .debug_rnglists
+# section (DWARF 5).
+
+foreach_with_prefix ranges_sect {ranges rnglists} {
+ set asm_file [standard_output_file ${ranges_sect}-$srcfile3]
+
+ if { $ranges_sect == "ranges" } {
+ Dwarf::assemble $asm_file {
+ global srcdir subdir srcfile2
+ declare_labels ranges_label
+
+ cu {} {
+ compile_unit {
+ {language @DW_LANG_C}
+ {name $srcfile2}
+ {ranges ${ranges_label} DW_FORM_sec_offset}
+ } {
+ subprogram {
+ {external 1 flag}
+ {name foo}
+ }
+ }
+ }
+
+ ranges {is_64 [is_64_target]} {
+ ranges_label: sequence {
+ base 0
+ range 0 1
+ }
+ }
+ }
+ } elseif { $ranges_sect == "rnglists" } {
+ Dwarf::assemble $asm_file {
+ global srcdir subdir srcfile2
+ declare_labels rnglists_label
+
+ cu {
+ version 5
+ } {
+ compile_unit {
+ {language @DW_LANG_C}
+ {name $srcfile2}
+ {ranges ${rnglists_label} DW_FORM_sec_offset}
+ } {
+ subprogram {
+ {external 1 flag}
+ {name foo}
+ }
+ }
+ }
+
+ rnglists {
+ table {
+ rnglists_label: list_ {
+ start_end 0 1
+ }
+ }
+ }
+ }
+ } else {
+ error "invalid ranges section kind"
+ }
+
+ set lib1 [standard_output_file shr1.sl]
+ set lib_opts "nodebug"
+
+ set sources [list ${srcdir}/${subdir}/$srcfile2 $asm_file]
+ if { [gdb_compile_shlib $sources ${lib1} $lib_opts] != "" } {
+ untested "failed to compile"
+ return -1
+ }
+
+ set exec_opts [list debug shlib=${lib1}]
+ set sources ${srcdir}/${subdir}/${srcfile}
+ if { [gdb_compile $sources ${binfile} executable \
+ $exec_opts] != ""} {
+ untested "failed to compile"
+ return -1
+ }
+
+ clean_restart $binfile
+
+ set readnow_p [readnow]
+
+ # Don't load the symbols for $lib1 during runto_main.
+ # Instead, we do this afterwards using "sharedlibrary $lib1".
+ gdb_test_no_output "set auto-solib-add off"
+
+ if { ![runto_main] } {
+ fail "cannot run to main."
+ return -1
+ }
+
+ set complaint_re ".debug_${ranges_sect} entry has start address of zero"
+ set re \
+ "During symbol reading: $complaint_re \\\[in module \[^\r\n\]*\\\]"
+
+ # Test for presence of complaint, with lib1 relocated.
+ with_complaints 1 {
+ set test "Zero address complaint - relocated - psymtab"
+ set have_complaint 0
+ gdb_test_multiple "sharedlibrary $lib1" $test {
+ -re -wrap $re {
+ set have_complaint 1
+ }
+ -re -wrap "" {
+ }
+ }
+
+ if { $have_complaint } {
+ pass $test
+ } else {
+ set index [have_index $lib1]
+ if { $index == "gdb_index" } {
+ kfail symtab/28159 $test
+ } else {
+ fail $test
+ }
+ }
+ }
+
+ if { ! $readnow_p } {
+ with_complaints 1 {
+ gdb_test "maint expand-symtabs $srcfile2" $re \
+ "Zero address complaint - relocated - symtab"
+ }
+ }
+
+ clean_restart
+ # Test for presence of complaint, with lib1 unrelocated.
+ with_complaints 1 {
+ gdb_load $lib1
+ set test "Zero address complaint - unrelocated - psymtab"
+ set have_complaint [regexp $re.* $gdb_file_cmd_msg]
+ if { $have_complaint } {
+ pass $test
+ } else {
+ set index [have_index $lib1]
+ if { $index == "gdb_index" } {
+ kfail symtab/28159 $test
+ } else {
+ fail $test
+ }
+ }
+ }
+
+ if { ! $readnow_p } {
+ with_complaints 1 {
+ gdb_test "maint expand-symtabs $srcfile2" $re \
+ "Zero address complaint - unrelocated - symtab"
+ }
+ }
+}