OSDN Git Service

Run $(AR) with LLVMgold.so plugin for CFI targets.
authorEvgenii Stepanov <eugenis@google.com>
Tue, 24 Jan 2017 00:57:38 +0000 (16:57 -0800)
committerEvgenii Stepanov <eugenis@google.com>
Tue, 24 Jan 2017 01:02:22 +0000 (17:02 -0800)
Bug: 34623182
Test: add LOCAL_SANITIZE:=cfi to some static libraries under libstagefright
Change-Id: I4f0d8cbd794e0ce4737c59a4617e93c7a5defec1

core/binary.mk
core/config_sanitizers.mk
core/definitions.mk

index 4db3d51..4986c85 100644 (file)
@@ -57,6 +57,7 @@ my_generated_sources := $(LOCAL_GENERATED_SOURCES)
 my_additional_dependencies := $(LOCAL_ADDITIONAL_DEPENDENCIES)
 my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
 my_export_c_include_deps := $(LOCAL_EXPORT_C_INCLUDE_DEPS)
+my_arflags :=
 
 ifneq (,$(strip $(foreach dir,$(subst $(comma),$(space),$(COVERAGE_PATHS)),$(filter $(dir)%,$(LOCAL_PATH)))))
   my_native_coverage := true
@@ -1736,6 +1737,7 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_CHECKS := $(my_tidy_checks)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_FLAGS := $(my_tidy_flags)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ARFLAGS := $(my_arflags)
 
 # this is really the way to get the files onto the command line instead
 # of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
index c9883d4..1046ff6 100644 (file)
@@ -145,6 +145,7 @@ endif
 ifneq ($(filter cfi,$(my_sanitize)),)
   my_cflags += -flto -fsanitize-cfi-cross-dso -fvisibility=default
   my_ldflags += -flto -fsanitize-cfi-cross-dso -fsanitize=cfi -Wl,-plugin-opt,O1 -Wl,-export-dynamic-symbol=__cfi_check
+  my_arflags += --plugin $(LLVM_PREBUILTS_PATH)/../lib64/LLVMgold.so
 endif
 
 # If local or global modules need ASAN, add linker flags.
index dd53e7e..d77cea9 100644 (file)
@@ -1581,6 +1581,7 @@ define transform-o-to-static-lib
 $(extract-and-include-target-whole-static-libs)
 $(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) \
     $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \
+    $(PRIVATE_ARFLAGS) \
     $@,$(PRIVATE_ALL_OBJECTS))
 endef