[dsymutil] Account for DW_OP_convert being CU relative
authorJonas Devlieghere <jonas@devlieghere.com>
Tue, 12 Jul 2022 21:18:19 +0000 (14:18 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Tue, 12 Jul 2022 22:03:15 +0000 (15:03 -0700)
commit7f3000fa8b321f7fae169a615734de74a737b5d4
treea6eb003a44150a06f39433d177d94d79e38d53dd
parent61ace8f78b1c52fd63fc8c2d800f08d7ddd87b0d
[dsymutil] Account for DW_OP_convert being CU relative

Currently, dsymutil treats the DW_OP_convert operand as absolute instead
of CU relative, as described by in the DWARFv5 spec, 2.5.1.6:

  "[DW_OP_convert] takes one operand, which is an unsigned LEB128 integer
  that represents the offset of a debugging information entry in the current
  compilation unit"

This patch makes dsymutil correctly treat the offset as CU relative,
preventing a crash when there are multiple compilation units.

Big thanks to Akira Hatanaka for figuring out this issue and providing
both a reduced test case and a proposed fix.
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/test/tools/dsymutil/Inputs/private/tmp/op-convert-offset/op-convert-offset [new file with mode: 0755]
llvm/test/tools/dsymutil/Inputs/private/tmp/op-convert-offset/op-convert-offset.o [new file with mode: 0644]
llvm/test/tools/dsymutil/X86/op-convert-offset.test [new file with mode: 0644]