On SPARC the address of the call instruction is placed in %o7 and a
normal function return will jump to %o7 + 8, skipping the delay slot.
The diff below changes the low-level libunwind code to take this into
account.  This way the addresses seen by the unwinder are as expected
and the unwinder can find the correct information in the various
tables.

ok?


Index: lib/libunwind/src/Registers.hpp
===================================================================
RCS file: /cvs/src/lib/libunwind/src/Registers.hpp,v
retrieving revision 1.4
diff -u -p -r1.4 Registers.hpp
--- lib/libunwind/src/Registers.hpp     21 Oct 2018 05:08:35 -0000      1.4
+++ lib/libunwind/src/Registers.hpp     2 Feb 2019 16:11:16 -0000
@@ -2648,8 +2648,8 @@ public:
 
   uint64_t  getSP() const         { return _registers.__o[6] + 2047; }
   void      setSP(uint64_t value) { _registers.__o[6] = value - 2047; }
-  uint64_t  getIP() const         { return _registers.__o[7]; }
-  void      setIP(uint64_t value) { _registers.__o[7] = value; }
+  uint64_t  getIP() const         { return _registers.__o[7] + 8; }
+  void      setIP(uint64_t value) { _registers.__o[7] = value - 8; }
   uint64_t  getWCookie() const    { return _wcookie; }
 
 private:
@@ -2702,7 +2702,7 @@ inline uint64_t Registers_sparc64::getRe
 
   switch (regNum) {
   case UNW_REG_IP:
-    return _registers.__o[7];
+    return _registers.__o[7] + 8;
   case UNW_REG_SP:
     return _registers.__o[6] + 2047;
   }
@@ -2729,7 +2729,7 @@ inline void Registers_sparc64::setRegist
 
   switch (regNum) {
   case UNW_REG_IP:
-    _registers.__o[7] = value;
+    _registers.__o[7] = value - 8;
     return;
   case UNW_REG_SP:
     _registers.__o[6] = value - 2047;
Index: lib/libunwind/src/UnwindRegistersRestore.S
===================================================================
RCS file: /cvs/src/lib/libunwind/src/UnwindRegistersRestore.S,v
retrieving revision 1.4
diff -u -p -r1.4 UnwindRegistersRestore.S
--- lib/libunwind/src/UnwindRegistersRestore.S  21 Oct 2018 05:08:35 -0000      
1.4
+++ lib/libunwind/src/UnwindRegistersRestore.S  2 Feb 2019 16:11:16 -0000
@@ -669,7 +669,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9li
   ldx  [%o0 + 0xe8], %i5
   ldx  [%o0 + 0xf0], %i6
   ldx  [%o0 + 0xf8], %i7
-  jmpl %o7, %g0
+  jmpl %o7 + 8, %g0
    ldx [%o0 + 0x40], %o0
 
 #elif defined(__mips__) && defined(_ABIO32)

Reply via email to