patch-gcc_unwind-dw2_c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. $OpenBSD: patch-gcc_unwind-dw2_c,v 1.1.1.1 2011/11/14 13:00:57 pascal Exp $
  2. --- gcc/unwind-dw2.c.orig Sat Nov 12 13:51:04 2011
  3. +++ gcc/unwind-dw2.c Sat Nov 12 13:52:44 2011
  4. @@ -145,6 +145,25 @@ _Unwind_IsExtendedContext (struct _Unwind_Context *con
  5. {
  6. return context->flags & EXTENDED_CONTEXT_BIT;
  7. }
  8. +
  9. +#ifdef __sparc64__
  10. +
  11. +/* Figure out StackGhost cookie. */
  12. +_Unwind_Word uw_get_wcookie(void);
  13. +
  14. +asm(".text\n"
  15. + "uw_get_wcookie:\n"
  16. + " add %o7, %g0, %g4\n"
  17. + " save %sp, -176, %sp\n"
  18. + " save %sp, -176, %sp\n"
  19. + " flushw\n"
  20. + " restore\n"
  21. + " ldx [%sp + 2047 + 120], %g5\n"
  22. + " xor %g4, %g5, %i0\n"
  23. + " ret\n"
  24. + " restore\n");
  25. +#endif
  26. +
  27. /* Get the value of register INDEX as saved in CONTEXT. */
  28. @@ -167,6 +186,13 @@ _Unwind_GetGR (struct _Unwind_Context *context, int in
  29. if (_Unwind_IsExtendedContext (context) && context->by_value[index])
  30. return (_Unwind_Word) (_Unwind_Internal_Ptr) ptr;
  31. +#ifdef __sparc64__
  32. + /* _Unwind_Word and _Unwind_Ptr are the same size on sparc64 */
  33. + _Unwind_Word reg = * (_Unwind_Word *) ptr;
  34. + if (index == 15 || index == 31)
  35. + reg ^= uw_get_wcookie ();
  36. + return reg;
  37. +#else
  38. /* This will segfault if the register hasn't been saved. */
  39. if (size == sizeof(_Unwind_Ptr))
  40. return * (_Unwind_Ptr *) ptr;
  41. @@ -175,6 +201,7 @@ _Unwind_GetGR (struct _Unwind_Context *context, int in
  42. gcc_assert (size == sizeof(_Unwind_Word));
  43. return * (_Unwind_Word *) ptr;
  44. }
  45. +#endif
  46. }
  47. static inline void *