diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2022-01-06 09:24:41 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2022-01-12 06:04:51 -0800 |
commit | 23cc1de50b006fa10e295bdb4455540f001515e9 (patch) | |
tree | d25d69445f837310c737233f5987861c9ca88a49 /bfd/elflink.c | |
parent | ld: Initial DT_RELR support (diff) | |
download | binutils-gdb-23cc1de50b006fa10e295bdb4455540f001515e9.tar.gz binutils-gdb-23cc1de50b006fa10e295bdb4455540f001515e9.tar.bz2 binutils-gdb-23cc1de50b006fa10e295bdb4455540f001515e9.zip |
elf: Add size_relative_relocs and finish_relative_relocs
On some targets, the DT_RELR section size can be computed only after all
symbols addresses can be determined. Set the preliminary DT_RELR section
size before mapping sections to segments and set the final DT_RELR section
size after regular symbol processing is done.
* elf-bfd.h (elf_backend_data): Add size_relative_relocs and
finish_relative_relocs.
* elf.c (_bfd_elf_map_sections_to_segments): Call
size_relative_relocs if DT_RELR is enabled.
* elflink.c (bfd_elf_final_link): Call finish_relative_relocs
after regular symbol processing is finished if DT_RELR is enabled.
* elfxx-target.h (elf_backend_size_relative_relocs): New.
(elf_backend_finish_relative_relocs): Likewise.
(elfNN_bed): Add elf_backend_size_relative_relocs and
elf_backend_finish_relative_relocs.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index 17407f26bc1..1613bc74819 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -12599,6 +12599,14 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) if (!_bfd_elf_fixup_eh_frame_hdr (info)) return false; + /* Finish relative relocations here after regular symbol processing + is finished if DT_RELR is enabled. */ + if (info->enable_dt_relr + && bed->finish_relative_relocs + && !bed->finish_relative_relocs (info)) + info->callbacks->einfo + (_("%F%P: %pB: failed to finish relative relocations\n"), abfd); + /* Since ELF permits relocations to be against local symbols, we must have the local symbols available when we do the relocations. Since we would rather only read the local symbols once, and we |