[llvm-readobj] Fix/improve printing WinEH unwind info for linked PE images
authorMartin Storsjö <martin@martin.st>
Mon, 25 Nov 2019 13:26:13 +0000 (15:26 +0200)
committerMartin Storsjö <martin@martin.st>
Wed, 11 Dec 2019 08:20:34 +0000 (10:20 +0200)
commitaf39708c2d48beedc6721fe25676789cc6719f7b
tree74a56c0042818cb0fef4e71fd2077978ae235c1c
parentf99297176cd9507393b69029406080de01ae41c7
[llvm-readobj] Fix/improve printing WinEH unwind info for linked PE images

ARMWinEHPrinter was already designed to handle linked PE images
(since d2941b43f40d), but resolving symbols didn't consistently
take the image base into account (as linked images seldom have a
symbol table, except for in MinGW setups).

Win64EHDumper wasn't really designed to handle linked images (it would
crash if executed on such a file), but a few concepts (getSymbol,
taking a virtual address instead of a relocation, and
getSectionContaining for finding the section containing a certain
virtual address) can be borrowed from ARMWinEHPrinter.

Adjust ARMWinEHPrinter to print the address of the exception handler
routine as a VA instead of an RVA, consistently with other addresses
in the same printout, and make Win64EHDumper print addresses similarly
for image cases.

Differential Revision: https://reviews.llvm.org/D71303
llvm/test/tools/llvm-readobj/COFF/lit.local.cfg [new file with mode: 0644]
llvm/test/tools/llvm-readobj/COFF/unwind-arm64-image.yaml [new file with mode: 0644]
llvm/test/tools/llvm-readobj/COFF/unwind-x86_64-image.yaml [new file with mode: 0644]
llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
llvm/tools/llvm-readobj/Win64EHDumper.cpp