summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2018-07-13 15:31:05 +0000
committerKostya Kortchinsky <kostyak@google.com>2018-07-13 15:31:05 +0000
commit4a547fb62d40a2406b5992e80cc27824f752b3db (patch)
tree8884cfe20ff2f78e6fd6c699442d72eeca48cb63 /compiler-rt
parentceabd50a5cff652dae468d872a8c31637c9ee415 (diff)
downloadbcm5719-llvm-4a547fb62d40a2406b5992e80cc27824f752b3db.tar.gz
bcm5719-llvm-4a547fb62d40a2406b5992e80cc27824f752b3db.zip
[sanitizer] Use -Wl,-z,global on Android
Summary: Use `-Wl,-z,global` for all Sanitizer shared libraries on Android. We want them to be in the global group (https://android.googlesource.com/platform/bionic/+/master/android-changes-for-ndk-developers.md#changes-to-library-search-order) to avoid any alloc/dealloc mismatch between the libc allocator & said library. `audioserver` was one of the binary that exhibited the problem with Scudo, this seems to fix it. [edited for accuracy] Reviewers: eugenis, alekseyshl Reviewed By: eugenis Subscribers: kubamracek, srhines, mgorny, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D49198 llvm-svn: 337010
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/CMakeLists.txt8
-rw-r--r--compiler-rt/lib/asan/CMakeLists.txt14
-rw-r--r--compiler-rt/lib/hwasan/CMakeLists.txt14
3 files changed, 8 insertions, 28 deletions
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index be4066f221e..77507b78a9f 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -333,6 +333,14 @@ endif()
append_list_if(COMPILER_RT_HAS_LIBC c SANITIZER_COMMON_LINK_LIBS)
+if(ANDROID)
+# Put the Sanitizer shared libraries in the global group. For more details, see
+# android-changes-for-ndk-developers.md#changes-to-library-search-order
+ if (COMPILER_RT_HAS_Z_GLOBAL)
+ list(APPEND SANITIZER_COMMON_LINK_FLAGS -Wl,-z,global)
+ endif()
+endif()
+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia")
list(APPEND SANITIZER_COMMON_LINK_FLAGS -Wl,-z,defs,-z,now,-z,relro)
list(APPEND SANITIZER_COMMON_LINK_LIBS zircon)
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt
index 48ac7cc7ec2..2ae5c85ecef 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -75,20 +75,6 @@ append_rtti_flag(OFF ASAN_CFLAGS)
set(ASAN_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})
-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.
-# As a net result, this allows running ASan executables without LD_PRELOAD-ing the
-# ASan runtime library.
-# 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()
-
set(ASAN_DYNAMIC_DEFINITIONS
${ASAN_COMMON_DEFINITIONS} ASAN_DYNAMIC=1)
append_list_if(WIN32 INTERCEPTION_DYNAMIC_CRT ASAN_DYNAMIC_DEFINITIONS)
diff --git a/compiler-rt/lib/hwasan/CMakeLists.txt b/compiler-rt/lib/hwasan/CMakeLists.txt
index 17a8e907bf8..42bf4366f19 100644
--- a/compiler-rt/lib/hwasan/CMakeLists.txt
+++ b/compiler-rt/lib/hwasan/CMakeLists.txt
@@ -36,20 +36,6 @@ append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding HWASAN_RTL_CFLA
set(HWASAN_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})
-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.
-# As a net result, this allows running ASan executables without LD_PRELOAD-ing the
-# ASan runtime library.
-# The above is applicable to L MR1 or newer.
- if (COMPILER_RT_HAS_Z_GLOBAL)
- list(APPEND HWASAN_DYNAMIC_LINK_FLAGS -Wl,-z,global)
- endif()
-endif()
-
set(HWASAN_DYNAMIC_CFLAGS ${HWASAN_RTL_CFLAGS})
append_list_if(COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC
-ftls-model=initial-exec HWASAN_DYNAMIC_CFLAGS)
OpenPOWER on IntegriCloud