[PATCH v3 01/11] Makefile: add SPL_REMAKE_ELF_LDSCRIPT feature

Tom Rini trini at konsulko.com
Fri Apr 24 18:19:55 CEST 2026


On Fri, Apr 24, 2026 at 02:14:42AM +0200, Michael Srba wrote:
> Hi,
> 
> On 4/21/26 22:45, Tom Rini wrote:
> > On Tue, Apr 21, 2026 at 09:43:44PM +0200, michael.srba at seznam.cz wrote:
> > 
> > > From: Michael Srba <Michael.Srba at seznam.cz>
> > > 
> > > Some platforms (e.g. least Qualcomm), use the ELF format in creative
> > > ways, including in the bootrom. Make SPL_REMAKE_ELF use a linker script
> > > specified in SPL_REMAKE_ELF_LDSCRIPT (with the previously hardcoded path
> > > as the default).
> > > 
> > > Signed-off-by: Michael Srba <Michael.Srba at seznam.cz>
> > > ---
> > >   Makefile           | 10 ++++++++--
> > >   common/spl/Kconfig | 10 ++++++++++
> > >   2 files changed, 18 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/Makefile b/Makefile
> > > index 8af18668b0f..50893d5689e 100644
> > > --- a/Makefile
> > > +++ b/Makefile
> > > @@ -2004,16 +2004,22 @@ u-boot.elf: u-boot.bin u-boot-elf.lds FORCE
> > >   quiet_cmd_u-boot-spl-elf ?= LD      $@
> > >   	cmd_u-boot-spl-elf ?= $(LD) spl/u-boot-spl-elf.o -o $@ \
> > >   	$(if $(CONFIG_SYS_BIG_ENDIAN),-EB,-EL) \
> > > -	-T u-boot-elf.lds --defsym=$(CONFIG_PLATFORM_ELFENTRY)=$(CONFIG_SPL_TEXT_BASE) \
> > > +	-T spl/u-boot-spl-elf.lds --defsym=$(CONFIG_PLATFORM_ELFENTRY)=$(CONFIG_SPL_TEXT_BASE) \
> > >   	-Ttext=$(CONFIG_SPL_TEXT_BASE)
> > > -spl/u-boot-spl.elf: spl/u-boot-spl.bin u-boot-elf.lds
> > > +spl/u-boot-spl.elf: spl/u-boot-spl.bin spl/u-boot-spl-elf.lds
> > >   	$(Q)$(OBJCOPY) -I binary $(PLATFORM_ELFFLAGS) $< spl/u-boot-spl-elf.o
> > >   	$(call if_changed,u-boot-spl-elf)
> > > +SPL_REMAKE_ELF_LDSCRIPT := $(addprefix $(srctree)/,$(CONFIG_SPL_REMAKE_ELF_LDSCRIPT:"%"=%))
> > > +
> > > +spl/u-boot-spl-elf.lds: $(SPL_REMAKE_ELF_LDSCRIPT) FORCE
> > > +	$(call if_changed_dep,cpp_lds)
> > > +
> > >   u-boot-elf.lds: arch/u-boot-elf.lds prepare FORCE
> > >   	$(call if_changed_dep,cpp_lds)
> > >   PHONY += prepare0
> > > +
> > >   # MediaTek's ARM-based u-boot needs a header to contains its load address
> > >   # which is parsed by the BootROM.
> > >   # If the SPL build is enabled, the header will be added to the spl binary,
> > > diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> > > index d1a85f50209..1d279a2bb05 100644
> > > --- a/common/spl/Kconfig
> > > +++ b/common/spl/Kconfig
> > > @@ -247,6 +247,16 @@ config SPL_HANDOFF
> > >   	  proper. Also SPL can receive information from TPL in the same place
> > >   	  if that is enabled.
> > > +config SPL_REMAKE_ELF_LDSCRIPT
> > > +	string "Linker script for SPL ELF"
> > > +	depends on SPL_REMAKE_ELF
> > > +	default "arch/$(ARCH)/u-boot-spl-elf.lds"
> > > +	help
> > > +	  This allows specifying a linker script that will act on u-boot-spl.bin.
> > > +	  Some platforms (e.g Qualcomm) use the ELF format in creative ways,
> > > +	  including in the bootrom. For such platforms, you can change the default
> > > +	  linker script to a platform-specific one.
> > > +
> > >   config SPL_LDSCRIPT
> > >   	string "Linker script for the SPL stage"
> > >   	default "arch/arm/cpu/arm926ejs/sunxi/u-boot-spl.lds" if MACH_SUNIV
> > Did what I said about cleaning up the remake elf Makefile logic itself
> > get lost somewhere? Sorry. To repeat, we should have a remake elf
> > function, make use of $(PHASE_) and have Kconfig entries for both
> > REMAKE_ELF_LDSCRIPT and SPL_REMAKE_ELF_SCRIPT (so we can use $(PHASE_)
> > again to get the right one. Thanks!
> > 
> Trying to figure this out, I feel like I must be missing something...
> It seems like $(PHASE_) is never going to be anything other than an empty
> string inside the main Makefile?
> While `libs-$(CONFIG_$(PHASE_)ALTERA_SDRAM) += drivers/ddr/altera/` would
> make me think otherwise, most of the contents of the toplevel Makefile
> strongly suggest that it's only ever executed once, rather than one time
> for each of u-boot proper, spl, tpl, vpl. I have tried to use $(PHASE_)
> anyway, but it really doesn't seem to work. Could you explain more
> specifically how I should do this?

I had thought this would work, yes. Does this mean the other cases of
$(PHASE_) in the top-level Makefile also aren't working? And, is there
some other Makefile where $(PHASE_) does indeed work, that we could move
this particular logic to?

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260424/d9202eeb/attachment.sig>


More information about the U-Boot mailing list