summaryrefslogtreecommitdiff
path: root/lib/ubsan/ubsan_flags.cc
AgeCommit message (Collapse)Author
2017-11-09ubsan: Allow programs to use setenv to configure ubsan_standalone.Peter Collingbourne
Previously ubsan_standalone used the GetEnv function to read the environment variables UBSAN_OPTIONS and UBSAN_SYMBOLIZER_PATH. The problem with GetEnv is that it does not respect changes to the environment variables made using the libc setenv function, which prevents clients from setting environment variables to configure ubsan before loading ubsan-instrumented libraries. The reason why we have GetEnv is that some runtimes need to read environment variables while they initialize using .preinit_array, and getenv does not work while .preinit_array functions are being called. However, it is unnecessary for ubsan_standalone to initialize that early. So this change switches ubsan_standalone to using getenv and removes the .preinit_array entry. The static version of the runtime still ends up being initialized using a C++ constructor that exists to support the shared runtime. Differential Revision: https://reviews.llvm.org/D39827 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317757 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19Let ubsan search UBSAN_SYMBOLIZER_PATH for llvm-symbolizerNico Weber
https://reviews.llvm.org/D27375 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@300692 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-29General definition for weak functionsMarcos Pividori
In this diff, I define a general macro for defining weak functions with a default implementation: "SANITIZER_INTERFACE_WEAK_DEF()". This way, we simplify the implementation for different platforms. For example, we cannot define weak functions on Windows, but we can use linker pragmas to create an alias to a default implementation. All of these implementation details are hidden in the new macro. Also, as I modify the name for exported weak symbols on Windows, I needed to temporarily disable "dll_host" test for asan, which checks the list of functions included in asan_win_dll_thunk. Differential Revision: https://reviews.llvm.org/D28596 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293419 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-20[sanitizer] [asan] Use macros to simplify weak aliases on Windows.Marcos Pividori
This patch adds some useful macros for dealing with pragma directives on Windows. Also, I add appropriate documentation for future users. Differential Revision: https://reviews.llvm.org/D28525 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@292650 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-18[sancov] common flags initialization.Mike Aizatsky
Summary: Introducing InitializeCommonFlags accross all sanitizers to simplify common flags management. Setting coverage=1 when html_cov_report is requested. Differential Revision: http://reviews.llvm.org/D18273 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@263820 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-13[UBSan] Enable 'help' option output, report unrecognized flagsAlexey Samsonov
Summary: Let UBSan output flag description if 'help' options is provided. Report unrecognized flags if verbosity mode is turned on. Patch by Svetlana Ryabkova! Differential Revision: http://reviews.llvm.org/D11903 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@244946 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-02Re-apply r241217 with build fixes:Peter Collingbourne
- Disable building of the interceptor library on 64-bit Windows. - Mangle names in /alternatename directive for 32-bit Windows. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@241224 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-02Revert r241217, it breaks the build on Windows.Nico Weber
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@241219 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-02ubsan: Port runtime library to (32- and 64-bit) Windows.Peter Collingbourne
Differential Revision: http://reviews.llvm.org/D10856 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@241217 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-01[UBSan] Embed UBSan into ASan runtime (compiler-rt part).Alexey Samsonov
Summary: Change the way we use ASan and UBSan together. Instead of keeping two separate runtimes (libclang_rt.asan and libclang_rt.ubsan), embed UBSan into ASan and get rid of libclang_rt.ubsan. If UBSan is not supported on a platform, all UBSan sources are just compiled into dummy empty object files. UBSan initialization code (e.g. flag parsing) is directly called from ASan initialization, so we are able to enforce correct initialization order. This mirrors the approach we already use for ASan+LSan. This change doesn't modify the way we use standalone UBSan. Test Plan: regression test suite Reviewers: kubabrecka, zaks.anna, rsmith, kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8646 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@233861 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-26[UBSan] Explicitly list all supported OS/arch pairs supported by UBSan.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@233295 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20[asan] Allow changing verbosity in activation flags.Evgeniy Stepanov
This change removes some debug output in asan_flags.cc that was reading the verbosity level before all the flags were parsed. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226566 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15[sanitizer] Flag parser rewrite.Evgeniy Stepanov
The new parser is a lot stricter about syntax, reports unrecognized flags, and will make it easier to implemented some of the planned features. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226169 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-07[Sanitizer] Change the runtime flag representation.Alexey Samsonov
This mirrors r225239 to all the rest sanitizers: ASan, DFSan, LSan, MSan, TSan, UBSan. Now the runtime flag type, name, default value and description is located in the single place in the .inc file. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225327 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-02Revert "Revert r224736: "[Sanitizer] Make CommonFlags immutable after ↵Alexey Samsonov
initialization."" Fix test failures by introducing CommonFlags::CopyFrom() to make sure compiler doesn't insert memcpy() calls into runtime code. Original commit message: Protect CommonFlags singleton by adding const qualifier to common_flags() accessor. The only ways to modify the flags are SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and OverrideCommonFlags() functions, which are only supposed to be called during initialization. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225088 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-02Revert r224736: "[Sanitizer] Make CommonFlags immutable after initialization."Chandler Carruth
We've got some internal users that either aren't compatible with this or have found a bug with it. Either way, this is an isolated cleanup and so I'm reverting it to un-block folks while we investigate. Alexey and I will be working on fixing everything up so this can be re-committed soon. Sorry for the noise and any inconvenience. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225079 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-22[Sanitizer] Make CommonFlags immutable after initialization.Alexey Samsonov
Summary: Protect CommonFlags singleton by adding const qualifier to common_flags() accessor. The only ways to modify the flags are SetCommonFlagsDefaults(), ParseCommonFlagsFromString() and OverrideCommonFlags() functions, which are only supposed to be called during initialization. Test Plan: regression test suite Reviewers: kcc, eugenis, glider Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6741 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224736 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-19[Sanitizer] Refactor CommonFlags interface. NFC.Alexey Samsonov
Add CommonFlags::SetDefaults() and CommonFlags::ParseFromString(), so that this object can be easily tested. Enforce that ParseCommonFlagsFromString() and SetCommonFlagsDefaults() work only with singleton CommonFlags, shared across all sanitizer runtimes. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224617 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-19[UBSan] Introduce more flexible __ubsan_default_options function instead of ↵Alexey Samsonov
UBSAN_DEFAULT_OPTIONS compile definition git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@218137 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-12Revert r217616. Problems and complexity it introduces negate its benefitAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217652 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11[UBSan] Parse common flags from UBSAN_OPTIONS runtime variable even ifAlexey Samsonov
UBSan is combined with ASan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217616 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-10[UBSan] Add halt_on_error runtime flagAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@217535 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-30[UBSan] Allow to override runtime flags defaults by providingAlexey Samsonov
compile definition UBSAN_DEFAULT_OPTIONS when building the runtime. This mirrors similar ASan functionality. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214259 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-29[UBSan] Move all runtime flags parsing to ubsan_flags.cc.Alexey Samsonov
No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@214258 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-23[UBSan] Add the ability to dump call stacks to -fsanitize=vptrAlexey Samsonov
This change introduces the first UBSan-specific runtime flag: print_stacktrace (off by default). It can be set in UBSAN_OPTIONS to unwind and print call stacks in addition to diagnostic messages. For now these stacks are printed only in vptr checker. This change is based on http://reviews.llvm.org/D4410 by Byoungyoung Lee! git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@213783 91177308-0d34-0410-b5e6-96231b3b80d8