Blame sysdeps/gnu/unwind-resume.c

Packit 6c4009
/* Copyright (C) 2003-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Contributed by Jakub Jelinek <jakub@redhat.com>.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public License as
Packit 6c4009
   published by the Free Software Foundation; either version 2.1 of the
Packit 6c4009
   License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; see the file COPYING.LIB.  If
Packit 6c4009
   not, see <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <dlfcn.h>
Packit 6c4009
#include <stdio.h>
Packit 6c4009
#include <unwind.h>
Packit 6c4009
#include <gnu/lib-names.h>
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
#include <unwind-resume.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
void (*__libgcc_s_resume) (struct _Unwind_Exception *exc)
Packit 6c4009
  attribute_hidden __attribute__ ((noreturn));
Packit 6c4009
Packit 6c4009
static _Unwind_Reason_Code (*libgcc_s_personality) PERSONALITY_PROTO;
Packit 6c4009
Packit 6c4009
void attribute_hidden __attribute__ ((cold))
Packit 6c4009
__libgcc_s_init (void)
Packit 6c4009
{
Packit 6c4009
  void *resume, *personality;
Packit 6c4009
  void *handle;
Packit 6c4009
Packit 6c4009
  /* See include/dlfcn.h. Use of __libc_dlopen requires RTLD_NOW.  */
Packit 6c4009
  handle = __libc_dlopen (LIBGCC_S_SO);
Packit 6c4009
Packit 6c4009
  if (handle == NULL
Packit 6c4009
      || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL
Packit 6c4009
      || (personality = __libc_dlsym (handle, "__gcc_personality_v0")) == NULL)
Packit 6c4009
    __libc_fatal (LIBGCC_S_SO
Packit 6c4009
                  " must be installed for unwinding to work\n");
Packit 6c4009
Packit 6c4009
#ifdef PTR_MANGLE
Packit 6c4009
  PTR_MANGLE (resume);
Packit 6c4009
#endif
Packit 6c4009
  __libgcc_s_resume = resume;
Packit 6c4009
#ifdef PTR_MANGLE
Packit 6c4009
  PTR_MANGLE (personality);
Packit 6c4009
#endif
Packit 6c4009
  libgcc_s_personality = personality;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#if !HAVE_ARCH_UNWIND_RESUME
Packit 6c4009
void
Packit 6c4009
_Unwind_Resume (struct _Unwind_Exception *exc)
Packit 6c4009
{
Packit 6c4009
  if (__glibc_unlikely (__libgcc_s_resume == NULL))
Packit 6c4009
    __libgcc_s_init ();
Packit 6c4009
Packit 6c4009
  __typeof (__libgcc_s_resume) resume = __libgcc_s_resume;
Packit 6c4009
#ifdef PTR_DEMANGLE
Packit 6c4009
  PTR_DEMANGLE (resume);
Packit 6c4009
#endif
Packit 6c4009
  (*resume) (exc);
Packit 6c4009
}
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
_Unwind_Reason_Code
Packit 6c4009
__gcc_personality_v0 PERSONALITY_PROTO
Packit 6c4009
{
Packit 6c4009
  if (__glibc_unlikely (libgcc_s_personality == NULL))
Packit 6c4009
    __libgcc_s_init ();
Packit 6c4009
Packit 6c4009
  __typeof (libgcc_s_personality) personality = libgcc_s_personality;
Packit 6c4009
#ifdef PTR_DEMANGLE
Packit 6c4009
  PTR_DEMANGLE (personality);
Packit 6c4009
#endif
Packit 6c4009
  return (*personality) PERSONALITY_ARGS;
Packit 6c4009
}