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