[PATCH] D133099: [LLD][COFF] Add load config checks to warn if incorrect for CFGuard

Alvin Wong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 01:40:45 PDT 2022


alvinhochun created this revision.
alvinhochun added reviewers: rnk, mstorsjo.
Herald added a project: All.
alvinhochun requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Control Flow Guard requires specific flags and VA's be included in the
load config directory to be functional. In case CFGuard is enabled via
linker flags, we can check to make sure this is the case and give the
user a warning if otherwise.

MSVC provides a proper `_load_config_used` by default, so this is more
relevant for the MinGW target in which current versions of mingw-w64
does not provide this symbol.

The checks (only if CFGuard is enabled) include:

- The `_load_config_used` struct shall exist.
- Alignment of the `_load_config_used` struct (shall be aligned to pointer size.)
- The `_load_config_used` struct shall be large enough to contain the required fields.
- The values of the following fields are checked against the expected values:
  - GuardCFFunctionTable
  - GuardCFFunctionCount
  - GuardFlags
  - GuardAddressTakenIatEntryTable
  - GuardAddressTakenIatEntryCount
  - GuardLongJumpTargetTable
  - GuardLongJumpTargetCount
  - GuardEHContinuationTable
  - GuardEHContinuationCount


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133099

Files:
  lld/COFF/Writer.cpp
  lld/test/COFF/guard-warnings.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133099.457200.patch
Type: text/x-patch
Size: 13019 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220901/88840fc2/attachment.bin>


More information about the llvm-commits mailing list