[AppleAccelTable] Keep track of the size of each hash data entry
authorFelipe de Azevedo Piovezan <fpiovezan@apple.com>
Sat, 3 Jun 2023 11:23:16 +0000 (07:23 -0400)
committerFelipe de Azevedo Piovezan <fpiovezan@apple.com>
Thu, 8 Jun 2023 18:20:54 +0000 (14:20 -0400)
commitc1059dcb1c88405bff4d3ceaa58af22c2f8c536e
tree5f2b15d13dfe46f9a65b9fa37c722a1eff593695
parent715726429ec4fc4f0f5f0f2e3dc6c3c31ce8f3a6
[AppleAccelTable] Keep track of the size of each hash data entry

In a future patch, it will be desirable to skip over all hash data entries for a
particular string. In order to do so, we must know how many bytes each of those
entries have.

In its full specification, Apple tables allow for variable length entries, which
would make the above impossible without reading the data of each entry. However,
this is largely unsupported today (as a FIXME in the code indicates, there is a
bug with hash collisions exactly because we don't know how to skip over data),
and the documentation[1] states that:

> For the current implementations of the “.apple_names” (all functions +
> globals), the “.apple_types” (names of all types that are defined), and the
> “.apple_namespaces” (all namespaces), we currently set the Atom array to be:
> [...]
> This defines the contents to be the DIE offset (eAtomTypeDIEOffset) that is
> encoded as a 32 bit value (DW_FORM_data4).

In other words, we only produce fixed sized entries.

A few tests containing invalid dwarf had to be updated, as the error is now
detected earlier (when the accelerator table is being parsed, instead of inside
the explicit call to "verify").

[1]: https://llvm.org/docs/SourceLevelDebugging.html#fixed-lookup

Depends on D152156

Differential Revision: https://reviews.llvm.org/D152157
llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
llvm/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test
llvm/test/tools/dsymutil/X86/basic-lto-linking-x86.test
llvm/test/tools/dsymutil/X86/objc.test
llvm/test/tools/llvm-dwarfdump/X86/apple_names_verify_form.s