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