Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH 02/17] build: Only enable backtrace(3) in maintainer mode
Date: Tue, 30 Jan 2024 15:21:07 -0600	[thread overview]
Message-ID: <20240130212137.814082-2-denkenz@gmail.com> (raw)
In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com>

Using backtrace() is of no use when building with PIE (which most
distro compilers do by default) and prevents catching the coredump
for later retracing, which is needed since distros usually don't
install debug symbols by default either.

This patch thus only enables backtrace() when --enable-maintainer-mode
is passed and also tries to explicitly disable PIE.

This commit is based on the following commit from 'iwd':
b6910e121082 ("build: only enable backtrace(3) in maintainer mode")
---
 configure.ac | 11 +++++++++++
 src/log.c    |  8 ++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index c18cfa3a696f..551f863538ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,6 +110,17 @@ AC_ARG_ENABLE(ubsan, AS_HELP_STRING([--enable-ubsan],
 AC_CHECK_FUNCS(explicit_bzero)
 AC_CHECK_FUNCS(rawmemchr)
 
+# In maintainer mode: try to build with application backtrace and disable PIE.
+if (test "${USE_MAINTAINER_MODE}" = yes); then
+	AC_SEARCH_LIBS([backtrace], [execinfo],
+		[
+			AC_DEFINE([HAVE_BACKTRACE], [1],
+				[Define to 1 if you have backtrace(3).])
+			CFLAGS="$CFLAGS -fno-PIE"
+			LDFLAGS="$LDFLAGS -no-pie"
+		])
+fi
+
 AC_CHECK_FUNC(signalfd, dummy=yes,
 			AC_MSG_ERROR(signalfd support is required))
 
diff --git a/src/log.c b/src/log.c
index b33a7d262474..a8b4ef10eaae 100644
--- a/src/log.c
+++ b/src/log.c
@@ -30,7 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <syslog.h>
-#ifdef __GLIBC__
+#ifdef HAVE_BACKTRACE
 #include <execinfo.h>
 #endif
 #include <dlfcn.h>
@@ -115,7 +115,7 @@ void ofono_debug(const char *format, ...)
 	va_end(ap);
 }
 
-#ifdef __GLIBC__
+#ifdef HAVE_BACKTRACE
 static void print_backtrace(unsigned int offset)
 {
 	void *frames[99];
@@ -303,7 +303,7 @@ int __ofono_log_init(const char *program, const char *debug,
 	if (detach == FALSE)
 		option |= LOG_PERROR;
 
-#ifdef __GLIBC__
+#ifdef HAVE_BACKTRACE
 	signal_setup(signal_handler);
 #endif
 
@@ -320,7 +320,7 @@ void __ofono_log_cleanup(void)
 
 	closelog();
 
-#ifdef __GLIBC__
+#ifdef HAVE_BACKTRACE
 	signal_setup(SIG_DFL);
 #endif
 
-- 
2.43.0


  reply	other threads:[~2024-01-30 21:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30 21:21 [PATCH 01/17] umlrunner: Also mount /var/lib as tmpfs Denis Kenzior
2024-01-30 21:21 ` Denis Kenzior [this message]
2024-01-30 21:21 ` [PATCH 03/17] build: Bring in more ell classes Denis Kenzior
2024-01-30 21:21 ` [PATCH 04/17] provisiondb: Remove some duplicate MCCMNC entries Denis Kenzior
2024-01-30 21:21 ` [PATCH 05/17] storage: Introduce storage_get_file_path() Denis Kenzior
2024-01-30 21:21 ` [PATCH 06/17] storage: Convert g_strdup_* use to l_strdup_* Denis Kenzior
2024-01-30 21:21 ` [PATCH 07/17] common: Drop GLib use from gprs_auth_proto_to_string Denis Kenzior
2024-01-30 21:21 ` [PATCH 08/17] common: Drop GLib use from gprs_proto_to_string Denis Kenzior
2024-01-30 21:21 ` [PATCH 09/17] storage: Remove mode parameter Denis Kenzior
2024-01-30 21:21 ` [PATCH 10/17] storage: Use l_malloc Denis Kenzior
2024-01-30 21:21 ` [PATCH 11/17] storage: Remove mode argument Denis Kenzior
2024-01-30 21:21 ` [PATCH 12/17] storage: Use void * instead of unsigned char * Denis Kenzior
2024-01-30 21:21 ` [PATCH 13/17] storage: use l_file_set_contents Denis Kenzior
2024-01-30 21:21 ` [PATCH 14/17] lte: Refactor lte settings management Denis Kenzior
2024-01-30 21:21 ` [PATCH 15/17] lte: Add provisioning support Denis Kenzior
2024-01-30 21:21 ` [PATCH 16/17] phonesim: Add lte atom Denis Kenzior
2024-01-30 21:21 ` [PATCH 17/17] lte: Write provisioned info to disk Denis Kenzior
2024-02-02 23:30 ` [PATCH 01/17] umlrunner: Also mount /var/lib as tmpfs patchwork-bot+ofono

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240130212137.814082-2-denkenz@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ofono@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox