This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 064c75aa92 elf/coredump: correct register offset after xcp.regs update
064c75aa92 is described below

commit 064c75aa92cbf3dc720c1c58aa5eee034d8dad40
Author: chao an <[email protected]>
AuthorDate: Thu May 18 17:08:58 2023 +0800

    elf/coredump: correct register offset after xcp.regs update
    
    The offset should be calculated from pointer xcp.regs
    
    Signed-off-by: chao an <[email protected]>
---
 binfmt/libelf/libelf_coredump.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/binfmt/libelf/libelf_coredump.c b/binfmt/libelf/libelf_coredump.c
index 13462a720d..c0d5b28996 100644
--- a/binfmt/libelf/libelf_coredump.c
+++ b/binfmt/libelf/libelf_coredump.c
@@ -246,8 +246,20 @@ static void elf_emit_note_info(FAR struct elf_dumpinfo_s 
*cinfo)
 
       for (j = 0; j < nitems(status.pr_regs); j++)
         {
-          status.pr_regs[j] = *(uintptr_t *)((uint8_t *)tcb +
-                                             g_tcbinfo.reg_off.p[j]);
+          if (tcb->xcp.regs == NULL)
+            {
+              continue;
+            }
+
+          if (g_tcbinfo.reg_off.p[j] == UINT16_MAX)
+            {
+              status.pr_regs[j] = 0;
+            }
+          else
+            {
+              status.pr_regs[j] = *(uintptr_t *)((uint8_t *)tcb->xcp.regs +
+                                                 g_tcbinfo.reg_off.p[j]);
+            }
         }
 
       elf_emit(cinfo, &status, sizeof(status));

Reply via email to