[DebugInfo/AccelTable] Fix inconsistency in getDIEOffset implementations
authorPavel Labath <labath@google.com>
Fri, 9 Mar 2018 11:58:59 +0000 (11:58 +0000)
committerPavel Labath <labath@google.com>
Fri, 9 Mar 2018 11:58:59 +0000 (11:58 +0000)
commit47c3472c412b79ccd9df9b1461910127df0d1d97
treeb93db1b74fed238fe1d506f143e883f8a142044b
parent893cbc25fb29d2f6fd59354206e677cc43a2206d
[DebugInfo/AccelTable] Fix inconsistency in getDIEOffset implementations

Summary:
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 offsets encoded with the DW_FORM_ref*** family, but
this was not 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.

Reviewers: JDevlieghere, dblaikie

Subscribers: aprantl, llvm-commits

Differential Revision: https://reviews.llvm.org/D44202

llvm-svn: 327116
llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
llvm/test/tools/llvm-dwarfdump/X86/apple-names-die-offset-data.s [new file with mode: 0644]
llvm/test/tools/llvm-dwarfdump/X86/apple-names-die-offset-ref.s [new file with mode: 0644]
llvm/test/tools/llvm-dwarfdump/X86/debug-names-find.s
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp