1 --- a/include/libunwind-ppc32.h
2 +++ b/include/libunwind-ppc32.h
3 @@ -81,6 +81,88 @@ typedef int64_t unw_sword_t;
5 typedef long double unw_tdep_fpreg_t;
9 +/* We can't include asm/ptrace.h here, as it conflicts with musl's definitions */
46 +#define PT_ORIG_R3 34
51 +#ifndef __powerpc64__
61 +#define PT_REGS_COUNT 44
63 +#define PT_FPR0 48 /* each FP reg occupies 2 slots in this space */
65 +#ifndef __powerpc64__
67 +#define PT_FPR31 (PT_FPR0 + 2*31)
68 +#define PT_FPSCR (PT_FPR0 + 2*32 + 1)
70 +#else /* __powerpc64__ */
72 +#define PT_FPSCR (PT_FPR0 + 32) /* each FP reg occupies 1 slot in 64-bit space */
75 +#define PT_VR0 82 /* each Vector reg occupies 2 slots in 64-bit */
76 +#define PT_VSCR (PT_VR0 + 32*2 + 1)
77 +#define PT_VRSAVE (PT_VR0 + 33*2)
81 + * Only store first 32 VSRs here. The second 32 VSRs in VR0-31
83 +#define PT_VSR0 150 /* each VSR reg occupies 2 slots in 64-bit */
84 +#define PT_VSR31 (PT_VSR0 + 2*31)
85 +#endif /* __powerpc64__ */
87 +#endif /* !__GLIBC__ */
92 --- a/include/libunwind-ppc64.h
93 +++ b/include/libunwind-ppc64.h
94 @@ -88,6 +88,88 @@ typedef struct {
100 +/* We can't include asm/ptrace.h here, as it conflicts with musl's definitions */
137 +#define PT_ORIG_R3 34
142 +#ifndef __powerpc64__
150 +#define PT_RESULT 43
152 +#define PT_REGS_COUNT 44
154 +#define PT_FPR0 48 /* each FP reg occupies 2 slots in this space */
156 +#ifndef __powerpc64__
158 +#define PT_FPR31 (PT_FPR0 + 2*31)
159 +#define PT_FPSCR (PT_FPR0 + 2*32 + 1)
161 +#else /* __powerpc64__ */
163 +#define PT_FPSCR (PT_FPR0 + 32) /* each FP reg occupies 1 slot in 64-bit space */
166 +#define PT_VR0 82 /* each Vector reg occupies 2 slots in 64-bit */
167 +#define PT_VSCR (PT_VR0 + 32*2 + 1)
168 +#define PT_VRSAVE (PT_VR0 + 33*2)
172 + * Only store first 32 VSRs here. The second 32 VSRs in VR0-31
174 +#define PT_VSR0 150 /* each VSR reg occupies 2 slots in 64-bit */
175 +#define PT_VSR31 (PT_VSR0 + 2*31)
176 +#endif /* __powerpc64__ */
178 +#endif /* !__GLIBC__ */
183 --- a/src/ppc32/Ginit.c
184 +++ b/src/ppc32/Ginit.c
185 @@ -46,10 +46,15 @@ static void *
186 uc_addr (ucontext_t *uc, int reg)
190 + mcontext_t *mc = uc->uc_mcontext.uc_regs;
192 + mcontext_t *mc = &uc->uc_mcontext;
195 if ((unsigned) (reg - UNW_PPC32_R0) < 32)
196 #if defined(__linux__)
197 - addr = &uc->uc_mcontext.uc_regs->gregs[reg - UNW_PPC32_R0];
198 + addr = &mc->gregs[reg - UNW_PPC32_R0];
199 #elif defined(__FreeBSD__)
200 addr = &uc->uc_mcontext.mc_gpr[reg - UNW_PPC32_R0];
202 @@ -58,7 +63,7 @@ uc_addr (ucontext_t *uc, int reg)
203 if ( ((unsigned) (reg - UNW_PPC32_F0) < 32) &&
204 ((unsigned) (reg - UNW_PPC32_F0) >= 0) )
205 #if defined(__linux__)
206 - addr = &uc->uc_mcontext.uc_regs->fpregs.fpregs[reg - UNW_PPC32_F0];
207 + addr = &mc->fpregs.fpregs[reg - UNW_PPC32_F0];
208 #elif defined(__FreeBSD__)
209 addr = &uc->uc_mcontext.mc_fpreg[reg - UNW_PPC32_F0];
211 @@ -85,7 +90,7 @@ uc_addr (ucontext_t *uc, int reg)
214 #if defined(__linux__)
215 - addr = &uc->uc_mcontext.uc_regs->gregs[gregs_idx];
216 + addr = &mc->gregs[gregs_idx];
217 #elif defined(__FreeBSD__)
218 addr = &uc->uc_mcontext.mc_gpr[gregs_idx];
220 --- a/src/ppc32/ucontext_i.h
221 +++ b/src/ppc32/ucontext_i.h
222 @@ -44,8 +44,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DE
227 #define _UC_MCONTEXT_GPR(x) ( ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[x] - (void *)&dmy_ctxt) )
228 #define _UC_MCONTEXT_FPR(x) ( ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[x] - (void *)&dmy_ctxt) )
230 +#define _UC_MCONTEXT_GPR(x) ( ((void *)&dmy_ctxt.uc_mcontext.gregs[x] - (void *)&dmy_ctxt) )
231 +#define _UC_MCONTEXT_FPR(x) ( ((void *)&dmy_ctxt.uc_mcontext.fpregs.fpregs[x] - (void *)&dmy_ctxt) )
234 /* These are dummy structures used only for obtaining the offsets of the
235 various structure members. */