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

Maciej W. Rozycki macro@orcam.me.uk
Sun Oct 26 05:48:15 GMT 2025
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


More information about the Binutils mailing list