]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Use __builtin_trap for ABORT_INSTRUCTION.
authorRoland McGrath <roland@hack.frob.com>
Thu, 31 Jul 2014 20:07:19 +0000 (13:07 -0700)
committerRoland McGrath <roland@hack.frob.com>
Thu, 31 Jul 2014 20:07:19 +0000 (13:07 -0700)
ChangeLog
config.h.in
configure
configure.ac
sysdeps/generic/abort-instr.h

index d50535c6fbacda159416edf371b513cd2e010b6e..e359c139d949f27ce567863a606abda025bd550a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index d612a04fe8ddfc11b6845fdd8fed5dd8fecd84cb..7da1a9f6f892e377242e672d7c10726f9629a417 100644 (file)
 /* 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
index c8d2967f9ea50910fc8ecad05e90efd16a55173a..646e0bc9af7c84b37cfab8cc902eaa6a344b54a8 100755 (executable)
--- a/configure
+++ b/configure
@@ -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.
 
index 566ecb276d42e36a9dc8d42ca01e5edf847c6378..e89faa0dfebf512c88a8bbb4f7eb200e0c44957e 100644 (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.
 
index 106a330b2b2ffd2cf84d563b20e8b8870012308a..4ac11d2ea54e94f44cc86b19a3e6badc4466cb62 100644 (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 */