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

xiaoxiang781216 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 63a11f84f41 arch/armv7-r,armv8-r: add CFI directives to the exception 
vectors
63a11f84f41 is described below

commit 63a11f84f41a04a46e532f611a070e7fecd96f53
Author: anjiahao <[email protected]>
AuthorDate: Sun Nov 29 01:08:42 2026 +0800

    arch/armv7-r,armv8-r: add CFI directives to the exception vectors
    
    The exception entry points set fp to zero, so an unwinder cannot walk
    past the handler frame and the abort handlers have no debug frame at
    all.  Set fp to the xcptcontext pointer that is passed to the handler,
    and annotate the vector bodies with .cfi_startproc/.cfi_def_cfa/
    .cfi_offset/.cfi_endproc so gdb and the backtrace code can unwind
    through the exception frame.
    
    Signed-off-by: anjiahao <[email protected]>
---
 arch/arm/src/armv7-r/arm_vectors.S | 36 ++++++++++++++++++++++++++++++++----
 arch/arm/src/armv8-r/arm_vectors.S | 36 ++++++++++++++++++++++++++++++++----
 2 files changed, 64 insertions(+), 8 deletions(-)

diff --git a/arch/arm/src/armv7-r/arm_vectors.S 
b/arch/arm/src/armv7-r/arm_vectors.S
index 648ea41d0e3..505c761e44f 100644
--- a/arch/arm/src/armv7-r/arm_vectors.S
+++ b/arch/arm/src/armv7-r/arm_vectors.S
@@ -378,6 +378,8 @@ arm_vectorsvc:
        .type   arm_vectordata, %function
 
 arm_vectordata:
+       .cfi_sections   .debug_frame
+       .cfi_startproc
 
        /* Save the LR and SPSR onto the SYS mode stack before switch. */
 
@@ -415,12 +417,16 @@ arm_vectordata:
         * void arm_dataabort(struct xcptcontext *xcp)
         */
 
-       mov             fp, #0                          /* Init frame pointer */
        mov             r0, sp                          /* Get r0=xcp */
        mrc             CP15_DFAR(r1)                   /* Get R1=DFAR */
        mrc             CP15_DFSR(r2)                   /* Get r2=DFSR */
        mov             r4, sp                          /* Save the SP in a 
preserved register */
        bic             sp, sp, #7                      /* Force 8-byte 
alignment */
+       mov             fp, r0
+       .cfi_def_cfa    fp, 0                           /* Register in fp, so 
we just set fp as frame */
+       .cfi_offset     pc, REG_PC * 4
+       .cfi_offset     sp, REG_SP * 4
+       .cfi_offset     lr, REG_LR * 4
        bl              arm_dataabort                   /* Call the handler */
        mov             sp, r4                          /* Restore the possibly 
unaligned stack pointer */
 
@@ -449,6 +455,7 @@ arm_vectordata:
        /* Restore the CPSR, SYS mode registers and return. */
 
        rfeia           r14
+       .cfi_endproc
        .size   arm_vectordata, . - arm_vectordata
 
        .align  5
@@ -469,6 +476,8 @@ arm_vectordata:
        .type   arm_vectorprefetch, %function
 
 arm_vectorprefetch:
+       .cfi_sections   .debug_frame
+       .cfi_startproc
 
        /* Save the LR and SPSR onto the SYS mode stack before switch. */
 
@@ -500,12 +509,16 @@ arm_vectorprefetch:
         * void arm_prefetchabort(struct xcptcontext *xcp)
         */
 
-       mov             fp, #0                          /* Init frame pointer */
        mov             r0, sp                          /* Get r0=xcp */
        mrc             CP15_IFAR(r1)                   /* Get R1=IFAR */
        mrc             CP15_IFSR(r2)                   /* Get r2=IFSR */
        mov             r4, sp                          /* Save the SP in a 
preserved register */
        bic             sp, sp, #7                      /* Force 8-byte 
alignment */
+       mov             fp, r0
+       .cfi_def_cfa    fp, 0                           /* Register in fp, so 
we just set fp as frame */
+       .cfi_offset     pc, REG_PC * 4
+       .cfi_offset     sp, REG_SP * 4
+       .cfi_offset     lr, REG_LR * 4
        bl              arm_prefetchabort               /* Call the handler */
        mov             sp, r4                          /* Restore the possibly 
unaligned stack pointer */
 
@@ -534,6 +547,7 @@ arm_vectorprefetch:
        /* Restore the CPSR, SYS mode registers and return. */
 
        rfeia           r14
+       .cfi_endproc
        .size   arm_vectorprefetch, . - arm_vectorprefetch
 
        .align  5
