This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

DIE with abbrev 0 behaves as if it had abbrev 1 on re-request


Hi,

this, too, came up during my automated garbage generation.  In this file
the abbrev code of CU DIE was changed to zero.  libdw is then used thus:

  die = dwarf_offdie (dw, 11, &die_mem);
  assert (dwarf_tag (die) == 0);

  die = dwarf_offdie (dw, 11, &die_mem);
  assert (dwarf_tag (die) != 0);

Surprisingly, this actually passes.  When we ask for dwarf_tag the first
time around, __libdw_findabbrev looks for abbrev with code 0, and
doesn't find it.  It then proceeds with loading .debug_abbrev, looking
at each abbrev in turn, and obviously it won't find the one numbered 0.

Then __libdw_findabbrev asks for code 0 again.  But
Dwarf_Abbrev_Hash_insert contains these lines

  /* Make the hash value nonzero.  */
  hval = hval ?: 1;

So it goes on to look for abbrev with code 1 instead, and because
.debug_abbrev has been loaded by now, it of course finds it.

I don't advocate supporting arbitrarily broken DWARF files, but this
inconsistency seems worth a fix.  Mine is on pmachata/findabbrev_0.

Thanks,
PM

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]