[CFGuard] Add address-taken IAT tables and delay-load support
authorAndrew Paverd <andrew.paverd@microsoft.com>
Thu, 1 Oct 2020 09:07:40 +0000 (10:07 +0100)
committerDavid Chisnall <David.Chisnall@microsoft.com>
Thu, 1 Oct 2020 11:45:07 +0000 (12:45 +0100)
commitef4e971e5e18ae796466623df8f26265ba6bdfb5
treefbe0513ea96471d4cc405b17f63708833eaeb6d9
parentfcf70e1e3b1d57d5fde6b99d0188d1b1774429af
[CFGuard] Add address-taken IAT tables and delay-load support

This patch adds support for creating Guard Address-Taken IAT Entry Tables (.giats$y sections) in object files, matching the behavior of MSVC. These contain lists of address-taken imported functions, which are used by the linker to create the final GIATS table.
Additionally, if any DLLs are delay-loaded, the linker must look through the .giats tables and add the respective load thunks of address-taken imports to the GFIDS table, as these are also valid call targets.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D87544
12 files changed:
lld/COFF/DLL.cpp
lld/COFF/ICF.cpp
lld/COFF/InputFiles.cpp
lld/COFF/InputFiles.h
lld/COFF/Symbols.h
lld/COFF/Writer.cpp
lld/test/COFF/giats.s [new file with mode: 0644]
llvm/include/llvm/MC/MCObjectFileInfo.h
llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
llvm/lib/MC/MCObjectFileInfo.cpp
llvm/test/CodeGen/WinCFGuard/cfguard-giats.ll [new file with mode: 0644]
llvm/tools/llvm-readobj/COFFDumper.cpp