[PATCH] D44202: [DebugInfo/AccelTable] Fix inconsistency in getDIEOffset implementations

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 7 04:42:06 PST 2018


labath created this revision.
labath added reviewers: JDevlieghere, dblaikie.
Herald added a subscriber: aprantl.

Even though the getDIEOffset offset function was common for the two
accelerator table implementations, it was doing two different things:
for the Apple tables, it was returning the die offset relative to the
start of the section, whereas for DWARF v5 tables, it was relative to
the start of the CU.

I resolve this by renaming the function to getDIESectionOffset to make
it obvious what the function returns, and change the DWARF
implementation to return the section offset. I also keep the CU-relative
accessor, but only in the DWARF implementation (there is no way to get
this information for the Apple tables). This was not caught by existing
tests because the hand-written inputs also erroneously used section
offsets instead of CU-relative ones.

While looking at this, I noticed that the Apple implementation was not
fully correct either -- the header contains a DIEOffsetBase field, which
should be added to all offsets (but it wasn't being used). This went unnoticed
because all current writers set this field to zero anyway. I fix this as well
and add a hand-written test which demonstrates the issue.


Repository:
  rL LLVM

https://reviews.llvm.org/D44202

Files:
  include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
  lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
  test/tools/llvm-dwarfdump/X86/apple-names-die-offset.s
  test/tools/llvm-dwarfdump/X86/debug-names-find.s
  tools/llvm-dwarfdump/llvm-dwarfdump.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44202.137363.patch
Type: text/x-patch
Size: 9696 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180307/734c348e/attachment.bin>


More information about the llvm-commits mailing list