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.
That's unfortunate that this is not a subset of any other source list. I'm worried that people will forget to update it, and would not know whether a new file belongs here or not. It's probably OK as long as scudo_minimal is built by default in compiler-rt.
AFAIR @pcc mentioned that _libcdep / _nolibc distinction can be deprecated. Is that true? If those are merged into a single source list, would this new SCUDO list be a subset of it?