summaryrefslogtreecommitdiffstats
path: root/docs/ScudoHardenedAllocator.rst
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-08-02 22:25:38 +0000
committerKostya Serebryany <kcc@google.com>2016-08-02 22:25:38 +0000
commit2ca02f6ea0a909c6a8e772a429ea50224d687f15 (patch)
treef8a4319d0570f990dae74ec100e088c149f05cb5 /docs/ScudoHardenedAllocator.rst
parent94166e75acd506c420708c8d335ccf47beb76484 (diff)
[sanitizer] Implement a __asan_default_options() equivalent for Scudo
Summary: Currently, the Scudo Hardened Allocator only gets its flags via the SCUDO_OPTIONS environment variable. With this patch, we offer the opportunity for programs to define their own options via __scudo_default_options() which behaves like __asan_default_options() (weak symbol). A relevant test has been added as well, and the documentation updated accordingly. I also used this patch as an opportunity to rename a few variables to comply with the LLVM naming scheme, and replaced a use of Report with dieWithMessage for consistency (and to avoid a callback). Reviewers: llvm-commits, kcc Differential Revision: https://reviews.llvm.org/D23018 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277536 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/ScudoHardenedAllocator.rst')
-rw-r--r--docs/ScudoHardenedAllocator.rst29
1 files changed, 26 insertions, 3 deletions
diff --git a/docs/ScudoHardenedAllocator.rst b/docs/ScudoHardenedAllocator.rst
index 5bc390eadd5c..2c8493a6c2bd 100644
--- a/docs/ScudoHardenedAllocator.rst
+++ b/docs/ScudoHardenedAllocator.rst
@@ -89,10 +89,33 @@ functions.
Options
-------
-Several aspects of the allocator can be configured through environment options,
-following the usual ASan options syntax, through the variable SCUDO_OPTIONS.
+Several aspects of the allocator can be configured through the following ways:
+
+- by defining a __scudo_default_options function in one's program that returns
+ the options string to be parsed. Said function must have the following
+ prototype: ``extern "C" const char* __scudo_default_options()``.
+
+- through the environment variable SCUDO_OPTIONS, containing the options string
+ to be parsed. Options defined this way will override any definition made
+ through __scudo_default_options;
+
+The options string follows a syntax similar to ASan, where distinct options
+can be assigned in the same string, separated by colons.
+
+For example, using the environment variable:
+
+.. code::
+
+ SCUDO_OPTIONS="DeleteSizeMismatch=1:QuarantineSizeMb=16" ./a.out
+
+Or using the function:
+
+.. code::
+
+ extern "C" const char *__scudo_default_options() {
+ return "DeleteSizeMismatch=1:QuarantineSizeMb=16";
+ }
-For example: SCUDO_OPTIONS="DeleteSizeMismatch=1:QuarantineSizeMb=16".
The following options are available: