[PATCH] D49198: [scudo] Use -Wl,-z,global on Android
Kostya Kortchinsky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 11 11:44:04 PDT 2018
cryptoad created this revision.
cryptoad added reviewers: eugenis, alekseyshl.
Herald added subscribers: Sanitizers, delcypher, mgorny, srhines.
As is used with ASan, use `-Wl,-z,global` for the Scudo shared library on
Android. We want Scudo to be loaded as early as possible to avoid any other
shared library to do an allocation that would later be freed by Scudo.
`audioserver` was one of the binary that exhibited the problem, this seems to
fix it.
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D49198
Files:
lib/scudo/CMakeLists.txt
Index: lib/scudo/CMakeLists.txt
===================================================================
--- lib/scudo/CMakeLists.txt
+++ lib/scudo/CMakeLists.txt
@@ -17,6 +17,18 @@
# Use gc-sections by default to avoid unused code being pulled in.
list(APPEND SCUDO_DYNAMIC_LINK_FLAGS -Wl,--gc-sections)
+if(ANDROID)
+# On Android, -z global does not do what it is documented to do.
+# On Android, -z global moves the library ahead in the lookup order, placing it
+# right after the LD_PRELOADs. This is used to compensate for the fact that
+# Android linker does not look at the dependencies of the main executable that
+# aren't dependencies of the current DSO when resolving symbols from said DSO.
+# The above is applicable to L MR1 or newer.
+ if (COMPILER_RT_HAS_Z_GLOBAL)
+ list(APPEND ASAN_DYNAMIC_LINK_FLAGS -Wl,-z,global)
+ endif()
+endif()
+
# The minimal Scudo runtime does not inlude the UBSan runtime.
set(SCUDO_MINIMAL_OBJECT_LIBS
RTSanitizerCommonNoTermination
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49198.155040.patch
Type: text/x-patch
Size: 987 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180711/143c8439/attachment.bin>
More information about the llvm-commits
mailing list