When adjusting the stack for a DW_CFA_arg_size adjustment, ensure that
we use the target dependent register name as the generic name does not
necessarily map to the same register.  For example, on x86, ESP maps to
the eip register, which results in the wrong stack adjustment being
applied.
---
 src/x86/Gresume.c    | 4 ++--
 src/x86_64/Gresume.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/x86/Gresume.c b/src/x86/Gresume.c
index 7d1d934..77a586a 100644
--- a/src/x86/Gresume.c
+++ b/src/x86/Gresume.c
@@ -66,10 +66,10 @@ establish_machine_state (struct cursor *c)
 
   if (c->dwarf.args_size)
     {
-      if (tdep_access_reg (c, ESP, &val, 0) >= 0)
+      if (tdep_access_reg (c, UNW_X86_ESP, &val, 0) >= 0)
         {
           val += c->dwarf.args_size;
-          (*access_reg) (as, ESP, &val, 1, arg);
+          (*access_reg) (as, UNW_X86_ESP, &val, 1, arg);
         }
     }
   return 0;
diff --git a/src/x86_64/Gresume.c b/src/x86_64/Gresume.c
index 9876a54..3d40756 100644
--- a/src/x86_64/Gresume.c
+++ b/src/x86_64/Gresume.c
@@ -98,10 +98,10 @@ establish_machine_state (struct cursor *c)
 
   if (c->dwarf.args_size)
     {
-      if (tdep_access_reg (c, RSP, &val, 0) >= 0)
+      if (tdep_access_reg (c, UNW_X86_64_RSP, &val, 0) >= 0)
         {
           val += c->dwarf.args_size;
-          (*access_reg) (as, RSP, &val, 1, arg);
+          (*access_reg) (as, UNW_X86_64_RSP, &val, 1, arg);
         }
     }
   return 0;
-- 
2.11.0


_______________________________________________
Libunwind-devel mailing list
Libunwind-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/libunwind-devel

Reply via email to