[PATCH] D44525: [sanitizer] Add a slim Scudo shared runtime

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 15 10:03:05 PDT 2018


cryptoad created this revision.
cryptoad added reviewers: eugenis, alekseyshl, flowerhack, phosek.
Herald added subscribers: Sanitizers, llvm-commits, delcypher, mgorny, kubamracek.

So I am actually not sure what would be the prefered way to do that from a
Sanitizer perspective, so here is one way that works, but feel free to point me
in another direction.

Fuchsia would like a standalone slim Scudo shared library, without C++
dependencies and with as few extras as possible. Right now, we bundle `RTUBsan`
because we want to cover the case `-fsanitize=scudo,undefined`, which has some
C++ runtime dependencies. So this new slim Scudo runtime will be UBSan free.

But then the other issue is that there is a whole lot of public functions that
are exported by default in sanitizer_common that pull in stuff like the
symbolizer or stacktraces modules that Scudo has no use for. This ends up
pulling in the internal allocator which has a 512kB memory footprint in the
bss section for example. So I defined a minimal set of files from
sanitizer_common needed by Scudo to get rid of all the extras.

The last thing was to override `__sanitizer_sandbox_on_notify` which was
pulling in the symbolizer has well.

This would also allow to add `nostdlib++` and `nostdinc++` to the minimal
runtime.

Here are a few binary sizes with different compilations options:

- a build with gcc: lib/clang/7.0.0/lib/linux/libclang_rt.scudo-x86_64.so 2777112 lib/clang/7.0.0/lib/linux/libclang_rt.scudo_minimal-x86_64.so 1608024
- a build with clang: lib/clang/7.0.0/lib/linux/libclang_rt.scudo-x86_64.so 469392 lib/clang/7.0.0/lib/linux/libclang_rt.scudo_minimal-x86_64.so 238432

Let me know what you think, or if there is another way to achieve this.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D44525

Files:
  lib/sanitizer_common/CMakeLists.txt
  lib/scudo/CMakeLists.txt
  lib/scudo/scudo_override.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44525.138578.patch
Type: text/x-patch
Size: 3975 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180315/136f3e82/attachment.bin>


More information about the llvm-commits mailing list