This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] Fix .debug_macro NOBITS crash (PR 14494)
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Sat, 18 Aug 2012 18:57:03 +0200
- Subject: [patch] Fix .debug_macro NOBITS crash (PR 14494)
Hi,
http://sourceware.org/bugzilla/show_bug.cgi?id=14494
libc-2.16.so.debug:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[...]
[12] .text NOBITS 000000000001f180 0002c0 143be0 00 AX 0 0 16
[...]
[33] .comment NOBITS 0000000000000000 0002c0 000011 01 MS 0 0 1
[34] .debug_aranges PROGBITS 0000000000000000 0002c0 011950 00 0 0 16
[35] .debug_info PROGBITS 0000000000000000 011c10 4279b3 00 0 0 1
[36] .debug_abbrev PROGBITS 0000000000000000 4395c3 093c0b 00 0 0 1
[37] .debug_line PROGBITS 0000000000000000 4cd1ce 33e348 00 0 0 1
[38] .debug_frame PROGBITS 0000000000000000 80b518 018688 00 0 0 8
[39] .debug_str PROGBITS 0000000000000000 823ba0 09443b 01 MS 0 0 1
[40] .debug_loc PROGBITS 0000000000000000 8b7fdb 278c8e 00 0 0 1
[41] .debug_ranges PROGBITS 0000000000000000 b30c70 05b320 00 0 0 16
[42] .debug_macro NOBITS 0000000000000000 b8bf90 24c528 00 0 0 1
[...]
GDB does not check NOBITS for .debug_macro, tries to interpret them and crashes
as there is no memory mapped by BFD for the section.
Tried a reproducer but it was not successful, it depends random way on from
where GDB tries to read the .debug_macro section.
No regressions on {x86_64,x86_64-m32,i686}-fedora18-linux-gnu.
Thanks,
Jan
gdb/
2012-08-18 Jan Kratochvil <jan.kratochvil@redhat.com>
* dwarf2read.c (dwarf2_locate_sections): Move variable aflag here.
Move the SEC_HAS_CONTENTS check here - for any NAMES use.
(dwarf2_locate_sections) <eh_frame>: Move the variable and check from
here.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 099b67a..da6e87a 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1710,13 +1710,18 @@ static void
dwarf2_locate_sections (bfd *abfd, asection *sectp, void *vnames)
{
const struct dwarf2_debug_sections *names;
+ flagword aflag = bfd_get_section_flags (abfd, sectp);
if (vnames == NULL)
names = &dwarf2_elf_names;
else
names = (const struct dwarf2_debug_sections *) vnames;
- if (section_is_p (sectp->name, &names->info))
+ if ((aflag & SEC_HAS_CONTENTS) == 0)
+ {
+ /* Such section is not usable for the purpose of NAMES. */
+ }
+ else if (section_is_p (sectp->name, &names->info))
{
dwarf2_per_objfile->info.asection = sectp;
dwarf2_per_objfile->info.size = bfd_get_section_size (sectp);
@@ -1763,13 +1768,8 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *vnames)
}
else if (section_is_p (sectp->name, &names->eh_frame))
{
- flagword aflag = bfd_get_section_flags (abfd, sectp);
-
- if (aflag & SEC_HAS_CONTENTS)
- {
- dwarf2_per_objfile->eh_frame.asection = sectp;
- dwarf2_per_objfile->eh_frame.size = bfd_get_section_size (sectp);
- }
+ dwarf2_per_objfile->eh_frame.asection = sectp;
+ dwarf2_per_objfile->eh_frame.size = bfd_get_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->ranges))
{