mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-25 21:41:47 +08:00
Don't crash if dwarf_decode_macro_bytes's 'body' is NULL
Hi, Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192 https://bugzilla.redhat.com/show_bug.cgi?id=1708786 During the Fedora RPM build process, gdb-add-index is invoked to extract the DWARF index from the binary, and GDB will segfault because dwarf2read.c:parse_definition_macro's 'body' variable is NULL. The underlying problem is that Fedora's rpm-build's "debugedit" program will silently corrupt .debug_macro strings when a binary is compiled with -g3. This is being taken care of by Mark Wielaard, here: https://bugzilla.redhat.com/show_bug.cgi?id=1708786 However, I still feel it's important to make GDB more resilient against invalid DWARF input, so I'm proposing this rather simple patch to catch the situation when "body == NULL" (i.e., it's probably been corrupted) and issue a complaint. This is not a real fix to the problem, of course, but at least GDB is able to finish without segfaulting. OK for master? gdb/ChangeLog: 2019-05-15 Sergio Durigan Junior <sergiodj@redhat.com> Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192 * dwarf2read.c (dwarf_decode_macro_bytes): Check whether 'body' is NULL, and complain if that's the case.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2019-05-15 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||||
|
|
||||||
|
Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192
|
||||||
|
* dwarf2read.c (parse_macro_definition): Check whether 'body' is
|
||||||
|
NULL, and complain/return if that's the case.
|
||||||
|
|
||||||
2019-05-15 John Darrington <john@darrington.wattle.id.au>
|
2019-05-15 John Darrington <john@darrington.wattle.id.au>
|
||||||
|
|
||||||
* s12z-tdep.c (push_pull_get_stack_adjustment): New function.
|
* s12z-tdep.c (push_pull_get_stack_adjustment): New function.
|
||||||
|
@ -24609,7 +24609,24 @@ dwarf_decode_macro_bytes (struct dwarf2_cu *cu,
|
|||||||
line == 0 ? _("zero") : _("non-zero"), line, body);
|
line == 0 ? _("zero") : _("non-zero"), line, body);
|
||||||
|
|
||||||
if (is_define)
|
if (is_define)
|
||||||
|
{
|
||||||
|
if (body != NULL)
|
||||||
parse_macro_definition (current_file, line, body);
|
parse_macro_definition (current_file, line, body);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Fedora's rpm-build's "debugedit" binary
|
||||||
|
corrupted .debug_macro sections.
|
||||||
|
|
||||||
|
For more info, see
|
||||||
|
https://bugzilla.redhat.com/show_bug.cgi?id=1708786 */
|
||||||
|
complaint (_("debug info gives %s invalid macro definition "
|
||||||
|
"without body (corrupted?) at line %d"
|
||||||
|
"on file %s"),
|
||||||
|
at_commandline ? _("command-line")
|
||||||
|
: _("in-file"),
|
||||||
|
line, current_file->filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gdb_assert (macinfo_type == DW_MACRO_undef
|
gdb_assert (macinfo_type == DW_MACRO_undef
|
||||||
|
Reference in New Issue
Block a user