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)