summaryrefslogtreecommitdiff
path: root/libubacktrace/backtrace.c
diff options
context:
space:
mode:
authorFilippo Arcidiacono <filippo.arcidiacono@st.com>2013-05-09 11:42:23 +0200
committerCarmelo Amoroso <carmelo.amoroso@st.com>2013-05-13 10:11:50 +0200
commit71c10c484e7dc113396cccb7e503befb759c6346 (patch)
tree2454e2e15be07928cafdfda2696129d4614dc8c2 /libubacktrace/backtrace.c
parent231e4a9b4b972662a6832f714a05525a3754892d (diff)
libubacktrace: fix backtrace for statically linked application
libgcc_s.so's unwinder could not access unwind tables of statically linked binaries, so we really want to use _Unwind_* stuff from libgcc_eh.a. It required to build backtrace.c differentiating between shared and static case. Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libubacktrace/backtrace.c')
-rw-r--r--libubacktrace/backtrace.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libubacktrace/backtrace.c b/libubacktrace/backtrace.c
index 0a72bae5e..08a7010e7 100644
--- a/libubacktrace/backtrace.c
+++ b/libubacktrace/backtrace.c
@@ -34,6 +34,7 @@ struct trace_arg
int cnt, size;
};
+#ifdef SHARED
static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *);
static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *);
@@ -48,6 +49,10 @@ static void backtrace_init (void)
abort();
}
}
+#else
+# define unwind_backtrace _Unwind_Backtrace
+# define unwind_getip _Unwind_GetIP
+#endif
static _Unwind_Reason_Code
backtrace_helper (struct _Unwind_Context *ctx, void *a)
@@ -72,8 +77,10 @@ int backtrace (void **array, int size)
{
struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
+#ifdef SHARED
if (unwind_backtrace == NULL)
backtrace_init();
+#endif
if (size >= 1)
unwind_backtrace (backtrace_helper, &arg);