@@ -1339,23 +1339,50 @@ if test "$pie" != "no" ; then
# define THREAD
#endif
+void *f(unsigned char *buf, int len);
+void *g(unsigned char *buf, int len);
+
+void *
+f(unsigned char *buf, int len)
+{
+ return (void*)0L;
+}
+
+
+void *
+g(unsigned char *buf, int len)
+{
+ return f(buf, len);
+}
+
+#ifdef PIE
static THREAD int tls_var;
int main(void) { return tls_var; }
+#endif
EOF
- if compile_prog "-fPIE -DPIE" "-pie"; then
- QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
- LDFLAGS="-pie $LDFLAGS"
- pie="yes"
- if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
- LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
+ if compile_prog "-shared -fPIE -fPIC" ""; then
+ if compile_prog "-fPIE -DPIE" "-pie"; then
+ QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
+ LDFLAGS="-pie $LDFLAGS"
+ pie="yes"
+ if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
+ LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
+ fi
+ else
+ if test "$pie" = "yes"; then
+ error_exit "PIE not available due to missing toolchain support"
+ else
+ echo "Disabling PIE due to missing toolchain support"
+ pie="no"
+ fi
fi
else
if test "$pie" = "yes"; then
- error_exit "PIE not available due to missing toolchain support"
+ error_exit "PIE not available due to broken toolchain support"
else
- echo "Disabling PIE due to missing toolchain support"
+ echo "Disabling PIE due to broken toolchain support"
pie="no"
fi
fi