enable PIE for dynamically linked executables

Compile all programs on Android with -fPIE and -pie. This enables
PIE (Position Independent Executables), which helps protect Android
applications from exploitation due to memory management bugs.

Stop using the armelf.x linker script. This script hard codes the
load address of the executable, defeating the position independence
PIE requires.

Note: PIE *static* executables are not supported at this time and
require additional linker changes.

Bug: 5323301
Change-Id: Ieafcc9c4f142495847e163881889d371a59d0878
This commit is contained in:
Nick Kralevich 2011-10-24 10:53:36 -07:00
parent 4fc484a7fe
commit 026a85b129
1 changed files with 2 additions and 2 deletions

View File

@ -102,7 +102,7 @@ android_config_h := $(call select-android-config-h,linux-arm)
arch_include_dir := $(dir $(android_config_h))
TARGET_GLOBAL_CFLAGS += \
-msoft-float -fpic \
-msoft-float -fpic -fPIE \
-ffunction-sections \
-fdata-sections \
-funwind-tables \
@ -266,7 +266,7 @@ $(hide) $(PRIVATE_CXX) \
endef
define transform-o-to-executable-inner
$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -fPIE -pie \
-Wl,-dynamic-linker,/system/bin/linker \
-Wl,--gc-sections \
-Wl,-z,nocopyreloc \