[Concept,06/10] backtrace: sandbox: Add -rdynamic to export symbols
Commit Message
From: Simon Glass <simon.glass@canonical.com>
Add the -rdynamic linker flag so that backtrace_symbols() can resolve
function names. This is needed to show meaningful symbol names instead
of just addresses.
Only enable this CONFIG_BACKTRACE and CONFIG_CMDLINE are enabled, since
it causes build failures with the tools-only build and sandbox_nocmdline
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
arch/sandbox/config.mk | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
@@ -28,6 +28,11 @@ SANITIZERS += -fsanitize=fuzzer
endif
KBUILD_CFLAGS += $(SANITIZERS)
+# Avoid defeating linker's garbage collection
+ifeq ($(CONFIG_BACKTRACE)$(CONFIG_CMDLINE),yy)
+RDYNAMIC += -rdynamic
+endif
+
cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \
$(KBUILD_LDFLAGS:%=-Wl,%) \
$(SANITIZERS) \
@@ -36,7 +41,7 @@ cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \
$(u-boot-main) \
$(u-boot-keep-syms-lto) \
-Wl,--no-whole-archive \
- $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -Wl,--gc-sections
+ $(RDYNAMIC) $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -Wl,--gc-sections
cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \
$(KBUILD_LDFLAGS:%=-Wl,%) \