diff options
author | Kostya Kortchinsky <kostyak@google.com> | 2018-03-06 20:13:37 +0000 |
---|---|---|
committer | Kostya Kortchinsky <kostyak@google.com> | 2018-03-06 20:13:37 +0000 |
commit | fda7be249930e29d47db4e21535c618afebfc8f5 (patch) | |
tree | 345d8263f920b0d042f216ed1e7786d92ae6c5f3 /lib/scudo | |
parent | 6a52b697d564699d511de92bce88e15bf6fc56b8 (diff) | |
download | compiler-rt-fda7be249930e29d47db4e21535c618afebfc8f5.tar.gz |
[scudo] Use gc-sections by default
Summary:
If not using `-Wl,--gc-sections`, a whole lot of unused `sanitizer_common` code
and related static variables are pulled into the shared library.
Keep the binary size smaller, and its memory footprint smaller as well, by
using the compiler flags `-ffunction-section` & `-fdata-sections` by default,
as well as the linker flags `-Wl,--gc-sections`.
Current experiments show a large discrepency between binary sizes generated
by gcc (big) and clang (small). I am not sure yet how I can make a test that
would encompass both, so it's an outstanding work item.
Reviewers: alekseyshl, flowerhack
Reviewed By: alekseyshl
Subscribers: mgorny, delcypher, llvm-commits, #sanitizers
Differential Revision: https://reviews.llvm.org/D44121
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@326833 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/scudo')
-rw-r--r-- | lib/scudo/CMakeLists.txt | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/scudo/CMakeLists.txt b/lib/scudo/CMakeLists.txt index 29e6795a5..0aba0cad1 100644 --- a/lib/scudo/CMakeLists.txt +++ b/lib/scudo/CMakeLists.txt @@ -9,6 +9,10 @@ append_rtti_flag(OFF SCUDO_CFLAGS) set(SCUDO_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}) +# Use gc-sections by default to avoid unused code being pulled in. +list(APPEND SCUDO_CFLAGS -ffunction-sections -fdata-sections) +list(APPEND SCUDO_DYNAMIC_LINK_FLAGS -Wl,--gc-sections) + set(SCUDO_SOURCES scudo_allocator.cpp scudo_crc32.cpp |