Dwarf: Don't add nameless modules to partial symbol table
authorBernhard Heckel <bernhard.heckel@intel.com>
Wed, 27 Feb 2019 14:21:12 +0000 (15:21 +0100)
committerPedro Alves <palves@redhat.com>
Tue, 11 Jun 2019 18:20:09 +0000 (19:20 +0100)
commita5fd13a91534b1c79a4b61995894a5bb4f08d3b0
treeccca118c9784175d6a3a5f27f9f26c9c16079eb0
parent2057d69dccf36206be3bec5d48ff165621e9a06c
Dwarf: Don't add nameless modules to partial symbol table

A name for BLOCK DATA in Fortran is optional.  If no name has been
assigned, GDB crashes during read-in of DWARF when BLOCK DATA is
represented via DW_TAG_module.  BLOCK DATA is used for one-time
initialization of non-pointer variables in named common blocks.

As of now there is no issue when gfortran is used as DW_TAG_module is
not emitted.  However, with Intel ifort the nameless DW_TAG_module is
present and has the following form:

 ...
  <1><dd>: Abbrev Number: 7 (DW_TAG_module)
     <de>   DW_AT_decl_line   : 46
     <df>   DW_AT_decl_file   : 1
     <e0>   DW_AT_description : (indirect string, offset: 0x110): block
 data
     <e4>   DW_AT_high_pc     : 0x402bb7
     <ec>   DW_AT_low_pc      : 0x402bb7
 ...

The missing name leads to a crash in add_partial_symbol, during length
calculation.

gdb/ChangeLog:
2019-06-11  Bernhard Heckel  <bernhard.heckel@intel.com>

* dwarf2read.c (add_partial_symbol): Skip nameless modules.

gdb/testsuite/Changelog:
2019-06-11  Bernhard Heckel  <bernhard.heckel@intel.com>

* gdb.fortran/block-data.f: New.
* gdb.fortran/block-data.exp: New.
gdb/dwarf2read.c
gdb/testsuite/gdb.fortran/block-data.exp [new file with mode: 0644]
gdb/testsuite/gdb.fortran/block-data.f [new file with mode: 0644]