GoogleGit

commitb0eafa21b9ac578e279198b8650fafbee6b83dc3[log][tgz]
authorJoshua J. Drake <android-open-source@qoop.org>Thu Dec 12 00:34:29 2013 -0600
committerYing Wang <wangying@google.com>Thu Dec 12 17:36:53 2013 -0800
treee6adf66d98f7920fac3a5e281695f2c93f1ccebc
parent5859f105fad3ce1ba76fb252c4c5b8fe357a3ce4[diff]
enable PIE for dynamically linked Linux host executables

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

Note: PIE *static* executables are not supported at this time. darwin
and windows are also not supported.

Change-Id: I67c1be297711ea23064c349f97ebd02eef3eff09
diff --git a/core/definitions.mk b/core/definitions.mk
index e1eb9f1..4e1a25d 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1368,6 +1368,7 @@
 	$(PRIVATE_LDFLAGS) \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 		$(HOST_GLOBAL_LDFLAGS) \
+		-fPIE -pie \
 	) \
 	-o $@ \
 	$(PRIVATE_LDLIBS)