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).
Details
Diff Detail
Event Timeline
Is your choice of the name (getScudoDefaultOptions, w/o "") deliberate?
With you are guaranteed that no user code will have such a name since __ names are reserved for the implementation.
With getScudoDefaultOptions you don't have such guarantee.
Otherwise LG
I couldn't find anything in the coding standards (http://llvm.org/docs/CodingStandards.html) that was covering this case, so I went with the default naming for a function.
If that's acceptable to prefix with __, then I am all for it!
I think it *has* to be prefixed with __ to avoid clashing with user code (according to the C++ standard, afiact, user functions can not start with )
For consistency with asan's asan_default_options, I would call it __scudo_default_options.
(We already broke the consistency a bit by using CamelCase in the names of options)
Diff updated with changes to the documentation. __scudo_default_options is now the name of the weak symbol used for options.
Additionally, using this as a vehicle to remove a use of Report in CheckFailed that was inconsistent with the rest, for the preferred dieWithMessage (this will be needed for the new Printf).
/code/llvm/projects/compiler-rt/lib/scudo/scudo_termination.cpp:40:1: error: function declared 'noreturn' should not return [-Werror,-Winvalid-noreturn]
}
^
1 error generated.
Please test with LLVM_ENABLE_WERROR.