]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/generic/unwind-link.h
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / generic / unwind-link.h
CommitLineData
9fc813e1 1/* Dynamic loading of the libgcc unwinder. Generic version.
6d7e8eda 2 Copyright (C) 2021-2023 Free Software Foundation, Inc.
9fc813e1
FW
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _UNWIND_LINK_H
20#define _UNWIND_LINK_H
21
22#include <unwind.h>
23#include <unwind-arch.h>
24
25#if !UNWIND_LINK_FRAME_ADJUSTMENT
26static inline void *
27unwind_arch_adjustment (void *prev, void *addr)
28{
29 return addr;
30}
31#endif
32
33#ifdef SHARED
88f4b692 34# include <pointer_guard.h>
9fc813e1
FW
35# include <unwind-resume.h>
36
37# if UNWIND_LINK_FRAME_STATE_FOR
38struct frame_state;
39# endif
40
41struct unwind_link
42{
43 __typeof (_Unwind_Backtrace) *ptr__Unwind_Backtrace;
44 __typeof (_Unwind_ForcedUnwind) *ptr__Unwind_ForcedUnwind;
45 __typeof (_Unwind_GetCFA) *ptr__Unwind_GetCFA;
46# if UNWIND_LINK_GETIP
47 __typeof (_Unwind_GetIP) *ptr__Unwind_GetIP;
48# endif
49 __typeof (_Unwind_Resume) *ptr__Unwind_Resume;
50#if UNWIND_LINK_FRAME_STATE_FOR
51 struct frame_state *(*ptr___frame_state_for) (void *, struct frame_state *);
52#endif
53 _Unwind_Reason_Code (*ptr_personality) PERSONALITY_PROTO;
54 UNWIND_LINK_EXTRA_FIELDS
55};
56
57/* Return a pointer to the implementation, or NULL on failure. */
58struct unwind_link *__libc_unwind_link_get (void);
59libc_hidden_proto (__libc_unwind_link_get)
60
61/* UNWIND_LINK_PTR returns the stored function pointer NAME from the
62 cached unwind link OBJ (which was previously returned by
63 __libc_unwind_link_get). */
58548b9d 64# define UNWIND_LINK_PTR(obj, name, ...) \
9fc813e1
FW
65 ({ \
66 __typeof ((obj)->ptr_##name) __unwind_fptr = (obj)->ptr_##name; \
67 PTR_DEMANGLE (__unwind_fptr); \
68 __unwind_fptr; \
69 })
9fc813e1
FW
70
71/* Called from fork, in the new subprocess. */
72void __libc_unwind_link_after_fork (void);
73
74/* Called from __libc_freeres. */
75void __libc_unwind_link_freeres (void) attribute_hidden;
76
77#else /* !SHARED */
78
79/* Dummy implementation so that the code can be shared with the SHARED
80 version. */
81struct unwind_link;
82static inline struct unwind_link *
83__libc_unwind_link_get (void)
84{
85 /* Return something that is not a null pointer, so that error checks
86 succeed. */
87 return (struct unwind_link *) 1;
88}
89
90/* Directly call the static implementation. */
91# define UNWIND_LINK_PTR(obj, name, ...) \
92 ((void) (obj), &name)
93
94static inline void
95__libc_unwind_link_after_fork (void)
96{
97 /* No need to clean up if the unwinder is statically linked. */
98}
99
100#endif /* !SHARED */
101
102#endif /* _UNWIND_LINK_H */