[Concept,05/10] backtrace: sandbox: Link with libbacktraces

Message ID 20251129080014.758001-6-sjg@u-boot.org
State New
Headers
Series backtrace: Add runtime support for looking at the backtrace |

Commit Message

Simon Glass Nov. 29, 2025, 7:59 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Link with libbacktrace when CONFIG_BACKTRACE is enabled. This library is
bundled with GCC and provides DWARF-based symbol resolution for
backtraces.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 arch/sandbox/config.mk | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index f80e2ef369f..7039b256d81 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -3,7 +3,13 @@ 
 
 PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE
 PLATFORM_CPPFLAGS += -fPIC -ffunction-sections -fdata-sections
+
+ifeq ($(CONFIG_BACKTRACE),y)
+GCC_LIB_DIR := $(shell $(CC) -print-file-name=)
+PLATFORM_LIBS += -L$(GCC_LIB_DIR) -lbacktrace
+endif
 PLATFORM_LIBS += -lrt
+
 SDL_CONFIG ?= sdl2-config
 
 # Define this to avoid linking with SDL, which requires SDL libraries