[PATCH 2/2] z80-elf: support complex relocation symbols

H. Peter Anvin hpa@zytor.com
Mon Nov 17 22:14:53 GMT 2025


On November 17, 2025 12:29:31 PM PST, Ismael Luceno <ismael@iodev.co.uk> wrote:
>On 17/Nov/2025 08:05, H. Peter Anvin wrote:
>> On November 17, 2025 4:07:31 AM PST, Ismael Luceno <ismael@iodev.co.uk> wrote:
>> >On 24/Oct/2025 09:58, H. Peter Anvin wrote:
>> >> Either way, the relocation does, for a loadable file, need to be
>> >> carried into the load format, as you point out, but that is usually
>> >> handled already by linking with -r and postprocessing the result, as
>> >> the load format generally isn't ELF but something more like MS-DOS
>> >> MZ (.exe) format. In this case it would be up to the postprocessor
>> >> to recognize the relevant expression symbol expressions and turn
>> >> them into native relocations.
>> >
>> >The point was about using ELF all the way.
>> 
>> The point for *whom*? 
>> 
>> Using ELF as much as possible, and *especially* through the linking
>> of the executable is obviously desired, but since Z80 is legacy
>> architecture it is obviously not what Z80 operating systems are
>> going to consume.
>
>I didn't meant specifically for Z80; though there's retro machines
>being built so, maybe for these.
>
>As for x86, to this day plenty of firmware relies on a very brittle
>ecosystem of long dead proprietary tools and hacks.

All of this, though, points to the same thing: to support these legacy systems, one generally needs to do post-link processing of the binary anyway.

Either that, or they always link to a fixed address, in which case it doesn't matter at all (the postprocessing consists of objcopy -O binary ...). To be honest, I have *never* seen anyone pull binary/ihex/srec directly from the linker, because the .elf intermediate file is pretty much essential for debugging.

Modern systems, with flat memory spaces and dynamic linking — the ones for which ELF would typically be a native format — tend not to need these hacks, but I could see things like waiting to load __bss_end - __bss_start into a register on an embedded system where the OS doesn't clear bss for you. It's it important? Probably not, but it might be nice.


More information about the Binutils mailing list