]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/mips/unwind-arch.h
1 /* Return backtrace of current program state. Arch-specific bits.
2 Copyright (C) 2020-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
19 #ifndef _UNWIND_ARCH_H
20 #define _UNWIND_ARCH_H
24 /* MIPS fallback code handle a frame where its FDE can not be obtained
25 (for instance a signal frame) by reading the kernel allocated signal frame
26 and adding '2' to the value of 'sc_pc' [1]. The added value is used to
27 recognize an end of an EH region on mips16 [2].
29 The idea here is to adjust the obtained signal frame ADDR value and remove
30 the libgcc added value by checking if the previous frame is a signal frame
33 [1] libgcc/config/mips/linux-unwind.h from gcc code.
34 [2] gcc/config/mips/mips.h from gcc code. */
37 unwind_arch_adjustment (void *prev
, void *addr
)
39 uint32_t *pc
= (uint32_t *) prev
;
44 /* For MIPS16 or microMIPS frame libgcc makes no adjustment. */
45 if ((uintptr_t) pc
& 0x3)
48 /* The vDSO containes either
50 24021061 li v0, 0x1061 (rt_sigreturn)
53 24021017 li v0, 0x1017 (sigreturn)
55 if (pc
[1] != 0x0000000c)
57 #if _MIPS_SIM == _ABIO32
58 if (pc
[0] == (0x24020000 | __NR_sigreturn
))
59 return (void *) ((uintptr_t) addr
- 2);
61 if (pc
[0] == (0x24020000 | __NR_rt_sigreturn
))
62 return (void *) ((uintptr_t) addr
- 2);