@@ -552,6 +566,8 @@ arm_vectorprefetch:
        .type   arm_vectorundefinsn, %function
 
 arm_vectorundefinsn:
+       .cfi_sections   .debug_frame
+       .cfi_startproc
 
        /* Save the LR and SPSR onto the SYS mode stack before switch. */
 
@@ -582,10 +598,14 @@ arm_vectorundefinsn:
         * void arm_undefinedinsn(struct xcptcontext *xcp)
         */
 
-       mov             fp, #0                          /* Init frame pointer */
        mov             r0, sp                          /* Get r0=xcp */
        mov             r4, sp                          /* Save the SP in a 
preserved register */
        bic             sp, sp, #7                      /* Force 8-byte 
alignment */
+       mov             fp, r0
+       .cfi_def_cfa    fp, 0                           /* Register in fp, so 
we just set fp as frame */
+       .cfi_offset     pc, REG_PC * 4
+       .cfi_offset     sp, REG_SP * 4
+       .cfi_offset     lr, REG_LR * 4
        bl              arm_undefinedinsn               /* Call the handler */
        mov             sp, r4                          /* Restore the possibly 
unaligned stack pointer */
 
@@ -614,6 +634,7 @@ arm_vectorundefinsn:
        /* Restore the CPSR, SYS mode registers and return. */
 
        rfeia           r14
+       .cfi_endproc
        .size   arm_vectorundefinsn, . - arm_vectorundefinsn
 
        .align  5
@@ -634,6 +655,8 @@ arm_vectorundefinsn:
        .type   arm_vectorfiq, %function
 
 arm_vectorfiq:
+       .cfi_sections   .debug_frame
+       .cfi_startproc
 #ifdef CONFIG_ARMV7R_DECODEFIQ
 
        /* Save the LR and SPSR onto the SYS mode stack before switch. */
@@ -664,7 +687,6 @@ arm_vectorfiq:
 
        /* Then call the FIQ handler with interrupts disabled. */
 
-       mov             fp, #0                          /* Init frame pointer */
        mov             r0, sp                          /* Get r0=xcp */
 
        mov             r4, sp                          /* Save the SP in a 
preserved register */
@@ -676,6 +698,11 @@ arm_vectorfiq:
 #endif
 
        bic             sp, sp, #7                      /* Force 8-byte 
alignment */
+       mov             fp, r0
+       .cfi_def_cfa    fp, 0                           /* Register in fp, so 
we just set fp as frame */
+       .cfi_offset     pc, REG_PC * 4
+       .cfi_offset     sp, REG_SP * 4
+       .cfi_offset     lr, REG_LR * 4
        bl              arm_decodefiq                   /* Call the handler */
        mov             sp, r4                          /* Restore the possibly 
unaligned stack pointer */
 
@@ -715,6 +742,7 @@ arm_vectorfiq:
 #else
        subs    pc, lr, #4
 #endif
+       .cfi_endproc
        .size   arm_vectorfiq, . - arm_vectorfiq
 
 /****************************************************************************
diff --git a/arch/arm/src/armv8-r/arm_vectors.S 
b/arch/arm/src/armv8-r/arm_vectors.S
index 8a0ea9d1f01..9702ed6ee23 100644
--- a/arch/arm/src/armv8-r/arm_vectors.S
+++ b/arch/arm/src/armv8-r/arm_vectors.S
@@ -455,6 +455,8 @@ arm_vectorsvc:
 #endif
 
 arm_vectordata:
+       .cfi_sections   .debug_frame
+       .cfi_startproc
 
        /* Save the LR and SPSR onto the SYS mode stack before switch. */
 
@@ -492,12 +494,16 @@ arm_vectordata:
         * void arm_dataabort(struct xcptcontext *xcp)
         */
 
-       mov             fp, #0                          /* Init frame pointer */
        mov             r0, sp                          /* Get r0=xcp */
        mrc             CP15_DFAR(r1)                   /* Get R1=DFAR */
        mrc             CP15_DFSR(r2)                   /* Get r2=DFSR */
        mov             r4, sp                          /* Save the SP in a 
preserved register */
        bic             sp, sp, #7                      /* Force 8-byte 
alignment */
+       mov             fp, r0
+       .cfi_def_cfa    fp, 0                           /* Register in fp, so 
we just set fp as frame */
+       .cfi_offset     pc, REG_PC * 4
+       .cfi_offset     sp, REG_SP * 4
+       .cfi_offset     lr, REG_LR * 4
        bl              arm_dataabort                   /* Call the handler */
        mov             sp, r4                          /* Restore the possibly 
unaligned stack pointer */
 
@@ -526,6 +532,7 @@ arm_vectordata:
        /* Restore the CPSR, SYS mode registers and return. */
 
        rfeia           r14
