[libcxx-commits] [libcxx] WIP [libc++][hardening] Overhaul the termination mechanism for hardening (PR #77823)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jan 11 13:46:24 PST 2024
================
@@ -0,0 +1,23 @@
+// -*- C++ -*-
----------------
ldionne wrote:
Per our live review just now, we explored the following alternatives (using chrome as an example since we know they override verbose abort right now):
```
Option #1
=======================
$ cmake ... -DLIBCXX_VERBOSE_TRAP_OVERRIDE="void __chromium_trap(char const*);\n#define _LIBCPP_VERBOSE_TRAP(message) __chromium_trap(message)"
// __verbose_trap.in
#ifndef _LIBCPP___VERBOSE_TRAP
#define _LIBCPP___VERBOSE_TRAP
#include <__availability>
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
#if @LIBCXX_VERBOSE_TRAP_OVERRIDE@
@LIBCXX_VERBOSE_TRAP_OVERRIDE@
#elif HARDENING_MODE == DEBUG
# define _LIBCPP_VERBOSE_TRAP(message) ::verbose_abort(...)
#else
# define _LIBCPP_VERBOSE_TRAP(message) ((void)message, __builtin_trap())
#endif
#endif // _LIBCPP___VERBOSE_TRAP
Option #2
=======================
$ cmake ... -DLIBCXX_VERBOSE_TRAP_OVERRIDE=libcxx/vendor/chrome/verbose_trap.in
// __verbose_trap.in
#ifndef _LIBCPP___VERBOSE_TRAP
#define _LIBCPP___VERBOSE_TRAP
#include <__availability>
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
#if @LIBCXX_VERBOSE_TRAP_OVERRIDE@
copy-paste the contents of @LIBCXX_VERBOSE_TRAP_OVERRIDE@ at CMake configuration time
#elif HARDENING_MODE == DEBUG
# define _LIBCPP_VERBOSE_TRAP(message) ::verbose_abort(...)
#else
# define _LIBCPP_VERBOSE_TRAP(message) ((void)message, __builtin_trap())
#endif
#endif // _LIBCPP___VERBOSE_TRAP
// in libcxx/vendor/chrome/verbose_trap.in
#define _LIBCPP_VERBOSE_TRAP(message) ::whatever()
```
https://github.com/llvm/llvm-project/pull/77823
More information about the libcxx-commits
mailing list