-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install sanitizer libraries to the out directory.
If the app uses any sanitizers, we can install the library to the out directory to allow them to use wrap.sh rather than root their devices. This only works for ndk-build due to the nature of CMake toolchain files. Test: Removed the sanitizer runtime libraries from my test devices Test: ./run_tests.py --rebuild --filter asan-smoke Bug: android/ndk#540 Change-Id: I2944c468a1b34161d792e689c68ad2c391bdd409 (cherry picked from commit d7e5e76ed836ed0c4093d5558d64fabecdfdb1eb)
- Loading branch information
Showing
12 changed files
with
171 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ __pycache__/ | |
|
||
# Distribution / packaging | ||
.Python | ||
/build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# | ||
# Copyright (C) 2018 The Android Open Source Project | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# Ensure that for debuggable applications, gdbserver will be copied to | ||
# the proper location | ||
|
||
NDK_APP_GDBSERVER := $(NDK_APP_DST_DIR)/gdbserver | ||
NDK_APP_GDBSETUP := $(NDK_APP_DST_DIR)/gdb.setup | ||
|
||
ifeq ($(NDK_APP_DEBUGGABLE),true) | ||
ifeq ($(TARGET_SONAME_EXTENSION),.so) | ||
|
||
installed_modules: $(NDK_APP_GDBSERVER) | ||
|
||
$(NDK_APP_GDBSERVER): PRIVATE_ABI := $(TARGET_ARCH_ABI) | ||
$(NDK_APP_GDBSERVER): PRIVATE_NAME := $(TOOLCHAIN_NAME) | ||
$(NDK_APP_GDBSERVER): PRIVATE_SRC := $(TARGET_GDBSERVER) | ||
$(NDK_APP_GDBSERVER): PRIVATE_DST := $(NDK_APP_GDBSERVER) | ||
|
||
$(call generate-file-dir,$(NDK_APP_GDBSERVER)) | ||
|
||
$(NDK_APP_GDBSERVER): clean-installed-binaries | ||
$(call host-echo-build-step,$(PRIVATE_ABI),Gdbserver) "[$(PRIVATE_NAME)] $(call pretty-dir,$(PRIVATE_DST))" | ||
$(hide) $(call host-install,$(PRIVATE_SRC),$(PRIVATE_DST)) | ||
endif | ||
|
||
# Install gdb.setup for both .so and .bc projects | ||
ifneq (,$(filter $(TARGET_SONAME_EXTENSION),.so .bc)) | ||
installed_modules: $(NDK_APP_GDBSETUP) | ||
|
||
$(NDK_APP_GDBSETUP): PRIVATE_ABI := $(TARGET_ARCH_ABI) | ||
$(NDK_APP_GDBSETUP): PRIVATE_DST := $(NDK_APP_GDBSETUP) | ||
$(NDK_APP_GDBSETUP): PRIVATE_SOLIB_PATH := $(TARGET_OUT) | ||
$(NDK_APP_GDBSETUP): PRIVATE_SRC_DIRS := $(SYSROOT_INC) | ||
|
||
$(NDK_APP_GDBSETUP): | ||
$(call host-echo-build-step,$(PRIVATE_ABI),Gdbsetup) "$(call pretty-dir,$(PRIVATE_DST))" | ||
$(hide) $(HOST_ECHO) "set solib-search-path $(call host-path,$(PRIVATE_SOLIB_PATH))" > $(PRIVATE_DST) | ||
$(hide) $(HOST_ECHO) "directory $(call host-path,$(call remove-duplicates,$(PRIVATE_SRC_DIRS)))" >> $(PRIVATE_DST) | ||
|
||
$(call generate-file-dir,$(NDK_APP_GDBSETUP)) | ||
|
||
# This prevents parallel execution to clear gdb.setup after it has been written to | ||
$(NDK_APP_GDBSETUP): clean-installed-binaries | ||
endif | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# | ||
# Copyright (C) 2018 The Android Open Source Project | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# Generates rules to install sanitizer runtime libraries to the out directory if | ||
# the sanitizer is requested in the app's ldflags. | ||
# | ||
# Args: | ||
# NDK_SANTIZER_NAME: | ||
# Sanitizer name used as the variable name component to find the library. | ||
# i.e. $(TARGET_$(2)_BASENAME) is the name of the library to install. This | ||
# is also used as the name printed to the terminal for the build step. | ||
# NDK_SANITIZER_FSANITIZE_ARGS: | ||
# -fsanitize= arguments that require this runtime library. | ||
# | ||
# Example usage: | ||
# NDK_SANITIZER_NAME := UBSAN | ||
# NDK_SANITIZER_FSANITIZE_ARGS := undefined | ||
# include $(BUILD_SYSTEM)/install_sanitizer.mk | ||
|
||
ifneq (,$(filter $(NDK_SANITIZER_FSANITIZE_ARGS),$(NDK_SANITIZERS))) | ||
installed_modules: $(NDK_APP_$(NDK_SANITIZER_NAME)) | ||
|
||
NDK_SANITIZER_TARGET := $(NDK_APP_$(NDK_SANITIZER_NAME)) | ||
NDK_SANITIZER_LIB_PATH := $(NDK_TOOLCHAIN_LIB_DIR)/$(TARGET_$(NDK_SANITIZER_NAME)_BASENAME) | ||
|
||
$(NDK_SANITIZER_TARGET): PRIVATE_ABI := $(TARGET_ARCH_ABI) | ||
$(NDK_SANITIZER_TARGET): PRIVATE_NAME := $(NDK_SANITIZER_NAME) | ||
$(NDK_SANITIZER_TARGET): PRIVATE_SRC := $(NDK_SANITIZER_LIB_PATH) | ||
$(NDK_SANITIZER_TARGET): PRIVATE_DST := $(NDK_APP_$(NDK_SANITIZER_NAME)) | ||
|
||
$(call generate-file-dir,$(NDK_APP_$(NDK_SANITIZER_NAME))) | ||
|
||
$(NDK_SANITIZER_TARGET): clean-installed-binaries | ||
$(call host-echo-build-step,$(PRIVATE_ABI),$(PRIVATE_NAME) "$(call pretty-dir,$(PRIVATE_DST))") | ||
$(hide) $(call host-install,$(PRIVATE_SRC),$(PRIVATE_DST)) | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# | ||
# Copyright (C) 2018 The Android Open Source Project | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
NDK_TOOLCHAIN_LIB_SUFFIX := 64 | ||
ifeq ($(HOST_ARCH64),x86) | ||
NDK_TOOLCHAIN_LIB_SUFFIX := | ||
endif | ||
|
||
NDK_TOOLCHAIN_LIB_DIR := \ | ||
$(LLVM_TOOLCHAIN_PREBUILT_ROOT)/lib$(NDK_TOOLCHAIN_LIB_SUFFIX)/clang/5.0.2/lib/linux | ||
|
||
NDK_APP_ASAN := $(NDK_APP_DST_DIR)/$(TARGET_ASAN_BASENAME) | ||
NDK_APP_UBSAN := $(NDK_APP_DST_DIR)/$(TARGET_UBSAN_BASENAME) | ||
|
||
NDK_ALL_LDFLAGS := $(NDK_APP_LDFLAGS) | ||
$(foreach __module,$(__ndk_modules),\ | ||
$(eval NDK_ALL_LDFLAGS += $(__ndk_modules.$(__module).LDFLAGS))) | ||
NDK_FSANITIZE_LDFLAGS := $(filter -fsanitize=%,$(NDK_ALL_LDFLAGS)) | ||
NDK_SANITIZERS := $(patsubst -fsanitize=%,%,$(NDK_FSANITIZE_LDFLAGS)) | ||
|
||
NDK_SANITIZER_NAME := UBSAN | ||
NDK_SANITIZER_FSANITIZE_ARGS := undefined | ||
include $(BUILD_SYSTEM)/install_sanitizer.mk | ||
|
||
NDK_SANITIZER_NAME := ASAN | ||
NDK_SANITIZER_FSANITIZE_ARGS := address | ||
include $(BUILD_SYSTEM)/install_sanitizer.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters