Chris@40: dnl Copyright (C) 2013 Xiph.org Foundation Chris@40: dnl Chris@40: dnl Redistribution and use in source and binary forms, with or without Chris@40: dnl modification, are permitted provided that the following conditions Chris@40: dnl are met: Chris@40: dnl Chris@40: dnl - Redistributions of source code must retain the above copyright Chris@40: dnl notice, this list of conditions and the following disclaimer. Chris@40: dnl Chris@40: dnl - Redistributions in binary form must reproduce the above copyright Chris@40: dnl notice, this list of conditions and the following disclaimer in the Chris@40: dnl documentation and/or other materials provided with the distribution. Chris@40: dnl Chris@40: dnl - Neither the name of the Xiph.org Foundation nor the names of its Chris@40: dnl contributors may be used to endorse or promote products derived from Chris@40: dnl this software without specific prior written permission. Chris@40: dnl Chris@40: dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS Chris@40: dnl ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT Chris@40: dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR Chris@40: dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR Chris@40: dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, Chris@40: dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, Chris@40: dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR Chris@40: dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF Chris@40: dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING Chris@40: dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS Chris@40: dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Chris@40: Chris@40: dnl Want to know of GCC stack protector works, botfor the C and for the C++ Chris@40: dnl compiler. Chris@40: dnl Chris@40: dnl Just checking if the compiler accepts the required CFLAGSs is not enough Chris@40: dnl because we have seen at least one instance where this check was Chris@40: dnl in-sufficient. Chris@40: dnl Chris@40: dnl Instead, try to compile and link a test program with the stack protector Chris@40: dnl flags. If that works, we use it. Chris@40: Chris@40: AC_DEFUN([XIPH_GCC_STACK_PROTECTOR], Chris@40: [AC_LANG_ASSERT(C) Chris@40: AC_MSG_CHECKING([if $CC supports stack smash protection]) Chris@40: xiph_stack_check_old_cflags="$CFLAGS" Chris@40: SSP_FLAGS="-fstack-protector --param ssp-buffer-size=4" Chris@40: CFLAGS=$SSP_FLAGS Chris@40: AC_TRY_LINK([ Chris@40: #include Chris@40: ], Chris@40: [puts("Hello, World!"); return 0;], Chris@40: AC_MSG_RESULT([yes]) Chris@40: CFLAGS="$xiph_stack_check_old_cflags $SSP_FLAGS", Chris@40: AC_MSG_RESULT([no]) Chris@40: CFLAGS="$xiph_stack_check_old_cflags" Chris@40: ) Chris@40: ])# XIPH_GCC_STACK_PROTECTOR Chris@40: Chris@40: AC_DEFUN([XIPH_GXX_STACK_PROTECTOR], Chris@40: [AC_LANG_PUSH([C++]) Chris@40: AC_MSG_CHECKING([if $CXX supports stack smash protection]) Chris@40: xiph_stack_check_old_cflags="$CFLAGS" Chris@40: SSP_FLAGS="-fstack-protector --param ssp-buffer-size=4" Chris@40: CFLAGS=$SSP_FLAGS Chris@40: AC_TRY_LINK([ Chris@40: #include Chris@40: ], Chris@40: [puts("Hello, World!"); return 0;], Chris@40: AC_MSG_RESULT([yes]) Chris@40: CFLAGS="$xiph_stack_check_old_cflags $SSP_FLAGS", Chris@40: AC_MSG_RESULT([no]) Chris@40: CFLAGS="$xiph_stack_check_old_cflags" Chris@40: ) Chris@40: AC_LANG_POP([C++]) Chris@40: ])# XIPH_GXX_STACK_PROTECTOR