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

H. Peter Anvin hpa@zytor.com
Sun Oct 26 10:27:40 GMT 2025


On October 25, 2025 10:48:15 PM PDT, "Maciej W. Rozycki" <macro@orcam.me.uk> wrote:
>On Fri, 24 Oct 2025, H. Peter Anvin wrote:
>
>> Out of these, SEG16 is the really problematic one, since neither s nor 
>> a is guaranteed to fit into 16 bits. Possible to solve that would be 
>> to generate a synthetic symbol for a and use stacked relocations, use 
>> x32 ELF rather than i386, or enable RELA for i386. It also requires 
>> enabling stacked relocations in the linker (for the SUB relocations) 
>> which *are* defined in the ELF gABI but not implemented in the x86 
>> linker (because x86 currently do not need them); I have prototyped 
>> that part and it is relatively trivial, though.
>
> FWIW composed relocations are supported by the MIPS backend, so please 
>feel free to reuse that code; in particular the n32 format uses the gABI 
>encoding (n64 has its own obscure one for some reason, possibly owing to 
>early IRIX attempts in this matter before this stuff got standardised).
>
> Although I think this stuff belongs to the generic ELF linker really 
>and then it'd be up to the individual backends whether to make use of 
>this feature or not (and with the `.reloc' generic assembly pseudo-op 
>one could in principle build composed relocations in their code with any 
>target, subject to the availability of suitable relocation operations as 
>per the relevant psABI, that is).
>
>  Maciej

It's trivial to support stacked relocations; for the i386 backend it is something like a 3-line change. Quite a few architectures use them.


More information about the Binutils mailing list