[PATCH 1/2] aarch64: Add DT_RELR support
Nick Clifton
nickc@redhat.com
Fri May 31 08:14:32 GMT 2024
Hi Szabolcs,
> The logic to decide if an input relocation for a symbol becomes a
> particular kind of output relocation is one of the hard to maintain
> parts of the bfd ld backend, since it is partially repeated across
>
> elfNN_aarch64_check_relocs (where dynamic relocations are counted per
> symbol and input section),
>
> elfNN_aarch64_late_size_sections (where relocation sections are sized
> and GOT offsets assigned),
>
> elfNN_aarch64_relocate_section (where most relocations are applied and
> output to a relocation section),
>
> elfNN_aarch64_finish_dynamic_symbol (where some of the GOT
> relocations are applied and output).
>
> The DT_RELR support adds another layer to this complexity: after the
> output relocation sections are sized, so all dynamic relocations are
> accounted (in elfNN_aarch64_late_size_sections), we scan the symbols
> and input relocations again to decide which ones become relative
> relocations that can be packed. The sizes of the relocation sections
> are updated accordingly. This logic must be consistent with the code
> that applies the relocs later so each relative relocation is emitted
> exactly once: either in .rela.* or packed in .relr.dyn.
>
> Sizing of .relr.dyn is done via elfNN_aarch64_size_relative_relocs that
> may be called repeatedly whenever the layout changes since an address
> change can affect the size of the packed format. Then the final content
> is emitted in elfNN_aarch64_finish_relative_relocs, that is called
> after the layout is final and before relocations are applied and
> emitted. These hooks are only called if DT_RELR is enabled.
>
> We only pack relative relocs that are known to be aligned in the output
> during .relr.dyn sizing, the potentially unaligned relative relocs are
> emitted normally (in .rela.*, not packed), because the format requires
> aligned addresses.
> ---
> bfd/elfnn-aarch64.c | 429 +++++++++++++++++++++++++++++++++-
> bfd/elfxx-aarch64.h | 11 +
> ld/emulparams/aarch64elf.sh | 2 +
> ld/emulparams/aarch64fbsd.sh | 2 +
> ld/emulparams/aarch64linux.sh | 2 +
> 5 files changed, 445 insertions(+), 1 deletion(-)
>
Approved - please apply.
Cheers
Nick
More information about the Binutils
mailing list