summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toolchain/3rd-party-g++.in10
-rw-r--r--toolchain/3rd-party-gcc.in10
2 files changed, 18 insertions, 2 deletions
diff --git a/toolchain/3rd-party-g++.in b/toolchain/3rd-party-g++.in
index 7c0fa78..f308016 100644
--- a/toolchain/3rd-party-g++.in
+++ b/toolchain/3rd-party-g++.in
@@ -4,12 +4,20 @@ if echo " $* " | grep -qE '[[:space:]]-[IL][[:space:]]*(/+usr)?/+((local|X11R6)/
echo "$0: poisoned host path detected: $*" >&2
exit 1
fi
+
+# Android only supports PIEs, but they don't set the default PIE behavior in
+# the compiler, so we need to manually add the flags.
+case " $* " in
+*" -fPIC "*|*" -fpic "*|*" -fPIE "*|*" -fpie "*|*" -shared "*|*" -static "*|*" -pie "*) ;;
+*) set -- -fpie -pie "$@"
+esac
+
exec \
"${ANDROID_TOOLCHAIN}/@CXX@" \
@CXXFLAGS@ \
@LDFLAGS@ \
--sysroot "${ANDROID_PRODUCT_OUT}/@ROOT_SUBDIR@" \
- -Wl,-rpath,/system/usr/@LIBDIR@ \
+ -Wl,--enable-new-dtags,-rpath,/system/usr/@LIBDIR@ \
-Wl,-lc++ \
-frtti \
"$@"
diff --git a/toolchain/3rd-party-gcc.in b/toolchain/3rd-party-gcc.in
index 3a03f13..e5e3af4 100644
--- a/toolchain/3rd-party-gcc.in
+++ b/toolchain/3rd-party-gcc.in
@@ -4,10 +4,18 @@ if echo " $* " | grep -qE '[[:space:]]-[IL][[:space:]]*(/+usr)?/+((local|X11R6)/
echo "$0: poisoned host path detected: $*" >&2
exit 1
fi
+
+# Android only supports PIEs, but they don't set the default PIE behavior in
+# the compiler, so we need to manually add the flags.
+case " $* " in
+*" -fPIC "*|*" -fpic "*|*" -fPIE "*|*" -fpie "*|*" -shared "*|*" -static "*|*" -pie "*) ;;
+*) set -- -fpie -pie "$@"
+esac
+
exec \
"${ANDROID_TOOLCHAIN}/@CC@" \
@CFLAGS@ \
@LDFLAGS@ \
--sysroot "${ANDROID_PRODUCT_OUT}/@ROOT_SUBDIR@" \
- -Wl,-rpath,/system/usr/@LIBDIR@ \
+ -Wl,--enable-new-dtags,-rpath,/system/usr/@LIBDIR@ \
"$@"