Add a build target to create barebox.elf, which provides an ELF format
version of barebox that can be used for debugging or alternative boot
scenarios.

Signed-off-by: Sascha Hauer <[email protected]>
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
---
 Makefile | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 
75e14383bcdcf987d091442adba9b053af28eae7..c1aa6935abe5c65156b812d4a0b21c6d488038ae
 100644
--- a/Makefile
+++ b/Makefile
@@ -850,6 +850,9 @@ all: barebox-flash-images
 endif
 
 all: $(symlink-y)
+ifeq ($(CONFIG_PBL_IMAGE)-$(CONFIG_PBL_IMAGE_NO_PIGGY),y-)
+all: barebox.elf
+endif
 
 .SECONDEXPANSION:
 $(symlink-y): $$(or $$(SYMLINK_DEP_$$(@F)),$$(SYMLINK_TARGET_$$(@F))) FORCE
@@ -1091,6 +1094,17 @@ barebox.fit: images/barebox-$(CONFIG_ARCH_LINUX_NAME).fit
 barebox.srec: barebox
        $(OBJCOPY) -O srec $< $@
 
+OBJCOPYFLAGS_barebox.elf = --strip-debug --strip-unneeded \
+                          --remove-section=.comment \
+                          --remove-section=.note \
+                          --remove-section=.note.gnu.build-id
+
+quiet_cmd_objcopy_elf = OBJCOPY $@
+      cmd_objcopy_elf = $(OBJCOPY) $(OBJCOPYFLAGS_barebox.elf) $< $@
+
+barebox.elf: barebox FORCE
+       $(call if_changed,objcopy_elf)
+
 quiet_cmd_barebox_proper__ = CC      $@
       cmd_barebox_proper__ = $(CC) -r -o $@ -Wl,--whole-archive $(BAREBOX_OBJS)
 
@@ -1388,7 +1402,7 @@ CLEAN_FILES +=    barebox System.map 
include/generated/barebox_default_env.h \
                 .tmp_version .tmp_barebox* barebox.bin barebox.map \
                .tmp_kallsyms* barebox.ldr compile_commands.json \
                .tmp_barebox.o barebox.o barebox-flash-image \
-               barebox.srec barebox.s5p barebox.ubl \
+               barebox.srec barebox.elf barebox.s5p barebox.ubl \
                barebox.uimage \
                barebox.efi barebox.canon-a1100.bin
 

-- 
2.47.3


Reply via email to