[PATCH] D15192: [safestack] Turn the OS X SafeStack runtime into a dynamic library
Kuba Brecka via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 3 07:49:41 PST 2015
kubabrecka created this revision.
kubabrecka added reviewers: eugenis, pcc, kcc, samsonov.
kubabrecka added subscribers: llvm-commits, zaks.anna.
On OS X, the are two huge drawbacks to having a static library (.a) as a runtime:
1) Interceptors don't work -- and SafeStack relies on intercepting pthread_create.
2) Having multiple instrumented modules (frameworks, dylibs, bundles) in a single process is problematic and requires special care when building each module.
Let's make the runtime a dynamic library, just like the other sanitizers (ASan, TSan).
http://reviews.llvm.org/D15192
Files:
projects/compiler-rt/lib/safestack/CMakeLists.txt
tools/clang/lib/Driver/ToolChains.cpp
tools/clang/lib/Driver/Tools.cpp
Index: projects/compiler-rt/lib/safestack/CMakeLists.txt
===================================================================
--- projects/compiler-rt/lib/safestack/CMakeLists.txt
+++ projects/compiler-rt/lib/safestack/CMakeLists.txt
@@ -9,13 +9,13 @@
if(APPLE)
# Build universal binary on APPLE.
add_compiler_rt_runtime(clang_rt.safestack
- STATIC
+ SHARED
OS osx
ARCHS ${SAFESTACK_SUPPORTED_ARCH}
SOURCES ${SAFESTACK_SOURCES}
$<TARGET_OBJECTS:RTInterception.osx>
$<TARGET_OBJECTS:RTSanitizerCommon.osx>
- $<TARGET_OBJECTS:RTSanitizerCommonNoLibc.osx>
+ $<TARGET_OBJECTS:RTSanitizerCommonLibc.osx>
CFLAGS ${SAFESTACK_CFLAGS}
PARENT_TARGET safestack)
else()
Index: tools/clang/lib/Driver/Tools.cpp
===================================================================
--- tools/clang/lib/Driver/Tools.cpp
+++ tools/clang/lib/Driver/Tools.cpp
@@ -6958,15 +6958,6 @@
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
getMachOToolChain().addStartObjectFileArgs(Args, CmdArgs);
- // SafeStack requires its own runtime libraries
- // These libraries should be linked first, to make sure the
- // __safestack_init constructor executes before everything else
- if (getToolChain().getSanitizerArgs().needsSafeStackRt()) {
- getMachOToolChain().AddLinkRuntimeLib(Args, CmdArgs,
- "libclang_rt.safestack_osx.a",
- /*AlwaysLink=*/true);
- }
-
Args.AddAllArgs(CmdArgs, options::OPT_L);
AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
Index: tools/clang/lib/Driver/ToolChains.cpp
===================================================================
--- tools/clang/lib/Driver/ToolChains.cpp
+++ tools/clang/lib/Driver/ToolChains.cpp
@@ -413,6 +413,8 @@
AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
if (Sanitize.needsTsanRt())
AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
+ if (Sanitize.needsSafeStackRt())
+ AddLinkSanitizerLibArgs(Args, CmdArgs, "safestack");
// Otherwise link libSystem, then the dynamic runtime library, and finally any
// target specific static runtime library.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15192.41756.patch
Type: text/x-patch
Size: 2219 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151203/7431a90b/attachment.bin>
More information about the llvm-commits
mailing list