* [PATCH v2] Fix PTRACE_GETREGSET failure for compat inferiors on arm64
@ 2017-01-19 20:56 Kees Cook
0 siblings, 0 replies; only message in thread
From: Kees Cook @ 2017-01-19 20:56 UTC (permalink / raw)
To: gdb-patches; +Cc: Yao Qi, Doug Evans, brian.murray, matthias.klose
When running a 32-bit ARM inferior with a 32-bit ARM GDB on a 64-bit
AArch64 host, only VFP registers (NT_ARM_VFP) are available. The FPA
registers (NT_PRFPREG) are not available so GDB must not request them, as
this will fail with -EINVAL. This is most noticeably exposed when running
"generate-core-file":
(gdb) generate-core-file myprog.core
Unable to fetch the floating point registers.: Invalid argument.
ptrace(PTRACE_GETREGSET, 27642, NT_FPREGSET, 0xffcc67f0) = -1 EINVAL (Invalid argument)
gdb/ChangeLog:
2016-12-19 Kees Cook <keescook@google.com>
* gdb/arm-linux-nat.c: Skip soft-float registers when using hard-float.
---
v2:
- check have_fpa_registers instead, dropped needless other change: qiyaoltc
---
gdb/arm-linux-nat.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index d11bdc6..12a3fa9 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -384,17 +384,19 @@ arm_linux_fetch_inferior_registers (struct target_ops *ops,
if (-1 == regno)
{
fetch_regs (regcache);
- fetch_fpregs (regcache);
if (tdep->have_wmmx_registers)
fetch_wmmx_regs (regcache);
if (tdep->vfp_register_count > 0)
fetch_vfp_regs (regcache);
+ if (tdep->have_fpa_registers)
+ fetch_fpregs (regcache);
}
- else
+ else
{
if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM)
fetch_regs (regcache);
- else if (regno >= ARM_F0_REGNUM && regno <= ARM_FPS_REGNUM)
+ else if (tdep->vfp_register_count == 0
+ && regno >= ARM_F0_REGNUM && regno <= ARM_FPS_REGNUM)
fetch_fpregs (regcache);
else if (tdep->have_wmmx_registers
&& regno >= ARM_WR0_REGNUM && regno <= ARM_WCGR7_REGNUM)
@@ -420,11 +422,12 @@ arm_linux_store_inferior_registers (struct target_ops *ops,
if (-1 == regno)
{
store_regs (regcache);
- store_fpregs (regcache);
if (tdep->have_wmmx_registers)
store_wmmx_regs (regcache);
if (tdep->vfp_register_count > 0)
store_vfp_regs (regcache);
+ if (tdep->have_fpa_registers)
+ store_fpregs (regcache);
}
else
{
--
2.7.4
--
Kees Cook
Nexus Security
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-01-19 20:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-19 20:56 [PATCH v2] Fix PTRACE_GETREGSET failure for compat inferiors on arm64 Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox