[PATCH 08/19] Makefile: add barebox.elf build target
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Jan 5 04:22:40 PST 2026
Hi,
On 1/5/26 12:26 PM, Sascha Hauer wrote:
> 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 <s.hauer at pengutronix.de>
> Co-Authored-By: Claude Sonnet 4.5 <noreply at anthropic.com>
I think conceptually, the Co-Authored-By should be before your S-o-b.
> ---
> 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
Why not:
ifdef CONFIG_PBL_IMAGE_ELF
export BAREBOX_PROPER ?= vmbarebox # or barebox.elf
else
export BAREBOX_PROPER ?= barebox.bin
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 \
--strip-section-headers goes the farthest I think.
> + --remove-section=.comment \
> + --remove-section=.note \
--remote-section=.note*
> + --remove-section=.note.gnu.build-id
--remove-section=.gnu.hash?
> +
> +quiet_cmd_objcopy_elf = OBJCOPY $@
> + cmd_objcopy_elf = $(OBJCOPY) $(OBJCOPYFLAGS_barebox.elf) $< $@
> +
> +barebox.elf: barebox FORCE
> + $(call if_changed,objcopy_elf)
There is already cmd_objcopy. You should be able to reuse it with
OBJCOPYFLAGS_$@ = $your_options.
Sidenote: We should add --error-rwx-segments depending on
CONFIG_PBL_IMAGE_ELF.
Cheers,
Ahmad
> +
> 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
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list