aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-03-01 15:56:36 +0100
committerFlorian Weimer <fweimer@redhat.com>2021-03-01 15:58:01 +0100
commit9fc813e1a37d2e2d5e85a97d5ac4fc1c15d839fb (patch)
tree62e5002b97acab6f776476c2325a37097693b0ea /sysdeps
parent764e9a0334350f52ab6953bef1db97f9b2e89ca5 (diff)
Implement <unwind-link.h> for dynamically loading the libgcc_s unwinder
This will be used to consolidate the libgcc_s access for backtrace and pthread_cancel. Unlike the existing backtrace implementations, it provides some hardening based on pointer mangling. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/alpha/unwind-arch.h28
-rw-r--r--sysdeps/arm/unwind-arch.h35
-rw-r--r--sysdeps/generic/unwind-arch.h27
-rw-r--r--sysdeps/generic/unwind-link.h106
-rw-r--r--sysdeps/i386/unwind-arch.h39
-rw-r--r--sysdeps/ia64/unwind-arch.h32
-rw-r--r--sysdeps/m68k/m680x0/unwind-arch.h26
-rw-r--r--sysdeps/m68k/unwind-arch.h35
-rw-r--r--sysdeps/mach/hurd/fork.c3
-rw-r--r--sysdeps/mips/unwind-arch.h (renamed from sysdeps/unix/sysv/linux/mips/unwind-arch.h)17
-rw-r--r--sysdeps/nptl/fork.c3
-rw-r--r--sysdeps/powerpc/powerpc32/unwind-arch.h28
-rw-r--r--sysdeps/s390/unwind-arch.h28
-rw-r--r--sysdeps/sh/unwind-arch.h28
-rw-r--r--sysdeps/sparc/unwind-arch.h28
15 files changed, 447 insertions, 16 deletions
diff --git a/sysdeps/alpha/unwind-arch.h b/sysdeps/alpha/unwind-arch.h
new file mode 100644
index 0000000000..9cb37fa604
--- /dev/null
+++ b/sysdeps/alpha/unwind-arch.h
@@ -0,0 +1,28 @@
+/* Dynamic loading of the libgcc unwinder. alpha customization.
+ Copyright (C) 2021 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
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _ARCH_UNWIND_LINK_H
+#define _ARCH_UNWIND_LINK_H
+
+#define UNWIND_LINK_GETIP 1
+#define UNWIND_LINK_FRAME_STATE_FOR 1
+#define UNWIND_LINK_FRAME_ADJUSTMENT 0
+#define UNWIND_LINK_EXTRA_FIELDS
+#define UNWIND_LINK_EXTRA_INIT
+
+#endif /* _ARCH_UNWIND_LINK_H */
diff --git a/sysdeps/arm/unwind-arch.h b/sysdeps/arm/unwind-arch.h
new file mode 100644
index 0000000000..fcf889b3c7
--- /dev/null
+++ b/sysdeps/arm/unwind-arch.h
@@ -0,0 +1,35 @@
+/* Dynamic loading of the libgcc unwinder. Arm customization.
+ Copyright (C) 2021 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
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _ARCH_UNWIND_LINK_H
+#define _ARCH_UNWIND_LINK_H
+
+/* On arm, _Unwind_GetIP is a macro. */
+#define UNWIND_LINK_GETIP 0
+
+#define UNWIND_LINK_FRAME_STATE_FOR 0
+#define UNWIND_LINK_FRAME_ADJUSTMENT 0
+#define UNWIND_LINK_EXTRA_FIELDS \
+ __typeof (_Unwind_VRS_Get) *ptr__Unwind_VRS_Get;
+#define UNWIND_LINK_EXTRA_INIT \
+ local.ptr__Unwind_VRS_Get \
+ = __libc_dlsym (local_libgcc_handle, "_Unwind_VRS_Get"); \
+ assert (local.ptr__Unwind_VRS_Get != NULL); \
+ PTR_MANGLE (local.ptr__Unwind_VRS_Get);
+
+#endif /* _ARCH_UNWIND_LINK_H */
diff --git a/sysdeps/generic/unwind-arch.h b/sysdeps/generic/unwind-arch.h
index feda585e8d..ead6674279 100644
--- a/sysdeps/generic/unwind-arch.h
+++ b/sysdeps/generic/unwind-arch.h
@@ -1,5 +1,5 @@
-/* Return backtrace of current program state. Arch-specific bits.
- Copyright (C) 2020-2021 Free Software Foundation, Inc.
+/* Dynamic loading of the libgcc unwinder. Generic version of parameters.
+ Copyright (C) 2021 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
@@ -16,15 +16,20 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#ifndef _UNWIND_ARCH_H
-#define _UNWIND_ARCH_H
+#ifndef _ARCH_UNWIND_LINK_H
+#define _ARCH_UNWIND_LINK_H
-#include <unwind.h>
+/* The _Unwind_GetIP function is supported. */
+#define UNWIND_LINK_GETIP 1
-static inline void *
-unwind_arch_adjustment (void *prev, void *addr)
-{
- return addr;
-}
+/* The __frame_state_for function is needed and re-exported from glibc. */
+#define UNWIND_LINK_FRAME_STATE_FOR 0
-#endif
+/* No adjustment of the is needed. */
+#define UNWIND_LINK_FRAME_ADJUSTMENT 0
+
+/* There are no extra fields in struct unwind_link in the generic version. */
+#define UNWIND_LINK_EXTRA_FIELDS
+#define UNWIND_LINK_EXTRA_INIT
+
+#endif /* _ARCH_UNWIND_LINK_H */
diff --git a/sysdeps/generic/unwind-link.h b/sysdeps/generic/unwind-link.h
new file mode 100644
index 0000000000..3527cebe2d
--- /dev/null
+++ b/sysdeps/generic/unwind-link.h
@@ -0,0 +1,106 @@
+/* Dynamic loading of the libgcc unwinder. Generic version.
+ Copyright (C) 2021 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
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _UNWIND_LINK_H
+#define _UNWIND_LINK_H
+
+#include <unwind.h>
+#include <unwind-arch.h>
+
+#if !UNWIND_LINK_FRAME_ADJUSTMENT
+static inline void *
+unwind_arch_adjustment (void *prev, void *addr)
+{
+ return addr;
+}
+#endif
+
+#ifdef SHARED
+# include <sysdep.h>
+# include <unwind-resume.h>
+
+# if UNWIND_LINK_FRAME_STATE_FOR
+struct frame_state;
+# endif
+
+struct unwind_link
+{
+ __typeof (_Unwind_Backtrace) *ptr__Unwind_Backtrace;
+ __typeof (_Unwind_ForcedUnwind) *ptr__Unwind_ForcedUnwind;
+ __typeof (_Unwind_GetCFA) *ptr__Unwind_GetCFA;
+# if UNWIND_LINK_GETIP
+ __typeof (_Unwind_GetIP) *ptr__Unwind_GetIP;
+# endif
+ __typeof (_Unwind_Resume) *ptr__Unwind_Resume;
+#if UNWIND_LINK_FRAME_STATE_FOR
+ struct frame_state *(*ptr___frame_state_for) (void *, struct frame_state *);
+#endif
+ _Unwind_Reason_Code (*ptr_personality) PERSONALITY_PROTO;
+ UNWIND_LINK_EXTRA_FIELDS
+};
+
+/* Return a pointer to the implementation, or NULL on failure. */
+struct unwind_link *__libc_unwind_link_get (void);
+libc_hidden_proto (__libc_unwind_link_get)
+
+/* UNWIND_LINK_PTR returns the stored function pointer NAME from the
+ cached unwind link OBJ (which was previously returned by
+ __libc_unwind_link_get). */
+# ifdef PTR_DEMANGLE
+# define UNWIND_LINK_PTR(obj, name, ...) \
+ ({ \
+ __typeof ((obj)->ptr_##name) __unwind_fptr = (obj)->ptr_##name; \
+ PTR_DEMANGLE (__unwind_fptr); \
+ __unwind_fptr; \
+ })
+# else /* !PTR_DEMANGLE */
+# define UNWIND_LINK_PTR(obj, name, ...) ((obj)->ptr_##name)
+# endif
+
+/* Called from fork, in the new subprocess. */
+void __libc_unwind_link_after_fork (void);
+
+/* Called from __libc_freeres. */
+void __libc_unwind_link_freeres (void) attribute_hidden;
+
+#else /* !SHARED */
+
+/* Dummy implementation so that the code can be shared with the SHARED
+ version. */
+struct unwind_link;
+static inline struct unwind_link *
+__libc_unwind_link_get (void)
+{
+ /* Return something that is not a null pointer, so that error checks
+ succeed. */
+ return (struct unwind_link *) 1;
+}
+
+/* Directly call the static implementation. */
+# define UNWIND_LINK_PTR(obj, name, ...) \
+ ((void) (obj), &name)
+
+static inline void
+__libc_unwind_link_after_fork (void)
+{
+ /* No need to clean up if the unwinder is statically linked. */
+}
+
+#endif /* !SHARED */
+
+#endif /* _UNWIND_LINK_H */
diff --git a/sysdeps/i386/unwind-arch.h b/sysdeps/i386/unwind-arch.h
new file mode 100644
index 0000000000..01c74fe814
--- /dev/null
+++ b/sysdeps/i386/unwind-arch.h
@@ -0,0 +1,39 @@
+/* Dynamic loading of the libgcc unwinder. i386 customization.
+ Copyright (C) 2021 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
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _ARCH_UNWIND_LINK_H
+#define _ARCH_UNWIND_LINK_H
+
+#define UNWIND_LINK_GETIP 1
+#define UNWIND_LINK_FRAME_STATE_FOR 1
+#define UNWIND_LINK_FRAME_ADJUSTMENT 0
+#define UNWIND_LINK_EXTRA_FIELDS \
+ __typeof (_Unwind_GetGR) *ptr__Unwind_GetGR;
+#define UNWIND_LINK_EXTRA_INIT_SHARED \
+ local.ptr__Unwind_GetGR \
+ = __libc_dlsym (local_libgcc_handle, "_Unwind_GetGR"); \
+ assert (local.ptr__Unwind_GetGR != NULL);
+#ifdef PTR_MANGLE
+# define UNWIND_LINK_EXTRA_INIT \
+ UNWIND_LINK_EXTRA_INIT_SHARED \
+ PTR_MANGLE (local.ptr__Unwind_GetGR);
+#else
+# define UNWIND_LINK_EXTRA_INIT UNWIND_LINK_EXTRA_INIT_SHARED
+#endif
+
+#endif /* _ARCH_UNWIND_LINK_H */
diff --git a/sysdeps/ia64/unwind-arch.h b/sysdeps/ia64/unwind-arch.h
new file mode 100644
index 0000000000..df294dedbe
--- /dev/null
+++ b/sysdeps/ia64/unwind-arch.h
@@ -0,0 +1,32 @@
+/* Dynamic loading of the libgcc unwinder. ia64 customization.
+ Copyright (C) 2021 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
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _ARCH_UNWIND_LINK_H
+
+#define UNWIND_LINK_GETIP 1
+#define UNWIND_LINK_FRAME_STATE_FOR 1
+#define UNWIND_LINK_FRAME_ADJUSTMENT 0
+#define UNWIND_LINK_EXTRA_FIELDS \
+ __typeof (_Unwind_GetBSP) *ptr__Unwind_GetBSP;
+#define UNWIND_LINK_EXTRA_INIT \
+ local.ptr__Unwind_GetBSP \
+ = __libc_dlsym (local_libgcc_handle, "_Unwind_GetBSP"); \
+ assert (local.ptr__Unwind_GetBSP != NULL); \
+ PTR_MANGLE (local.ptr__Unwind_GetBSP);
+
+#endif /* _ARCH_UNWIND_LINK_H */
diff --git a/sysdeps/m68k/m680x0/unwind-arch.h b/sysdeps/m68k/m680x0/unwind-arch.h
new file mode 100644
index 0000000000..fea71d45ce
--- /dev/null
+++ b/sysdeps/m68k/m680x0/unwind-arch.h
@@ -0,0 +1,26 @@
+/* Dynamic loading of the libgcc unwinder. Baseline m68k customization.
+ Copyright (C) 2021 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
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _ARCH_UNWIND_LINK_H
+
+#include <sysdeps/m68k/unwind-arch.h>
+
+#undef UNWIND_LINK_FRAME_STATE_FOR
+#define UNWIND_LINK_FRAME_STATE_FOR 1
+
+#endif /* _ARCH_UNWIND_LINK_H */
diff --git a/sysdeps/m68k/unwind-arch.h b/sysdeps/m68k/unwind-arch.h
new file mode 100644
index 0000000000..37f1013c7e
--- /dev/null
+++ b/sysdeps/m68k/unwind-arch.h
@@ -0,0 +1,35 @@
+/* Dynamic loading of the libgcc unwinder. m68k customization.
+ Copyright (C) 2021 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
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _ARCH_UNWIND_LINK_H
+#define _ARCH_UNWIND_LINK_H
+
+#define UNWIND_LINK_GETIP 1
+#define UNWIND_LINK_FRAME_ADJUSTMENT 0
+#define UNWIND_LINK_EXTRA_FIELDS \
+ __typeof (_Unwind_GetGR) *ptr__Unwind_GetGR;
+#define UNWIND_LINK_EXTRA_INIT \
+ local.ptr__Unwind_GetGR \
+ = __libc_dlsym (local_libgcc_handle, "_Unwind_GetGR"); \
+ assert (local.ptr__Unwind_GetGR != NULL); \
+ PTR_MANGLE (local.ptr__Unwind_GetGR);
+
+/* This is overriden by the m680x0 variant. */
+#define UNWIND_LINK_FRAME_STATE_FOR 0
+
+#endif /* _ARCH_UNWIND_LINK_H */
diff --git a/sysdeps/mach/hurd/fork.c b/sysdeps/mach/hurd/fork.c
index fb6c7ee8b7..2b39f4e8b5 100644
--- a/sysdeps/mach/hurd/fork.c
+++ b/sysdeps/mach/hurd/fork.c
@@ -29,6 +29,7 @@
#include <tls.h>
#include <malloc/malloc-internal.h>
#include <nss/nss_database.h>
+#include <unwind-link.h>
#undef __fork
@@ -667,6 +668,8 @@ __fork (void)
__sigemptyset (&_hurd_global_sigstate->pending);
__sigemptyset (&ss->pending);
+ __libc_unwind_link_after_fork ();
+
/* Release malloc locks. */
_hurd_malloc_fork_child ();
call_function_static_weak (__malloc_fork_unlock_child);
diff --git a/sysdeps/unix/sysv/linux/mips/unwind-arch.h b/sysdeps/mips/unwind-arch.h
index 38bc60cde6..78de42e001 100644
--- a/sysdeps/unix/sysv/linux/mips/unwind-arch.h
+++ b/sysdeps/mips/unwind-arch.h
@@ -1,4 +1,4 @@
-/* Return backtrace of current program state. Arch-specific bits.
+/* Dynamic loading of the libgcc unwinder. MIPS customization.
Copyright (C) 2020-2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -16,10 +16,17 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#ifndef _UNWIND_ARCH_H
-#define _UNWIND_ARCH_H
+#ifndef _ARCH_UNWIND_LINK_H
+#define _ARCH_UNWIND_LINK_H
#include <stdint.h>
+#include <sys/syscall.h>
+
+#define UNWIND_LINK_GETIP 1
+#define UNWIND_LINK_FRAME_STATE_FOR 1
+#define UNWIND_LINK_FRAME_ADJUSTMENT 1
+#define UNWIND_LINK_EXTRA_FIELDS
+#define UNWIND_LINK_EXTRA_INIT
/* MIPS fallback code handle a frame where its FDE can not be obtained
(for instance a signal frame) by reading the kernel allocated signal frame
@@ -49,7 +56,7 @@ unwind_arch_adjustment (void *prev, void *addr)
24021061 li v0, 0x1061 (rt_sigreturn)
0000000c syscall
- or
+ or
24021017 li v0, 0x1017 (sigreturn)
0000000c syscall */
if (pc[1] != 0x0000000c)
@@ -64,4 +71,4 @@ unwind_arch_adjustment (void *prev, void *addr)
return addr;
}
-#endif
+#endif /* _ARCH_UNWIND_LINK_H */
diff --git a/sysdeps/nptl/fork.c b/sysdeps/nptl/fork.c
index 26703d958f..4fb4c2d254 100644
--- a/sysdeps/nptl/fork.c
+++ b/sysdeps/nptl/fork.c
@@ -33,6 +33,7 @@
#include <futex-internal.h>
#include <malloc/malloc-internal.h>
#include <nss/nss_database.h>
+#include <unwind-link.h>
static void
fresetlockfiles (void)
@@ -116,6 +117,8 @@ __libc_fork (void)
/* Reset the lock state in the multi-threaded case. */
if (multiple_threads)
{
+ __libc_unwind_link_after_fork ();
+
/* Release malloc locks. */
call_function_static_weak (__malloc_fork_unlock_child);
diff --git a/sysdeps/powerpc/powerpc32/unwind-arch.h b/sysdeps/powerpc/powerpc32/unwind-arch.h
new file mode 100644
index 0000000000..f2869ac3ae
--- /dev/null
+++ b/sysdeps/powerpc/powerpc32/unwind-arch.h
@@ -0,0 +1,28 @@
+/* Dynamic loading of the libgcc unwinder. powerpc customization.
+ Copyright (C) 2021 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
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _ARCH_UNWIND_LINK_H
+#define _ARCH_UNWIND_LINK_H
+
+#define UNWIND_LINK_GETIP 1
+#define UNWIND_LINK_FRAME_STATE_FOR 1
+#define UNWIND_LINK_FRAME_ADJUSTMENT 0
+#define UNWIND_LINK_EXTRA_FIELDS
+#define UNWIND_LINK_EXTRA_INIT
+
+#endif /* _ARCH_UNWIND_LINK_H */
diff --git a/sysdeps/s390/unwind-arch.h b/sysdeps/s390/unwind-arch.h
new file mode 100644
index 0000000000..64d976de03
--- /dev/null
+++ b/sysdeps/s390/unwind-arch.h
@@ -0,0 +1,28 @@
+/* Dynamic loading of the libgcc unwinder. S/390 customization.
+ Copyright (C) 2021 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
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _ARCH_UNWIND_LINK_H
+#define _ARCH_UNWIND_LINK_H
+
+#define UNWIND_LINK_GETIP 1
+#define UNWIND_LINK_FRAME_STATE_FOR 1
+#define UNWIND_LINK_FRAME_ADJUSTMENT 0
+#define UNWIND_LINK_EXTRA_FIELDS
+#define UNWIND_LINK_EXTRA_INIT
+
+#endif /* _ARCH_UNWIND_LINK_H */
diff --git a/sysdeps/sh/unwind-arch.h b/sysdeps/sh/unwind-arch.h
new file mode 100644
index 0000000000..8fdac6322b
--- /dev/null
+++ b/sysdeps/sh/unwind-arch.h
@@ -0,0 +1,28 @@
+/* Dynamic loading of the libgcc unwinder. SH customization.
+ Copyright (C) 2021 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
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _ARCH_UNWIND_LINK_H
+#define _ARCH_UNWIND_LINK_H
+
+#define UNWIND_LINK_GETIP 1
+#define UNWIND_LINK_FRAME_STATE_FOR 1
+#define UNWIND_LINK_FRAME_ADJUSTMENT 0
+#define UNWIND_LINK_EXTRA_FIELDS
+#define UNWIND_LINK_EXTRA_INIT
+
+#endif /* _ARCH_UNWIND_LINK_H */
diff --git a/sysdeps/sparc/unwind-arch.h b/sysdeps/sparc/unwind-arch.h
new file mode 100644
index 0000000000..299fa006be
--- /dev/null
+++ b/sysdeps/sparc/unwind-arch.h
@@ -0,0 +1,28 @@
+/* Dynamic loading of the libgcc unwinder. SPARC customization.
+ Copyright (C) 2021 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
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _ARCH_UNWIND_LINK_H
+#define _ARCH_UNWIND_LINK_H
+
+#define UNWIND_LINK_GETIP 1
+#define UNWIND_LINK_FRAME_STATE_FOR 1
+#define UNWIND_LINK_FRAME_ADJUSTMENT 0
+#define UNWIND_LINK_EXTRA_FIELDS
+#define UNWIND_LINK_EXTRA_INIT
+
+#endif /* _ARCH_UNWIND_LINK_H */