From 2c8ce5dc9cec957457a221493c052e5f4596e622 Mon Sep 17 00:00:00 2001 From: yueyuankun Date: Thu, 12 Dec 2024 16:44:52 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E5=90=8C=E6=AD=A5pr]=20arm6?= =?UTF-8?q?4:=20Handle=20sp,=20lr,=20fp=20as=20DwReg=20in=20CfiExpr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-Handle-sp-lr-fp-as-DwReg-in-CfiExpr.patch | 127 ++++++++++++++++++ valgrind.spec | 10 +- 2 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 arm64-Handle-sp-lr-fp-as-DwReg-in-CfiExpr.patch diff --git a/arm64-Handle-sp-lr-fp-as-DwReg-in-CfiExpr.patch b/arm64-Handle-sp-lr-fp-as-DwReg-in-CfiExpr.patch new file mode 100644 index 0000000..3f74c61 --- /dev/null +++ b/arm64-Handle-sp-lr-fp-as-DwReg-in-CfiExpr.patch @@ -0,0 +1,127 @@ +From e1ff6760049df57935131059ec176db0b31b403c Mon Sep 17 00:00:00 2001 +From: wangshuo +Date: Fri, 23 Jun 2023 10:07:12 +0800 +Subject: [PATCH] arm64: Handle sp, lr, fp as DwReg in CfiExpr + +When copy_convert_CfiExpr_tree sees a DwReg on arm64 we simply call +I_die_here; This causes an issue in the case we really do have to handle +that case (see https://bugzilla.redhat.com/show_bug.cgi?id=1923493). + +Handle the stack pointer (sp), link register (x30) and frame pointer +(x29), +which we already keep in D3UnwindRegs, like we do for other +architectures +in evalCfiExpr and copy_convert_CfiExpr_tree. + +https://bugs.kde.org/show_bug.cgi?id=433898 +https://bugzilla.redhat.com/show_bug.cgi?id=1923493 +https://sourceware.org/git/?p=valgrind.git;a=commit;h=b92d30bb6de3aec40be9ad368f10f881e2b84ca7 + +--- + NEWS | 16 ++++++++++++++++ + coregrind/m_debuginfo/d3basics.c | 1 + + coregrind/m_debuginfo/debuginfo.c | 2 ++ + coregrind/m_debuginfo/priv_storage.h | 2 ++ + coregrind/m_debuginfo/readdwarf.c | 7 ++++++- + coregrind/m_debuginfo/storage.c | 2 ++ + 6 files changed, 29 insertions(+), 1 deletion(-) + +diff --git a/NEWS b/NEWS +index 71a7a01..2314773 100644 +--- a/NEWS ++++ b/NEWS +@@ -1,3 +1,19 @@ ++* ==================== FIXED BUGS ==================== ++ ++The following bugs have been fixed or resolved. Note that "n-i-bz" ++stands for "not in bugzilla" -- that is, a bug that was reported to us ++but never got a bugzilla entry. We encourage you to file bugs in ++bugzilla (https://bugs.kde.org/enter_bug.cgi?product=valgrind) rather ++than mailing the developers (or mailing lists) directly -- bugs that ++are not entered into bugzilla tend to get forgotten about or ignored. ++ ++To see details of a given bug, visit ++ https://bugs.kde.org/show_bug.cgi?id=XXXXXX ++where XXXXXX is the bug number as listed below. ++ ++433898 arm64: Handle sp, lr, fp as DwReg in CfiExpr ++ ++ + + Release 3.16.0 (27 May 2020) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +diff --git a/coregrind/m_debuginfo/d3basics.c b/coregrind/m_debuginfo/d3basics.c +index b6d13c1..9787b63 100644 +--- a/coregrind/m_debuginfo/d3basics.c ++++ b/coregrind/m_debuginfo/d3basics.c +@@ -424,6 +424,7 @@ static Bool get_Dwarf_Reg( /*OUT*/Addr* a, Word regno, const RegSummary* regs ) + if (regno == 30) { *a = regs->fp; return True; } + # elif defined(VGP_arm64_linux) + if (regno == 31) { *a = regs->sp; return True; } ++ if (regno == 29) { *a = regs->fp; return True; } + # else + # error "Unknown platform" + # endif +diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c +index 13e528e..0697640 100644 +--- a/coregrind/m_debuginfo/debuginfo.c ++++ b/coregrind/m_debuginfo/debuginfo.c +@@ -2875,7 +2875,9 @@ UWord evalCfiExpr ( const XArray* exprs, Int ix, + # elif defined(VGA_ppc32) || defined(VGA_ppc64be) \ + || defined(VGA_ppc64le) + # elif defined(VGP_arm64_linux) ++ case Creg_ARM64_SP: return eec->uregs->sp; + case Creg_ARM64_X30: return eec->uregs->x30; ++ case Creg_ARM64_X29: return eec->uregs->x29; + # else + # error "Unsupported arch" + # endif +diff --git a/coregrind/m_debuginfo/priv_storage.h b/coregrind/m_debuginfo/priv_storage.h +index 39456ec..ae44ca3 100644 +--- a/coregrind/m_debuginfo/priv_storage.h ++++ b/coregrind/m_debuginfo/priv_storage.h +@@ -415,7 +415,9 @@ typedef + Creg_ARM_R15, + Creg_ARM_R14, + Creg_ARM_R7, ++ Creg_ARM64_SP, + Creg_ARM64_X30, ++ Creg_ARM64_X29, + Creg_S390_IA, + Creg_S390_SP, + Creg_S390_FP, +diff --git a/coregrind/m_debuginfo/readdwarf.c b/coregrind/m_debuginfo/readdwarf.c +index 5701c50..511b854 100644 +--- a/coregrind/m_debuginfo/readdwarf.c ++++ b/coregrind/m_debuginfo/readdwarf.c +@@ -2541,7 +2541,12 @@ static Int copy_convert_CfiExpr_tree ( XArray* dstxa, + if (dwreg == srcuc->ra_reg) + return ML_(CfiExpr_CfiReg)( dstxa, Creg_IA_IP ); + # elif defined(VGA_arm64) +- I_die_here; ++ if (dwreg == SP_REG) ++ return ML_(CfiExpr_CfiReg)( dstxa, Creg_ARM64_SP ); ++ if (dwreg == FP_REG) ++ return ML_(CfiExpr_CfiReg)( dstxa, Creg_ARM64_X29 ); ++ if (dwreg == srcuc->ra_reg) ++ return ML_(CfiExpr_CfiReg)( dstxa, Creg_ARM64_X30 ); + # elif defined(VGA_ppc32) || defined(VGA_ppc64be) \ + || defined(VGA_ppc64le) + # else +diff --git a/coregrind/m_debuginfo/storage.c b/coregrind/m_debuginfo/storage.c +index 2a975dc..0b05c12 100644 +--- a/coregrind/m_debuginfo/storage.c ++++ b/coregrind/m_debuginfo/storage.c +@@ -1002,7 +1002,9 @@ static void ppCfiReg ( CfiReg reg ) + case Creg_ARM_R15: VG_(printf)("R15"); break; + case Creg_ARM_R14: VG_(printf)("R14"); break; + case Creg_ARM_R7: VG_(printf)("R7"); break; ++ case Creg_ARM64_SP: VG_(printf)("SP"); break; + case Creg_ARM64_X30: VG_(printf)("X30"); break; ++ case Creg_ARM64_X29: VG_(printf)("X29"); break; + case Creg_MIPS_RA: VG_(printf)("RA"); break; + case Creg_S390_IA: VG_(printf)("IA"); break; + case Creg_S390_SP: VG_(printf)("SP"); break; +-- +2.33.0 + diff --git a/valgrind.spec b/valgrind.spec index 95cdf85..0270868 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -17,7 +17,7 @@ Name: valgrind Version: 3.16.0 -Release: 5 +Release: 6 Epoch: 1 Summary: An instrumentation framework for building dynamic analysis tools License: GPLv2+ @@ -29,6 +29,7 @@ Patch2: valgrind-3.9.0-helgrind-race-supp.patch Patch3: valgrind-3.9.0-ldso-supp.patch Patch4: backport-Generate-a-ENOSYS-sys_ni_syscall-for-clone3-on-all-linux-arches.patch Patch5: valgrind-Implement-linux-rseq-syscall-as-ENOSYS.patch +Patch6: arm64-Handle-sp-lr-fp-as-DwReg-in-CfiExpr.patch BuildRequires: glibc glibc-devel gdb procps gcc-c++ perl(Getopt::Long) @@ -106,6 +107,13 @@ popd %{_mandir}/man1/* %changelog +* Thu Dec 12 2024 yueyuankun - 1:3.16.0-6 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:arm64: Handle sp, lr, fp as DwReg in CfiExpr + sync arm64-Handle-sp-lr-fp-as-DwReg-in-CfiExpr.patch + * Wed Jan 31 2024 peng.zou - 1:3.16.0-5 - Add ppc64le support -- Gitee