aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2023-10-24 08:30:47 +0200
committerTom Rini <trini@konsulko.com>2023-11-02 22:38:01 -0400
commitbe6a249b417fb159db6fc3f4b7d72eb2fd036554 (patch)
tree273285cfbf999e57ac8a402c5ce0e43373156de9 /arch
parenta4ed4c8a51435a63ca79e6d7bca317eff30e9ed3 (diff)
downloadu-boot-be6a249b417fb159db6fc3f4b7d72eb2fd036554.zip
u-boot-be6a249b417fb159db6fc3f4b7d72eb2fd036554.tar.gz
u-boot-be6a249b417fb159db6fc3f4b7d72eb2fd036554.tar.bz2
sandbox: eliminate unused functions from binaries
The sandbox should closely mimic other architectures. Place each function or data in a separate section and let the linker eliminate unused ones. This will reduce the binary size. In the linker script mark that u_boot_sandbox_getopt are to be kept. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/sandbox/config.mk4
-rw-r--r--arch/sandbox/cpu/u-boot.lds2
2 files changed, 3 insertions, 3 deletions
diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index 2d184c5..1d50991 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -2,7 +2,7 @@
# Copyright (c) 2011 The Chromium OS Authors.
PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE
-PLATFORM_CPPFLAGS += -fPIC
+PLATFORM_CPPFLAGS += -fPIC -ffunction-sections -fdata-sections
PLATFORM_LIBS += -lrt
SDL_CONFIG ?= sdl2-config
@@ -30,7 +30,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
+ $(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,%) \
diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds
index ba8dee5..52f13af 100644
--- a/arch/sandbox/cpu/u-boot.lds
+++ b/arch/sandbox/cpu/u-boot.lds
@@ -15,7 +15,7 @@ SECTIONS
_u_boot_sandbox_getopt : {
*(_u_boot_sandbox_getopt_start)
- *(_u_boot_sandbox_getopt)
+ KEEP(*(_u_boot_sandbox_getopt))
*(_u_boot_sandbox_getopt_end)
}