[PATCH] D138337: Add support for kcfi-seal optimization with LTO

Sami Tolvanen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 18 16:14:30 PST 2022


samitolvanen created this revision.
Herald added subscribers: pengfei, hiraditya, inglorion.
Herald added a project: All.
samitolvanen requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

With -fsanitize=kcfi, Clang emits a !kcfi_type attribute for all global
functions, making them valid indirect call targets, whether the program
ends up calling them indirectly or not. With LTO, we can "seal" the
program by dropping types from non-address-taken globals, thus limiting
the possible targets that can be called.

Add -fsanitize-kcfi-seal command line flag to Clang that's only allowed
with -flto, and drop types from non-address-taken globals in AsmPrinter
when the kcfi-seal module attribute is set.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138337

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/kcfi.c
  clang/test/Driver/fsanitize.c
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/test/CodeGen/X86/kcfi-seal.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138337.476626.patch
Type: text/x-patch
Size: 9185 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221119/fffbddff/attachment.bin>


More information about the cfe-commits mailing list