[PATCH v2] os: Prevent backtrace from being stopped in noreturn functions.

Rami Ylimaki ext-rami.ylimaki at nokia.com
Wed Mar 17 03:16:57 PDT 2010

There are two noreturn functions in the X server: FatalError and
AbortServer. Having any of those two functions in the middle of a call
stack will prevent unwinding the program properly and stops the
backtrace at those functions in gdb.

The file containing FatalError and AbortServer, os/log.c, has to be
compiled with the -mapcs-frame option on ARM to get proper
backtraces. Automake imposes its own restrictions on compiling
individual source files with different options. The recommended way to
do this is to put os/log.c into a convenience library and add this
library inside os/libos.la. See the documentation of GNU Automake
manual, version 1.11.1, section 27.8 Per-Object Flags Emulation, for

Signed-off-by: Rami Ylimaki <ext-rami.ylimaki at nokia.com>
Fixed based on previous review feedback. I'm aware that GCC should
also be fixed at some point, but nevertheless it'd be nice to get this
fix integrated upstream because we don't have the possibility to
switch to a patched GCC anytime soon.

 configure.ac   |   13 +++++++++++++
 os/Makefile.am |   17 ++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6d5e98c..a17d709 100644
--- a/configure.ac
+++ b/configure.ac
@@ -315,6 +315,19 @@ AC_CHECK_HEADER([execinfo.h],[
+dnl ARM needs additional compiler flags for proper backtraces if GCC is
+dnl used. Compile a dummy program with the -mapcs-frame option. If it
+dnl succeeds, we know that we are building for ARM with GCC.
+        AC_LANG_PROGRAM([[ ]]),
 dnl ---------------------------------------------------------------------------
 dnl Bus options and CPU capabilities.  Replaces logic in
 dnl hw/xfree86/os-support/bus/Makefile.am, among others.
diff --git a/os/Makefile.am b/os/Makefile.am
index 66a4a0f..3e4f2c5 100644
--- a/os/Makefile.am
+++ b/os/Makefile.am
@@ -1,11 +1,19 @@
-noinst_LTLIBRARIES = libos.la
+noinst_LTLIBRARIES = libos.la liblog.la
 SECURERPC_SRCS = rpcauth.c
 XDMCP_SRCS = xdmcp.c
 STRLCAT_SRCS = strlcat.c strlcpy.c
-XORG_SRCS = log.c
+# Build a convenience library liblog.la that will be added into
+# libos.la. The split is done so that log.c can be built with
+# different compiler options.
+liblog_la_SOURCES = log.c
+# Add flags needed for proper backtraces of functions marked with GCC
+# __attribute__((noreturn)). Currently those flags are needed for
+# FatalError and AbortServer in log.c.
 libos_la_SOURCES = 	\
 	WaitFor.c	\
@@ -24,9 +32,8 @@ libos_la_SOURCES = 	\
 	xdmauth.c	\
 	xsha1.c		\
 	xstrans.c	\
-	xprintf.c	\
+	xprintf.c
+libos_la_LIBADD = @SHA1_LIBS@ $(DLOPEN_LIBS) liblog.la

More information about the xorg-devel mailing list