As suggested in https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8076 :
authormorriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 19 Dec 2012 02:09:48 +0000 (02:09 +0000)
committermorriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 19 Dec 2012 02:09:48 +0000 (02:09 +0000)
Enable PIE (if the compiler supports it) when compiling dumpcap.  Do this
regardless of whether we're configured to install dumpcap setuid-root because
some users will end up running dumpcap as root regardless of how we were
configured.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@46608 f5534014-38df-0310-8fa8-9805f1628bb7

Makefile.am
configure.ac

index 94a4d302cad6420a2843c8e930b2001b800f0aaa..4fb1092f1e3f745d7ac459ec2bd5a1c90304d5ba 100644 (file)
@@ -85,7 +85,7 @@ diameter_DATA = \
        diameter/Vodafone.xml \
        diameter/AlcatelLucent.xml \
        diameter/Nokia.xml \
-       diameter/NokiaSiemensNetworks.xml 
+       diameter/NokiaSiemensNetworks.xml
 
 #
 # Install the DTDs directory files in the "dtds" subdirectory
@@ -503,7 +503,8 @@ dumpcap_LDADD = \
        @SYSTEMCONFIGURATION_FRAMEWORKS@        \
        @COREFOUNDATION_FRAMEWORKS@     \
        @LIBCAP_LIBS@
-dumpcap_CFLAGS = $(AM_CLEAN_CFLAGS)
+dumpcap_CFLAGS = $(AM_CLEAN_CFLAGS) $(PIE_CFLAGS)
+dumpcap_LDFLAGS = $(PIE_LDFLAGS)
 
 # Common headers
 AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/wiretap \
index 19889716212b4ea3cf81afd366a7394f2d733869..9108b5701da91696a2916f7f8a78dc27bbbac005 100644 (file)
@@ -426,6 +426,30 @@ AC_WIRESHARK_GCC_CFLAGS_CHECK(-Warray-bounds)
 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wcast-align)
 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wformat-security)
 AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wold-style-definition, C)
+
+CFLAGS_before_pie=$CFLAGS
+AC_WIRESHARK_GCC_CFLAGS_CHECK(-fPIE, C)
+if test "x$CLFAGS" != "x$CFLAGS_before_pie"
+then
+       # Restore CFLAGS
+       CFLAGS=$CFLAGS_before_pie
+
+       LDFLAGS_before_pie=$LDFLAGS
+       AC_WIRESHARK_LDFLAGS_CHECK([-pie])
+       if test "x$LDFLAGS" != "x$LDFLAGS_before_pie"
+       then
+               # We can use PIE
+               PIE_CFLAGS="-fPIE"
+               PIE_LDFLAGS="-pie"
+
+               # Restore LDFLAGS
+               LDFLAGS=$LDFLAGS_before_pie
+       fi
+
+fi
+AC_SUBST(PIE_CFLAGS)
+AC_SUBST(PIE_LDFLAGS)
+
 #
 # XXX - OK for C++?
 #