annotate src/libsndfile-1.0.27/M4/stack_protect.m4 @ 83:ae30d91d2ffe

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