Build raise and abort function with dwarf2 info by using
-fasynchronous-unwind-tables to make backtrace() working across a
call to abort.

A scenario where it could be useful is within a signal handler that
wants to dump a backtrace when catching some signal (i.e SIGABRT).
Without having abort & raise built with DWARF2 information, it is not
possible for the libgcc stack unwinder to walk through the call stack
out of the abort/raise function.

Impacts in terms of size are really limited

Current
   text    data     bss     dec     hex filename
    164       0       0     164      a4 
./libpthread/nptl/sysdeps/unix/sysv/linux/raise.os
    164       0       0     164      a4 
./libpthread/nptl/sysdeps/unix/sysv/linux/raise.oS
    220      24       4     248      f8 ./libc/stdlib/abort.os

With (-fasynchronous-unwind-tables)

   text    data     bss     dec     hex filename
    216       0       0     216      d8 
./libpthread/nptl/sysdeps/unix/sysv/linux/raise.os
    216       0       0     216      d8 
./libpthread/nptl/sysdeps/unix/sysv/linux/raise.oS
    280      24       4     308     134 ./libc/stdlib/abort.os

Signed-off-by: Carmelo Amoroso <carmelo.amor...@st.com>
---
 libc/signal/Makefile.in                            |    2 ++
 libc/stdlib/Makefile.in                            |    2 ++
 .../sysdeps/unix/sysv/linux/Makefile.commonarch    |    2 ++
 3 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/libc/signal/Makefile.in b/libc/signal/Makefile.in
index a7e3078..ed8598b 100644
--- a/libc/signal/Makefile.in
+++ b/libc/signal/Makefile.in
@@ -24,6 +24,8 @@ ifneq ($(strip $(ARCH_OBJS)),)
 CSRC-y := $(filter-out $(notdir $(ARCH_OBJS:.o=.c)),$(CSRC-y))
 endif
 
+CFLAGS-raise.c = -fasynchronous-unwind-tables
+
 SIGNAL_DIR := $(top_srcdir)libc/signal
 SIGNAL_OUT := $(top_builddir)libc/signal
 
diff --git a/libc/stdlib/Makefile.in b/libc/stdlib/Makefile.in
index 73e5462..9e96f03 100644
--- a/libc/stdlib/Makefile.in
+++ b/libc/stdlib/Makefile.in
@@ -27,6 +27,8 @@ CSRC-$(if $(findstring 
yy,$(UCLIBC_HAS_FLOATS)$(UCLIBC_SUSV3_LEGACY)),y) += \
        gcvt.c
 CSRC-$(UCLIBC_SUSV3_LEGACY) += mktemp.c
 
+CFLAGS-abort.c = -fasynchronous-unwind-tables
+
 # multi source stdlib.c
 CSRC-y += abs.c labs.c atoi.c atol.c strtol.c strtoul.c _stdlib_strto_l.c \
        qsort.c qsort_r.c bsearch.c \
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch 
b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch
index e28cec2..b32bc9b 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.commonarch
@@ -128,6 +128,8 @@ CFLAGS-timer_gettime.c = -I$(top_srcdir)librt -DIS_IN_librt
 CFLAGS-timer_routines.c = -I$(top_srcdir)librt -DIS_IN_librt
 CFLAGS-timer_settime.c = -I$(top_srcdir)librt -DIS_IN_librt
 
+CFLAGS-raise.c = -fasynchronous-unwind-tables
+
 CFLAGS-linux = -DNOT_IN_libc -DIS_IN_libpthread $(SSP_ALL_CFLAGS)
 
 CFLAGS-OMIT-libc_pthread_init.c = -DNOT_IN_libc -DIS_IN_libpthread
-- 
1.7.4.4

_______________________________________________
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to