From e93fe55e54fee4f4c357e8719b8e6bbedc25e139 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Fri, 16 Dec 2016 21:15:17 +0100 Subject: [PATCH] libc: clear frame pointer on user-context entry If built with frame-pointer support the backtrace now stops at the user entry code. Before, the libc kernel stack was trced back too. --- .../libports/src/lib/libc/include/spec/arm/internal/call_func.h | 1 + .../src/lib/libc/include/spec/x86_32/internal/call_func.h | 1 + 2 files changed, 2 insertions(+) diff --git a/repos/libports/src/lib/libc/include/spec/arm/internal/call_func.h b/repos/libports/src/lib/libc/include/spec/arm/internal/call_func.h index ad9b4ef5e0..8bc8b82927 100644 --- a/repos/libports/src/lib/libc/include/spec/arm/internal/call_func.h +++ b/repos/libports/src/lib/libc/include/spec/arm/internal/call_func.h @@ -25,6 +25,7 @@ { asm volatile ("mov r0, %2;" /* set arg */ "mov sp, %0;" /* set stack */ + "mov fp, #0;" /* clear frame pointer */ "mov pc, %1;" /* call func */ "" : : "r"(sp), "r"(func), "r"(arg) : "r0"); diff --git a/repos/libports/src/lib/libc/include/spec/x86_32/internal/call_func.h b/repos/libports/src/lib/libc/include/spec/x86_32/internal/call_func.h index 4f1610606b..1bee91fd3a 100644 --- a/repos/libports/src/lib/libc/include/spec/x86_32/internal/call_func.h +++ b/repos/libports/src/lib/libc/include/spec/x86_32/internal/call_func.h @@ -26,6 +26,7 @@ asm volatile ("movl %2, 0(%0);" "movl %1, -0x4(%0);" "movl %0, %%esp;" + "xorl %%ebp, %%ebp;" /* clear frame pointer */ "call *-4(%%esp);" : : "r" (sp), "r" (func), "r" (arg)); __builtin_unreachable();