This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] Fix has_section_at_zero for separate debug files
- From: Tristan Gingold <gingold at ACT-Europe dot FR>
- To: gdb-patches at sourceware dot org
- Cc: kevinb at redhat dot com
- Date: Thu, 7 Jan 2010 14:09:18 +0100
- Subject: [RFA] Fix has_section_at_zero for separate debug files
Hi,
this patch reconsiders the approach taken in
http://sourceware.org/ml/gdb-patches/2009-06/msg00116.html
The new problem is that has_section_at_zero is now wrongly cleared. This
happens when the separate debug file is a relocatable file (such as on
Darwin) which may have a function at address 0. If its backlink (ie the
executable) has no section at 0 (which is the rule), one or more symbols
disappear in the symtab.
Because a separate debug file may be completely unrelated (in terms of
mapping) from its backlink, we shouldn't try to copy the has_section_at_zero.
Instead, we also consider SEC_ALLOC sections to set has_section_at_zero. This
makes sense because you may perfectly have the bss at zero.
No regression on GNU Linux i386.
I have also checked this patch which a tiny program having a section at 0
and run in qemu.
(I cc: Kevin Buettner, the author of the previous approach).
Tristan.
2010-01-07 Tristan Gingold <gingold@adacore.com>
* dwarf2read.c (dwarf2_locate_sections): Also consider SEC_ALLOC
sections to set has_section_at_zero.
(dwarf2_psymtab_to_symtab): Do not copy has_section_at_zero from
backlink for separate debug file.
---
gdb/dwarf2read.c | 15 +--------------
1 files changed, 1 insertions(+), 14 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 7623035..7dbe02f 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1258,7 +1258,7 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr)
dwarf2_per_objfile->types.size = bfd_get_section_size (sectp);
}
- if ((bfd_get_section_flags (abfd, sectp) & SEC_LOAD)
+ if ((bfd_get_section_flags (abfd, sectp) & (SEC_LOAD | SEC_ALLOC))
&& bfd_section_vma (abfd, sectp) == 0)
dwarf2_per_objfile->has_section_at_zero = 1;
}
@@ -2994,19 +2994,6 @@ dwarf2_psymtab_to_symtab (struct partial_symtab *pst)
dwarf2_per_objfile = objfile_data (pst->objfile,
dwarf2_objfile_data_key);
- /* If this psymtab is constructed from a debug-only objfile, the
- has_section_at_zero flag will not necessarily be correct. We
- can get the correct value for this flag by looking at the data
- associated with the (presumably stripped) associated objfile. */
- if (pst->objfile->separate_debug_objfile_backlink)
- {
- struct dwarf2_per_objfile *dpo_backlink
- = objfile_data (pst->objfile->separate_debug_objfile_backlink,
- dwarf2_objfile_data_key);
- dwarf2_per_objfile->has_section_at_zero
- = dpo_backlink->has_section_at_zero;
- }
-
psymtab_to_symtab_1 (pst);
/* Finish up the debug error message. */
--
1.6.5.rc2