[PATCH 8/8] bfd/ELF: fold BFD_RELOC_<arch>_PCREL*

Hans-Peter Nilsson hp@axis.com
Sat Mar 14 04:45:30 GMT 2026


> Date: Fri, 13 Mar 2026 11:00:45 +0100
> From: Jan Beulich <jbeulich@suse.com>

> There's no need to have a separate reloc per arch; just like for other
> more or less generic ones a single one will (mostly) do, as long as the
> resulting reloc's properties fit such a generic use (in the assembler it
> could, after all, also result from ordinary expressions or uses with the
> .reloc directive). Arm64, C-Sky, and KVX - sadly - are once again
> exceptions.
> 
> For cris it's a PLT reloc which is being replaced.

The CRIS bits are ok.  At the time, I chose to go with a
CRIS-specific reloc because it looks odd with a
differently-defined reloc in the middle of CRIS-specific
relocs, like in:

> --- a/bfd/elf32-cris.c
> +++ b/bfd/elf32-cris.c
> @@ -408,7 +408,7 @@ static const struct cris_reloc_map cris_
>    { BFD_RELOC_CRIS_32_GOTPLT,	R_CRIS_32_GOTPLT },
>    { BFD_RELOC_CRIS_32_GOTREL,	R_CRIS_32_GOTREL },
>    { BFD_RELOC_CRIS_32_PLT_GOTREL, R_CRIS_32_PLT_GOTREL },
> -  { BFD_RELOC_CRIS_32_PLT_PCREL, R_CRIS_32_PLT_PCREL },
> +  { BFD_RELOC_32_PLT_PCREL,	R_CRIS_32_PLT_PCREL },
>    { BFD_RELOC_CRIS_32_GOT_GD,	R_CRIS_32_GOT_GD },
>    { BFD_RELOC_CRIS_16_GOT_GD,	R_CRIS_16_GOT_GD },
>    { BFD_RELOC_CRIS_32_GD,	R_CRIS_32_GD },

and similar hunks.  Again FAOD: the patch is ok.

BTW, while it doesn't matter in this context (AFAIK),
pc-relative are still target-specific, since there's also an
inherent target-specific offset; a target-specific
definition of the value of "pc".  Like: it can be the
address after the reloc, or the address of the reloc, or (I
suppose) a different offset.

brgds, H-P


More information about the Binutils mailing list