[PATCH] D101122: introduce flag -fsanitize-address-detect-stack-use-after-return-mode. No functional change.
Kevin Athey via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 22 17:47:08 PDT 2021
kda created this revision.
kda added a reviewer: vitalybuka.
Herald added subscribers: jansvoboda11, dexonsmith, dang.
kda requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.
introduce flag -fsanitize-address-detect-stack-use-after-return-mode. No functional change.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D101122
Files:
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
Index: llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
===================================================================
--- llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
+++ llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h
@@ -20,5 +20,16 @@
Invalid, ///< Not a valid destructor Kind.
// TODO(dliew): Add more more kinds.
};
+
+/// Modes of ASan detect stack use after return
+enum class AsanDetectStackUseAfterReturnMode {
+ Always, ///< Always detect stack use after return.
+ Runtime, ///< Detect stack use after return if runtime flag is enabled
+ ///< (ASAN_OPTIONS=detect_stack_use_after_return=1)
+ Never, ///< Never detect stack use after return.
+ Invalid, ///< Not a valid detect mode.
+};
+
} // namespace llvm
+
#endif
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1544,6 +1544,16 @@
NormalizedValuesScope<"llvm::AsanDtorKind">,
NormalizedValues<["None", "Global"]>,
MarshallingInfoEnum<CodeGenOpts<"SanitizeAddressDtorKind">, "Global">;
+def sanitize_address_detect_stack_use_after_return_mode_EQ
+ : Joined<["-"], "fsanitize-address-detect-stack-use-after-return-mode=">,
+ MetaVarName<"<mode>">,
+ Flags<[CC1Option]>,
+ HelpText<"Select the enabling method of detect-stack-use-after-return in AddressSanitizer">,
+ Group<f_clang_Group>,
+ Values<"always,runtime,never">,
+ NormalizedValuesScope<"llvm::AsanDetectStackUseAfterReturnMode">,
+ NormalizedValues<["Always", "Runtime", "Never"]>,
+ MarshallingInfoEnum<CodeGenOpts<"SanitizeAddressDetectStackUseAfterReturnMode">, "Runtime">;
// Note: This flag was introduced when it was necessary to distinguish between
// ABI for correct codegen. This is no longer needed, but the flag is
// not removed since targeting either ABI will behave the same.
Index: clang/include/clang/Basic/CodeGenOptions.def
===================================================================
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -222,6 +222,10 @@
ENUM_CODEGENOPT(SanitizeAddressDtorKind, llvm::AsanDtorKind, 2,
llvm::AsanDtorKind::Global) ///< Set how ASan global
///< destructors are emitted.
+ENUM_CODEGENOPT(SanitizeAddressDetectStackUseAfterReturnMode,
+ llvm::AsanDetectStackUseAfterReturnMode, 2,
+ llvm::AsanDetectStackUseAfterReturnMode::Runtime
+ ) ///< Set detection mode for stack-use-after-return.
CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete detection
///< in MemorySanitizer
CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101122.339829.patch
Type: text/x-patch
Size: 2992 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210423/ef22e0d9/attachment.bin>
More information about the cfe-commits
mailing list