diff options
author | Guy Harris <guy@alum.mit.edu> | 2012-12-29 22:50:48 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2012-12-29 22:50:48 +0000 |
commit | e0b3a943f7bf590b830a39268d722a7a6fbdc424 (patch) | |
tree | 68c6e089cc0d52b2454ce0347fec7d3ca865656d | |
parent | 592a0fcf04c3f7f9f23476525877763303a1a87d (diff) |
Move the PIE checks after the warning checks, to keep the warning checks
together, and add a comment explaining what's being done.
svn path=/trunk/; revision=46854
-rw-r--r-- | configure.ac | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/configure.ac b/configure.ac index 2d0e33ddbb..86d916c1f4 100644 --- a/configure.ac +++ b/configure.ac @@ -447,29 +447,6 @@ AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-overlength-strings) AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wwrite-strings) AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-long-long) -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([-fPIE -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++? # @@ -515,6 +492,35 @@ AC_WIRESHARK_LDFLAGS_CHECK([-Wl,--as-needed]) # AC_WIRESHARK_LDFLAGS_CHECK([-fwhole-program]) # +# Put -fPIE in PIE_CFLAGS and -pie in PIE_LDFLAGS if we can use them, +# so that we can build dumpcap PIE - it may run with elevated +# privileges, and using PIE means the OS can run it at random locations +# in the address space to make attacks more difficult. +# +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([-fPIE -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) + +# # If we're running GCC or clang define _U_ to be "__attribute__((unused))" # so we can use _U_ to flag unused function parameters and not get warnings # about them. Otherwise, define _U_ to be an empty string so that _U_ used |