From 11a053f5caf95cf174f74fbe1a20100c7d2fa0d0 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 18 Jan 2017 10:07:50 -0800 Subject: [PATCH] use target dependent names for stack registers 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 7d1d934f..77a586ad 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 9876a549..3d40756e 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;