[PATCH] Don't handle blocks as exprlocs for DWARF version 4 or higher.

Jakub Jelinek jakub@redhat.com
Thu Feb 18 14:09:47 GMT 2021


On Thu, Feb 18, 2021 at 02:40:36PM +0100, Mark Wielaard wrote:
> On Sat, 2021-02-13 at 23:46 +0100, Mark Wielaard wrote:
> > Since DWARF version 4 blocks just contain bytes, trying to interpret
> > them as exprlocs will most likely fail.
> > 
> >      * dwz.c (add_locexpr_dummy_dies): Only handle block as exprloc
> >      for cu_version < 4.
> >      (checksum_die): Likewise.
> >      (write_die): Likewise.
> > 
> > https://sourceware.org/bugzilla/show_bug.cgi?id=26987
> 
> Ping. Any comments?

Doing some GCC archeology if it is safe, I think it principially ok, but I'd
like slightly different patch, see below.
While -gdwarf-4 support has been added in
https://gcc.gnu.org/r0-96109-g15b3fbeb7e97f2ca3731881bf3a0f899ec56ebbf
during GCC 4.5 development, it was still emitting DWARF 3 .debug_info
headers and not using DW_FORM_exprloc.
DW_FORM_exprloc came with:
https://gcc.gnu.org/r0-99103-g290d8971e6e3b784a88b5c4b6b91b8d77552cb3a
and DWARF version .debug_info header changed from 3 to 4 for -gdwarf-4
a day after that:
https://gcc.gnu.org/r0-99139-g2f43d500a6769e563fb8f645e7530c2f144d7023

> > +++ b/dwz.c
> > @@ -2913,43 +2913,44 @@ add_locexpr_dummy_dies (DSO *dso, dw_cu_ref
> > cu, dw_die_ref die,
> >    if (form == DW_FORM_block1)
> >      {
> >        /* Old DWARF uses blocks instead of exprlocs.  */

Instead of reindenting everything, can't you simply change
-  if (form == DW_FORM_block1)
+  if (form == DW_FORM_block1 && cu->cu_version < 4)

> >        if (form == DW_FORM_block1)

And likewise here:
-      if (form == DW_FORM_block1)
+      if (form == DW_FORM_block1 && cu->cu_version < 4)

> > @@ -12392,7 +12394,7 @@ write_die (unsigned char *ptr, dw_cu_ref cu,
> > dw_die_ref die,
> >  	  ptr += inptr - orig_ptr;
> >  
> >  	  /* Old DWARF uses blocks instead of exprlocs.  */
> > -	  if (form == DW_FORM_block1)
> > +	  if (form == DW_FORM_block1 && cu->cu_version < 4)

Like you've done it here?

> >  	    switch (reft->attr[i].attr)
> >  	      {
> >  	      case DW_AT_frame_base:

	Jakub



More information about the Dwz mailing list