Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 5da4968

Browse files
committed
[sanitizer] Use -Wl,-z,global on Android for sanitizers except UBsan
Summary: This essentially reverts r337010 since it breaks UBSan, which is used for a few platform libraries. The "-z global" flag is now added for Scudo as well. The only other sanitizer shared libraries are for asan and hwasan, which have also been reinstated to use the global flag. Reviewers: cryptoad, eugenis Reviewed By: cryptoad Subscribers: kubamracek, mgorny, delcypher, #sanitizers, nickdesaulniers, chh, kongyi, pirama, llvm-commits Differential Revision: https://reviews.llvm.org/D52770 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@343599 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 02170f7 commit 5da4968

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -385,14 +385,6 @@ endif()
385385

386386
append_list_if(COMPILER_RT_HAS_LIBC c SANITIZER_COMMON_LINK_LIBS)
387387

388-
if(ANDROID)
389-
# Put the Sanitizer shared libraries in the global group. For more details, see
390-
# android-changes-for-ndk-developers.md#changes-to-library-search-order
391-
if (COMPILER_RT_HAS_Z_GLOBAL)
392-
list(APPEND SANITIZER_COMMON_LINK_FLAGS -Wl,-z,global)
393-
endif()
394-
endif()
395-
396388
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia")
397389
list(APPEND SANITIZER_COMMON_LINK_FLAGS -Wl,-z,defs,-z,now,-z,relro)
398390
list(APPEND SANITIZER_COMMON_LINK_LIBS zircon)

lib/asan/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ append_rtti_flag(OFF ASAN_CFLAGS)
7575

7676
set(ASAN_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})
7777

78+
if(ANDROID)
79+
# Put most Sanitizer shared libraries in the global group. For more details, see
80+
# android-changes-for-ndk-developers.md#changes-to-library-search-order
81+
if (COMPILER_RT_HAS_Z_GLOBAL)
82+
list(APPEND ASAN_DYNAMIC_LINK_FLAGS -Wl,-z,global)
83+
endif()
84+
endif()
85+
7886
set(ASAN_DYNAMIC_DEFINITIONS
7987
${ASAN_COMMON_DEFINITIONS} ASAN_DYNAMIC=1)
8088
append_list_if(WIN32 INTERCEPTION_DYNAMIC_CRT ASAN_DYNAMIC_DEFINITIONS)

lib/hwasan/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding HWASAN_RTL_CFLA
4141

4242
set(HWASAN_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})
4343

44+
if(ANDROID)
45+
# Put most Sanitizer shared libraries in the global group. For more details, see
46+
# android-changes-for-ndk-developers.md#changes-to-library-search-order
47+
if (COMPILER_RT_HAS_Z_GLOBAL)
48+
list(APPEND HWASAN_DYNAMIC_LINK_FLAGS -Wl,-z,global)
49+
endif()
50+
endif()
51+
4452
set(HWASAN_DYNAMIC_CFLAGS ${HWASAN_RTL_CFLAGS})
4553
append_list_if(COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC
4654
-ftls-model=initial-exec HWASAN_DYNAMIC_CFLAGS)

lib/scudo/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ set(SCUDO_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})
1717
# Use gc-sections by default to avoid unused code being pulled in.
1818
list(APPEND SCUDO_DYNAMIC_LINK_FLAGS -Wl,--gc-sections)
1919

20+
if(ANDROID)
21+
# Put most Sanitizer shared libraries in the global group. For more details, see
22+
# android-changes-for-ndk-developers.md#changes-to-library-search-order
23+
if (COMPILER_RT_HAS_Z_GLOBAL)
24+
list(APPEND SCUDO_DYNAMIC_LINK_FLAGS -Wl,-z,global)
25+
endif()
26+
endif()
27+
2028
# The minimal Scudo runtime does not inlude the UBSan runtime.
2129
set(SCUDO_MINIMAL_OBJECT_LIBS
2230
RTSanitizerCommonNoTermination

0 commit comments

Comments
 (0)