Use __builtin_trap for ABORT_INSTRUCTION.

This commit is contained in:
Roland McGrath 2014-07-31 13:07:19 -07:00
parent 23fe486beb
commit 9fe7e787ad
5 changed files with 95 additions and 1 deletions

View File

@ -1,5 +1,11 @@
2014-07-31 Roland McGrath <roland@hack.frob.com>
* config.h.in (HAVE_BUILTIN_TRAP): New #define to 0.
* configure.ac (libc_cv_builtin_trap): New test.
* configure: Regenerated.
* sysdeps/generic/abort-instr.h [HAVE_BUILTIN_TRAP]
(ABORT_INSTRUCTION): Define using __builtin_trap.
* nptl/pthreadP.h (SIGCANCEL, SIGTIMER, SIGSETXID, __xidcmd): Moved ...
* sysdeps/unix/sysv/linux/nptl-signals.h: ... to this new file.
* sysdeps/nptl/nptl-signals.h: New file.

View File

@ -249,6 +249,10 @@
/* The pt_chown binary is being built and used by grantpt. */
#define HAVE_PT_CHOWN 0
/* Define if the compiler supports __builtin_trap without
any external dependencies such as making a function call. */
#define HAVE_BUILTIN_TRAP 0
/* ports/sysdeps/mips/configure.in */
/* Define if using the IEEE 754-2008 NaN encoding on the MIPS target. */
#undef HAVE_MIPS_NAN2008

38
configure vendored
View File

@ -7003,6 +7003,44 @@ if test $libc_cv_ehdr_start = yes; then
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_trap with no external dependencies" >&5
$as_echo_n "checking for __builtin_trap with no external dependencies... " >&6; }
if ${libc_cv_builtin_trap+:} false; then :
$as_echo_n "(cached) " >&6
else
libc_cv_builtin_trap=no
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
__builtin_trap ()
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
libc_undefs=`$NM -u conftest.o |
LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
2>&5` || {
as_fn_error $? "confusing output from $NM -u" "$LINENO" 5
}
echo >&5 "libc_undefs='$libc_undefs'"
if test -z "$libc_undefs"; then
libc_cv_builtin_trap=yes
fi
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_builtin_trap" >&5
$as_echo "$libc_cv_builtin_trap" >&6; }
if test $libc_cv_builtin_trap = yes; then
$as_echo "#define HAVE_BUILTIN_TRAP 1" >>confdefs.h
fi
### End of automated tests.
### Now run sysdeps configure fragments.

View File

@ -1901,6 +1901,23 @@ if test $libc_cv_ehdr_start = yes; then
AC_DEFINE([HAVE_EHDR_START])
fi
AC_CACHE_CHECK(for __builtin_trap with no external dependencies,
libc_cv_builtin_trap, [dnl
libc_cv_builtin_trap=no
AC_TRY_COMPILE([], [__builtin_trap ()], [
libc_undefs=`$NM -u conftest.o |
LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
2>&AS_MESSAGE_LOG_FD` || {
AC_MSG_ERROR([confusing output from $NM -u])
}
echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
if test -z "$libc_undefs"; then
libc_cv_builtin_trap=yes
fi])])
if test $libc_cv_builtin_trap = yes; then
AC_DEFINE([HAVE_BUILTIN_TRAP])
fi
### End of automated tests.
### Now run sysdeps configure fragments.

View File

@ -1,2 +1,31 @@
/* Magic instruction to crash quickly and reliably. Generic/stub version.
Copyright (C) 2014 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _ABORT_INSTR_H
#define _ABORT_INSTR_H 1
/* If the compiler provides the generic way to generate the right
instruction, we can use that without any machine-specific knowledge. */
#if HAVE_BUILTIN_TRAP
# define ABORT_INSTRUCTION __builtin_trap ()
#else
/* We cannot give any generic instruction to crash the program.
abort() will have to make sure it never returns. */
abort will have to make sure it never returns. */
#endif
#endif /* abort-instr.h */