2016-01-04 16:05:18 +00:00
|
|
|
/* Copyright (C) 2003-2016 Free Software Foundation, Inc.
|
2003-07-22 23:56:53 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
Contributed by Jakub Jelinek <jakub@redhat.com>.
|
|
|
|
|
|
|
|
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
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
|
|
|
not, see <http://www.gnu.org/licenses/>. */
|
2003-07-22 23:56:53 +00:00
|
|
|
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unwind.h>
|
2012-04-26 03:48:48 +00:00
|
|
|
#include <gnu/lib-names.h>
|
2014-12-16 23:14:03 +00:00
|
|
|
#include <sysdep.h>
|
2015-01-05 22:01:49 +00:00
|
|
|
#include <unwind-resume.h>
|
2003-07-22 23:56:53 +00:00
|
|
|
|
|
|
|
|
2015-01-05 22:01:49 +00:00
|
|
|
void (*__libgcc_s_resume) (struct _Unwind_Exception *exc)
|
|
|
|
attribute_hidden __attribute__ ((noreturn));
|
|
|
|
|
|
|
|
static _Unwind_Reason_Code (*libgcc_s_personality) PERSONALITY_PROTO;
|
|
|
|
|
|
|
|
void attribute_hidden __attribute__ ((cold))
|
|
|
|
__libgcc_s_init (void)
|
2003-07-22 23:56:53 +00:00
|
|
|
{
|
|
|
|
void *resume, *personality;
|
|
|
|
void *handle;
|
|
|
|
|
2009-11-03 22:52:01 +00:00
|
|
|
handle = __libc_dlopen (LIBGCC_S_SO);
|
2003-07-22 23:56:53 +00:00
|
|
|
|
|
|
|
if (handle == NULL
|
|
|
|
|| (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL
|
|
|
|
|| (personality = __libc_dlsym (handle, "__gcc_personality_v0")) == NULL)
|
2014-05-09 17:05:29 +00:00
|
|
|
__libc_fatal (LIBGCC_S_SO
|
|
|
|
" must be installed for pthread_cancel to work\n");
|
2003-07-22 23:56:53 +00:00
|
|
|
|
2015-02-08 17:46:00 +00:00
|
|
|
#ifdef PTR_MANGLE
|
2014-12-16 23:14:03 +00:00
|
|
|
PTR_MANGLE (resume);
|
2015-02-08 17:46:00 +00:00
|
|
|
#endif
|
2015-01-05 22:01:49 +00:00
|
|
|
__libgcc_s_resume = resume;
|
2015-02-08 17:46:00 +00:00
|
|
|
#ifdef PTR_MANGLE
|
2014-12-16 23:14:03 +00:00
|
|
|
PTR_MANGLE (personality);
|
2015-02-08 17:46:00 +00:00
|
|
|
#endif
|
2003-07-22 23:56:53 +00:00
|
|
|
libgcc_s_personality = personality;
|
|
|
|
}
|
|
|
|
|
2015-01-05 22:01:49 +00:00
|
|
|
#if !HAVE_ARCH_UNWIND_RESUME
|
2003-07-22 23:56:53 +00:00
|
|
|
void
|
|
|
|
_Unwind_Resume (struct _Unwind_Exception *exc)
|
|
|
|
{
|
2015-01-05 22:01:49 +00:00
|
|
|
if (__glibc_unlikely (__libgcc_s_resume == NULL))
|
|
|
|
__libgcc_s_init ();
|
2014-12-16 23:14:03 +00:00
|
|
|
|
2015-01-05 22:01:49 +00:00
|
|
|
__typeof (__libgcc_s_resume) resume = __libgcc_s_resume;
|
2015-02-08 17:35:54 +00:00
|
|
|
#ifdef PTR_DEMANGLE
|
2014-12-16 23:14:03 +00:00
|
|
|
PTR_DEMANGLE (resume);
|
2015-02-08 17:35:54 +00:00
|
|
|
#endif
|
2014-12-16 23:14:03 +00:00
|
|
|
(*resume) (exc);
|
2003-07-22 23:56:53 +00:00
|
|
|
}
|
2015-01-05 22:01:49 +00:00
|
|
|
#endif
|
2003-07-22 23:56:53 +00:00
|
|
|
|
|
|
|
_Unwind_Reason_Code
|
2015-01-05 22:01:49 +00:00
|
|
|
__gcc_personality_v0 PERSONALITY_PROTO
|
2003-07-22 23:56:53 +00:00
|
|
|
{
|
2014-02-10 13:45:42 +00:00
|
|
|
if (__glibc_unlikely (libgcc_s_personality == NULL))
|
2015-01-05 22:01:49 +00:00
|
|
|
__libgcc_s_init ();
|
2014-12-16 23:14:03 +00:00
|
|
|
|
|
|
|
__typeof (libgcc_s_personality) personality = libgcc_s_personality;
|
2015-02-08 17:35:54 +00:00
|
|
|
#ifdef PTR_DEMANGLE
|
2014-12-16 23:14:03 +00:00
|
|
|
PTR_DEMANGLE (personality);
|
2015-02-08 17:35:54 +00:00
|
|
|
#endif
|
2015-01-05 22:01:49 +00:00
|
|
|
return (*personality) PERSONALITY_ARGS;
|
2003-07-22 23:56:53 +00:00
|
|
|
}
|