[PATCH 1/5] Makefile: add SPL_REMAKE_ELF_LDSCRIPT feature

Michael Srba Michael.Srba at seznam.cz
Tue Apr 7 00:43:05 CEST 2026


On 4/6/26 17:50, Simon Glass wrote:
> Hi Michael,
>
> On 2026-04-03T23:18:18, Michael Srba <michael.srba at seznam.cz> wrote:
>> Makefile: add SPL_REMAKE_ELF_LDSCRIPT feature
>>
>> On some platforms (at least Qualcomm), the bootrom expects an ELF file.
>> Since the contents of the ELF file are platform specific, add a config
>> option that allows specifying a linker script to use to produce the
>> ELF file.
>>
>> Signed-off-by: Michael Srba <Michael.Srba at seznam.cz>
>> diff --git a/Makefile b/Makefile
>> @@ -2014,6 +2017,26 @@ u-boot-elf.lds: arch/u-boot-elf.lds prepare FORCE
>> +quiet_cmd_u-boot-spl-elf ?= LD      $@
>> +     cmd_u-boot-spl-elf ?= $(LD) spl/u-boot-spl-elf.o -o $@ \
>> +     -T spl/u-boot-spl-elf.lds --defsym=$(CONFIG_PLATFORM_ELFENTRY)=$(CONFIG_SPL_TEXT_BASE) \
>> +     -Ttext=$(CONFIG_SPL_TEXT_BASE) -z max-page-size=0x1000
> The existing cmd_u-boot-spl-elf includes $(if
> $(CONFIG_SYS_BIG_ENDIAN),-EB,-EL) for endianness. Please can you add
> the same here for consistency.
>
> Since this redefines cmd_u-boot-spl-elf using ?=, the earlier
> definition takes precedence if both SPL_REMAKE_ELF and
> SPL_REMAKE_ELF_LDSCRIPT are enabled. This is probably fine since
> enabling both does not make sense, but maybe add 'depends on
> !SPL_REMAKE_ELF' or a note in the Kconfig help text.
Hi,
slowly going through the reviews, I think when I originally worked on this
u-boot didn't support remaking SPL into an ELF at all. I completely missed
this change when rebasing (or didn't miss it, made a mental note, and
completely forgot... hard to say at this point).

I could certainly just
add a conditional, though there's probably cleaner ways to do this where
only the linker script is conditional (not sure what to do about the page
size, would need to test to double check if it's even actually necessary).

Actually, making the linker script path default to the standard one would be
the cleanest option by some measures, but since you didn't suggest it
I assume that's not your preferred solution?

>
>> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
>> @@ -247,6 +247,12 @@ config SPL_HANDOFF
>> +config SPL_REMAKE_ELF_LDSCRIPT
>> +     string "Linker script to run with u-boot-spl.bin as input"
>> +     help
>> +       This allows specifying a linker script that will act on u-boot-spl.bin
>> +       (see also REMAKE_ELF)
> Can you explain when you would need a custom linker script rather than
> just using SPL_REMAKE_ELF ?. Something like:
>
> Some platforms (e.g. Qualcomm) require the bootrom to load a custom
> ELF format. Unlike SPL_REMAKE_ELF which uses a standard linker script,
> this allows a platform-specific one.
Can do
> Regards,
> Simon



More information about the U-Boot mailing list