[PATCH 2/2] z80-elf: support complex relocation symbols
Maciej W. Rozycki
macro@orcam.me.uk
Sun Oct 26 15:02:24 GMT 2025
On Sun, 26 Oct 2025, H. Peter Anvin wrote:
> > 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).
>
> 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.
Possibly, though as usually with BFD I suspect there's a catch; also I
guess a lot of complication in the MIPS backend comes from the use of said
odd n64 encoding (triple relocs in a single Elf64_Rela entry).
And yet we don't have generic support for this stuff and moreover as new
psABIs are invented people come up with zillions of complex relocation
operations while they could be composed with a bunch of basic ones, by
separating input and output data processing from each other.
NB any target that has fields to relocate narrower than the width of
address ought to use the RELA format really. Doing otherwise is asking
for trouble. In reality this means REL is almost always suitable for
dynamic relocations only and for some targets possibly not even for that.
Maciej
More information about the Binutils
mailing list