+       .cfi_endproc
        .size   arm_vectordata, . - arm_vectordata
 
 #ifdef __ghs__
@@ -554,6 +561,8 @@ arm_vectordata:
 #endif
 
 arm_vectorprefetch:
+       .cfi_sections   .debug_frame
+       .cfi_startproc
 
        /* Save the LR and SPSR onto the SYS mode stack before switch. */
 
@@ -585,12 +594,16 @@ arm_vectorprefetch:
         * void arm_prefetchabort(struct xcptcontext *xcp)
         */
 
-       mov             fp, #0                          /* Init frame pointer */
        mov             r0, sp                          /* Get r0=xcp */
        mrc             CP15_IFAR(r1)                   /* Get R1=IFAR */
        mrc             CP15_IFSR(r2)                   /* Get r2=IFSR */
        mov             r4, sp                          /* Save the SP in a 
preserved register */
        bic             sp, sp, #7                      /* Force 8-byte 
alignment */
+       mov             fp, r0
+       .cfi_def_cfa    fp, 0                           /* Register in fp, so 
we just set fp as frame */
+       .cfi_offset     pc, REG_PC * 4
+       .cfi_offset     sp, REG_SP * 4
+       .cfi_offset     lr, REG_LR * 4
        bl              arm_prefetchabort               /* Call the handler */
        mov             sp, r4                          /* Restore the possibly 
unaligned stack pointer */
 
@@ -619,6 +632,7 @@ arm_vectorprefetch:
        /* Restore the CPSR, SYS mode registers and return. */
 
        rfeia           r14
+       .cfi_endproc
        .size   arm_vectorprefetch, . - arm_vectorprefetch
 
 #ifdef __ghs__
@@ -645,6 +659,8 @@ arm_vectorprefetch:
 #endif
 
 arm_vectorundefinsn:
+       .cfi_sections   .debug_frame
+       .cfi_startproc
 
        /* Save the LR and SPSR onto the SYS mode stack before switch. */
 
@@ -675,10 +691,14 @@ arm_vectorundefinsn:
         * void arm_undefinedinsn(struct xcptcontext *xcp)
         */
 
-       mov             fp, #0                          /* Init frame pointer */
        mov             r0, sp                          /* Get r0=xcp */
        mov             r4, sp                          /* Save the SP in a 
preserved register */
        bic             sp, sp, #7                      /* Force 8-byte 
alignment */
+       mov             fp, r0
+       .cfi_def_cfa    fp, 0                           /* Register in fp, so 
we just set fp as frame */
+       .cfi_offset     pc, REG_PC * 4
+       .cfi_offset     sp, REG_SP * 4
+       .cfi_offset     lr, REG_LR * 4
        bl              arm_undefinedinsn               /* Call the handler */
        mov             sp, r4                          /* Restore the possibly 
unaligned stack pointer */
 
@@ -707,6 +727,7 @@ arm_vectorundefinsn:
        /* Restore the CPSR, SYS mode registers and return. */
 
        rfeia           r14
+       .cfi_endproc
        .size   arm_vectorundefinsn, . - arm_vectorundefinsn
 
 #ifdef __ghs__
@@ -735,6 +756,8 @@ arm_vectorundefinsn:
 #endif
 
 arm_vectorfiq:
+       .cfi_sections   .debug_frame
+       .cfi_startproc
 #ifdef CONFIG_ARCH_HIPRI_INTERRUPT
 
        /* Save the LR and SPSR onto the SYS mode stack before switch. */
@@ -765,7 +788,6 @@ arm_vectorfiq:
 
        /* Then call the FIQ handler with interrupts disabled. */
 
-       mov             fp, #0                          /* Init frame pointer */
        mov             r0, sp                          /* Get r0=xcp */
 
        mov             r4, sp                          /* Save the SP in a 
preserved register */
@@ -777,6 +799,11 @@ arm_vectorfiq:
 #endif
 
        bic             sp, sp, #7                      /* Force 8-byte 
alignment */
+       mov             fp, r0
+       .cfi_def_cfa    fp, 0                           /* Register in fp, so 
we just set fp as frame */
+       .cfi_offset     pc, REG_PC * 4
+       .cfi_offset     sp, REG_SP * 4
+       .cfi_offset     lr, REG_LR * 4
        bl              arm_decodefiq                   /* Call the handler */
        mov             sp, r4                          /* Restore the possibly 
unaligned stack pointer */
 
@@ -816,6 +843,7 @@ arm_vectorfiq:
 #else
        subs    pc, lr, #4
 #endif
+       .cfi_endproc
        .size   arm_vectorfiq, . - arm_vectorfiq
 
 /****************************************************************************

Reply via email to