diff options
author | James Y Knight <jyknight@google.com> | 2017-01-13 19:22:26 +0000 |
---|---|---|
committer | James Y Knight <jyknight@google.com> | 2017-01-13 19:22:26 +0000 |
commit | 0d3145ff8dae2a77ea5fc1743f75e180e48bc3da (patch) | |
tree | eac2c62b6fd03488c30382502cdb1d99efb3793e /libcxxabi/src/cxa_default_handlers.cpp | |
parent | 8a59f5c79fec30f876d30f4e8347dfed64ea3df5 (diff) | |
download | bcm5719-llvm-0d3145ff8dae2a77ea5fc1743f75e180e48bc3da.tar.gz bcm5719-llvm-0d3145ff8dae2a77ea5fc1743f75e180e48bc3da.zip |
[libc++abi] Add a silent terminate handler to libcxxabi.
The current std::terminate_handler pulls in some string code, some I/O
code, and more. Since it is automatically setup as the default, this
means that any trivial binary linking against libcxxabi will get this
extra bloat.
This patch allows disabling it as a build-time option, if you want to
avoid the extra bloat.
Patch by Tom Rybka!
Reviewers: EricWF
Subscribers: danalbert, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D28497
llvm-svn: 291946
Diffstat (limited to 'libcxxabi/src/cxa_default_handlers.cpp')
-rw-r--r-- | libcxxabi/src/cxa_default_handlers.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libcxxabi/src/cxa_default_handlers.cpp b/libcxxabi/src/cxa_default_handlers.cpp index 09350e7721a..a1ea2961655 100644 --- a/libcxxabi/src/cxa_default_handlers.cpp +++ b/libcxxabi/src/cxa_default_handlers.cpp @@ -12,6 +12,7 @@ #include <stdexcept> #include <new> #include <exception> +#include <cstdlib> #include "abort_message.h" #include "config.h" // For __sync_swap #include "cxxabi.h" @@ -22,7 +23,7 @@ static const char* cause = "uncaught"; __attribute__((noreturn)) -static void default_terminate_handler() +static void demangling_terminate_handler() { // If there might be an uncaught exception using namespace __cxxabiv1; @@ -78,12 +79,19 @@ static void default_terminate_handler() } __attribute__((noreturn)) -static void default_unexpected_handler() +static void demangling_unexpected_handler() { cause = "unexpected"; std::terminate(); } +#if !LIBCXXABI_SILENT_TERMINATE +static std::terminate_handler default_terminate_handler = demangling_terminate_handler; +static std::terminate_handler default_unexpected_handler = demangling_unexpected_handler; +#else +static std::terminate_handler default_terminate_handler = std::abort; +static std::terminate_handler default_unexpected_handler = std::abort; +#endif // // Global variables that hold the pointers to the current handler |