004-ppc-musl.patch 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. --- a/include/libunwind-ppc32.h
  2. +++ b/include/libunwind-ppc32.h
  3. @@ -81,6 +81,88 @@ typedef int64_t unw_sword_t;
  4. typedef long double unw_tdep_fpreg_t;
  5. +#ifndef __GLIBC__
  6. +
  7. +/* We can't include asm/ptrace.h here, as it conflicts with musl's definitions */
  8. +
  9. +#define PT_R0 0
  10. +#define PT_R1 1
  11. +#define PT_R2 2
  12. +#define PT_R3 3
  13. +#define PT_R4 4
  14. +#define PT_R5 5
  15. +#define PT_R6 6
  16. +#define PT_R7 7
  17. +#define PT_R8 8
  18. +#define PT_R9 9
  19. +#define PT_R10 10
  20. +#define PT_R11 11
  21. +#define PT_R12 12
  22. +#define PT_R13 13
  23. +#define PT_R14 14
  24. +#define PT_R15 15
  25. +#define PT_R16 16
  26. +#define PT_R17 17
  27. +#define PT_R18 18
  28. +#define PT_R19 19
  29. +#define PT_R20 20
  30. +#define PT_R21 21
  31. +#define PT_R22 22
  32. +#define PT_R23 23
  33. +#define PT_R24 24
  34. +#define PT_R25 25
  35. +#define PT_R26 26
  36. +#define PT_R27 27
  37. +#define PT_R28 28
  38. +#define PT_R29 29
  39. +#define PT_R30 30
  40. +#define PT_R31 31
  41. +
  42. +#define PT_NIP 32
  43. +#define PT_MSR 33
  44. +#define PT_ORIG_R3 34
  45. +#define PT_CTR 35
  46. +#define PT_LNK 36
  47. +#define PT_XER 37
  48. +#define PT_CCR 38
  49. +#ifndef __powerpc64__
  50. +#define PT_MQ 39
  51. +#else
  52. +#define PT_SOFTE 39
  53. +#endif
  54. +#define PT_TRAP 40
  55. +#define PT_DAR 41
  56. +#define PT_DSISR 42
  57. +#define PT_RESULT 43
  58. +#define PT_DSCR 44
  59. +#define PT_REGS_COUNT 44
  60. +
  61. +#define PT_FPR0 48 /* each FP reg occupies 2 slots in this space */
  62. +
  63. +#ifndef __powerpc64__
  64. +
  65. +#define PT_FPR31 (PT_FPR0 + 2*31)
  66. +#define PT_FPSCR (PT_FPR0 + 2*32 + 1)
  67. +
  68. +#else /* __powerpc64__ */
  69. +
  70. +#define PT_FPSCR (PT_FPR0 + 32) /* each FP reg occupies 1 slot in 64-bit space */
  71. +
  72. +
  73. +#define PT_VR0 82 /* each Vector reg occupies 2 slots in 64-bit */
  74. +#define PT_VSCR (PT_VR0 + 32*2 + 1)
  75. +#define PT_VRSAVE (PT_VR0 + 33*2)
  76. +
  77. +
  78. +/*
  79. + * Only store first 32 VSRs here. The second 32 VSRs in VR0-31
  80. + */
  81. +#define PT_VSR0 150 /* each VSR reg occupies 2 slots in 64-bit */
  82. +#define PT_VSR31 (PT_VSR0 + 2*31)
  83. +#endif /* __powerpc64__ */
  84. +
  85. +#endif /* !__GLIBC__ */
  86. +
  87. typedef enum
  88. {
  89. UNW_PPC32_R0,
  90. --- a/include/libunwind-ppc64.h
  91. +++ b/include/libunwind-ppc64.h
  92. @@ -88,6 +88,88 @@ typedef struct {
  93. uint64_t halves[2];
  94. } unw_tdep_vreg_t;
  95. +#ifndef __GLIBC__
  96. +
  97. +/* We can't include asm/ptrace.h here, as it conflicts with musl's definitions */
  98. +
  99. +#define PT_R0 0
  100. +#define PT_R1 1
  101. +#define PT_R2 2
  102. +#define PT_R3 3
  103. +#define PT_R4 4
  104. +#define PT_R5 5
  105. +#define PT_R6 6
  106. +#define PT_R7 7
  107. +#define PT_R8 8
  108. +#define PT_R9 9
  109. +#define PT_R10 10
  110. +#define PT_R11 11
  111. +#define PT_R12 12
  112. +#define PT_R13 13
  113. +#define PT_R14 14
  114. +#define PT_R15 15
  115. +#define PT_R16 16
  116. +#define PT_R17 17
  117. +#define PT_R18 18
  118. +#define PT_R19 19
  119. +#define PT_R20 20
  120. +#define PT_R21 21
  121. +#define PT_R22 22
  122. +#define PT_R23 23
  123. +#define PT_R24 24
  124. +#define PT_R25 25
  125. +#define PT_R26 26
  126. +#define PT_R27 27
  127. +#define PT_R28 28
  128. +#define PT_R29 29
  129. +#define PT_R30 30
  130. +#define PT_R31 31
  131. +
  132. +#define PT_NIP 32
  133. +#define PT_MSR 33
  134. +#define PT_ORIG_R3 34
  135. +#define PT_CTR 35
  136. +#define PT_LNK 36
  137. +#define PT_XER 37
  138. +#define PT_CCR 38
  139. +#ifndef __powerpc64__
  140. +#define PT_MQ 39
  141. +#else
  142. +#define PT_SOFTE 39
  143. +#endif
  144. +#define PT_TRAP 40
  145. +#define PT_DAR 41
  146. +#define PT_DSISR 42
  147. +#define PT_RESULT 43
  148. +#define PT_DSCR 44
  149. +#define PT_REGS_COUNT 44
  150. +
  151. +#define PT_FPR0 48 /* each FP reg occupies 2 slots in this space */
  152. +
  153. +#ifndef __powerpc64__
  154. +
  155. +#define PT_FPR31 (PT_FPR0 + 2*31)
  156. +#define PT_FPSCR (PT_FPR0 + 2*32 + 1)
  157. +
  158. +#else /* __powerpc64__ */
  159. +
  160. +#define PT_FPSCR (PT_FPR0 + 32) /* each FP reg occupies 1 slot in 64-bit space */
  161. +
  162. +
  163. +#define PT_VR0 82 /* each Vector reg occupies 2 slots in 64-bit */
  164. +#define PT_VSCR (PT_VR0 + 32*2 + 1)
  165. +#define PT_VRSAVE (PT_VR0 + 33*2)
  166. +
  167. +
  168. +/*
  169. + * Only store first 32 VSRs here. The second 32 VSRs in VR0-31
  170. + */
  171. +#define PT_VSR0 150 /* each VSR reg occupies 2 slots in 64-bit */
  172. +#define PT_VSR31 (PT_VSR0 + 2*31)
  173. +#endif /* __powerpc64__ */
  174. +
  175. +#endif /* !__GLIBC__ */
  176. +
  177. typedef enum
  178. {
  179. UNW_PPC64_R0,
  180. --- a/src/ppc32/Ginit.c
  181. +++ b/src/ppc32/Ginit.c
  182. @@ -46,10 +46,15 @@ static void *
  183. uc_addr (ucontext_t *uc, int reg)
  184. {
  185. void *addr;
  186. +#ifdef __GLIBC__
  187. + mcontext_t *mc = uc->uc_mcontext.uc_regs;
  188. +#else
  189. + mcontext_t *mc = &uc->uc_mcontext;
  190. +#endif
  191. if ((unsigned) (reg - UNW_PPC32_R0) < 32)
  192. #if defined(__linux__)
  193. - addr = &uc->uc_mcontext.uc_regs->gregs[reg - UNW_PPC32_R0];
  194. + addr = &mc->gregs[reg - UNW_PPC32_R0];
  195. #elif defined(__FreeBSD__)
  196. addr = &uc->uc_mcontext.mc_gpr[reg - UNW_PPC32_R0];
  197. #endif
  198. @@ -58,7 +63,7 @@ uc_addr (ucontext_t *uc, int reg)
  199. if ( ((unsigned) (reg - UNW_PPC32_F0) < 32) &&
  200. ((unsigned) (reg - UNW_PPC32_F0) >= 0) )
  201. #if defined(__linux__)
  202. - addr = &uc->uc_mcontext.uc_regs->fpregs.fpregs[reg - UNW_PPC32_F0];
  203. + addr = &mc->fpregs.fpregs[reg - UNW_PPC32_F0];
  204. #elif defined(__FreeBSD__)
  205. addr = &uc->uc_mcontext.mc_fpreg[reg - UNW_PPC32_F0];
  206. #endif
  207. @@ -85,7 +90,7 @@ uc_addr (ucontext_t *uc, int reg)
  208. return NULL;
  209. }
  210. #if defined(__linux__)
  211. - addr = &uc->uc_mcontext.uc_regs->gregs[gregs_idx];
  212. + addr = &mc->gregs[gregs_idx];
  213. #elif defined(__FreeBSD__)
  214. addr = &uc->uc_mcontext.mc_gpr[gregs_idx];
  215. #endif
  216. --- a/src/ppc32/ucontext_i.h
  217. +++ b/src/ppc32/ucontext_i.h
  218. @@ -44,8 +44,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DE
  219. //#define MQ_IDX 36
  220. #define LINK_IDX 36
  221. +#ifdef __GLIBC__
  222. #define _UC_MCONTEXT_GPR(x) ( ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[x] - (void *)&dmy_ctxt) )
  223. #define _UC_MCONTEXT_FPR(x) ( ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[x] - (void *)&dmy_ctxt) )
  224. +#else
  225. +#define _UC_MCONTEXT_GPR(x) ( ((void *)&dmy_ctxt.uc_mcontext.gregs[x] - (void *)&dmy_ctxt) )
  226. +#define _UC_MCONTEXT_FPR(x) ( ((void *)&dmy_ctxt.uc_mcontext.fpregs.fpregs[x] - (void *)&dmy_ctxt) )
  227. +#endif
  228. /* These are dummy structures used only for obtaining the offsets of the
  229. various structure members. */