mirror of
https://github.com/apache/nuttx.git
synced 2026-09-09 10:26:37 +00:00
sys_callN() wraps a bare ecall and calls no other function, so the compiler treats it as a leaf function: with frame pointers enabled, it only needs to spill the caller's s0, which it places in what up_backtrace()'s fp-chain walk assumes is ra's stack slot, while the real ra slot is never written. sched_backtrace() then misreads that slot as the return address for this frame, either resolving to a bogus symbol or, if the adjacent garbage happens to look out-of-range, terminating the backtrace early. Add "ra" to the ecall clobber list so the compiler spills/reloads ra around the ecall like a normal call site, keeping ra and the saved s0 in their expected slots. Gate this on CONFIG_FRAME_POINTER && CONFIG_SCHED_BACKTRACE, the only combination where up_backtrace()'s fp-chain walk is both valid (FRAME_POINTER) and actually exercised (SCHED_BACKTRACE); other configurations keep the original "memory"-only clobber and pay no extra cost. This only fixes the syscall boundary. Leaf functions that do not cross a syscall (e.g. up_idle()) can still lose their ra slot the same way and are not addressed here. Signed-off-by: liang.huang <liang.huang@houmo.ai> |
||
|---|---|---|
| .. | ||
| bl602 | ||
| bl808 | ||
| c906 | ||
| eic7700x | ||
| esp32c3 | ||
| esp32c3-legacy | ||
| esp32c6 | ||
| esp32h2 | ||
| esp32p4 | ||
| fe310 | ||
| hpm6000 | ||
| hpm6750 | ||
| jh7110 | ||
| k210 | ||
| k230 | ||
| litex | ||
| mpfs | ||
| qemu-rv | ||
| rp23xx-rv | ||
| rv32m1 | ||
| sg2000 | ||
| thead | ||
| .gitignore | ||
| arch.h | ||
| barriers.h | ||
| csr.h | ||
| elf.h | ||
| inttypes.h | ||
| irq.h | ||
| limits.h | ||
| mode.h | ||
| setjmp.h | ||
| spinlock.h | ||
| stdarg.h | ||
| syscall.h | ||
| types.h | ||