diff --git a/core/binary.mk b/core/binary.mk index f5dac69a4..6cfd0ace9 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -113,6 +113,12 @@ my_cxx := $(LOCAL_CXX) my_c_includes := $(LOCAL_C_INCLUDES) my_generated_sources := $(LOCAL_GENERATED_SOURCES) +ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES) +my_cflags += -fpie +else +my_cflags += -fPIC +endif + my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix)) my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix)) my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix)) diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk index 702a3669c..88f11fdca 100644 --- a/core/combo/TARGET_linux-arm.mk +++ b/core/combo/TARGET_linux-arm.mk @@ -95,7 +95,7 @@ endif android_config_h := $(call select-android-config-h,linux-arm) $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \ - -msoft-float -fpic -fPIE \ + -msoft-float \ -ffunction-sections \ -fdata-sections \ -funwind-tables \ @@ -218,7 +218,7 @@ $(hide) $(PRIVATE_CXX) \ endef define $(combo_2nd_arch_prefix)transform-o-to-executable-inner -$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -fPIE -pie \ +$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -pie \ -Wl,-dynamic-linker,/system/bin/linker \ -Wl,--gc-sections \ -Wl,-z,nocopyreloc \ diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk index e04329e74..520eb0941 100644 --- a/core/combo/TARGET_linux-arm64.mk +++ b/core/combo/TARGET_linux-arm64.mk @@ -73,7 +73,6 @@ TARGET_GLOBAL_CFLAGS += \ android_config_h := $(call select-android-config-h,linux-arm64) TARGET_GLOBAL_CFLAGS += \ - -fpic -fPIE \ -fstack-protector \ -ffunction-sections \ -fdata-sections \ @@ -185,7 +184,7 @@ $(hide) $(PRIVATE_CXX) \ endef define transform-o-to-executable-inner -$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -fPIE -pie \ +$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -pie \ -Wl,-dynamic-linker,/system/bin/linker64 \ -Wl,--gc-sections \ -Wl,-z,nocopyreloc \ diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk index 8930f0e13..ccd7c1a2d 100644 --- a/core/combo/TARGET_linux-mips.mk +++ b/core/combo/TARGET_linux-mips.mk @@ -84,7 +84,6 @@ android_config_h := $(call select-android-config-h,linux-mips) $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \ $(TARGET_mips_CFLAGS) \ -U__unix -U__unix__ -Umips \ - -fpic -fPIE\ -ffunction-sections \ -fdata-sections \ -funwind-tables \ @@ -191,7 +190,7 @@ $(hide) $(PRIVATE_CXX) \ endef define $(combo_2nd_arch_prefix)transform-o-to-executable-inner -$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -fPIE -pie \ +$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -pie \ -Wl,-dynamic-linker,/system/bin/linker \ -Wl,--gc-sections \ -Wl,-z,nocopyreloc \ diff --git a/core/combo/TARGET_linux-mips64.mk b/core/combo/TARGET_linux-mips64.mk index e23978fe9..b66389bbe 100644 --- a/core/combo/TARGET_linux-mips64.mk +++ b/core/combo/TARGET_linux-mips64.mk @@ -84,7 +84,6 @@ android_config_h := $(call select-android-config-h,linux-mips64) TARGET_GLOBAL_CFLAGS += \ $(TARGET_mips_CFLAGS) \ -U__unix -U__unix__ -Umips \ - -fpic -fPIE\ -ffunction-sections \ -fdata-sections \ -funwind-tables \ @@ -195,7 +194,7 @@ $(hide) $(PRIVATE_CXX) \ endef define transform-o-to-executable-inner -$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -fPIE -pie \ +$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -pie \ -Wl,-dynamic-linker,/system/bin/linker64 \ -Wl,--gc-sections \ -Wl,-z,nocopyreloc \ diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk index 395660383..b534e3294 100644 --- a/core/combo/TARGET_linux-x86.mk +++ b/core/combo/TARGET_linux-x86.mk @@ -177,7 +177,7 @@ $(hide) $(PRIVATE_CXX) \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ -nostdlib -Bdynamic \ -Wl,-z,nocopyreloc \ - -fPIE -pie \ + -pie \ $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ -Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O)) \ diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk index 4f727a25e..b1c6fbfe0 100644 --- a/core/combo/TARGET_linux-x86_64.mk +++ b/core/combo/TARGET_linux-x86_64.mk @@ -180,7 +180,7 @@ $(hide) $(PRIVATE_CXX) \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ -nostdlib -Bdynamic \ -Wl,-z,nocopyreloc \ - -fPIE -pie \ + -pie \ $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \ -Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O)) \ diff --git a/core/definitions.mk b/core/definitions.mk index 66565919d..c798f022b 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1413,7 +1413,7 @@ endef ifdef BUILD_HOST_static HOST_FPIE_FLAGS := else -HOST_FPIE_FLAGS := -fPIE -pie +HOST_FPIE_FLAGS := -pie endif ifneq ($(HOST_CUSTOM_LD_COMMAND),true)