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/elf.c | |
parent | 6a91be866619c592762cd7e9b034a9f7ad27ef37 (diff) | |
download | gdb-23cc1de50b006fa10e295bdb4455540f001515e9.zip gdb-23cc1de50b006fa10e295bdb4455540f001515e9.tar.gz gdb-23cc1de50b006fa10e295bdb4455540f001515e9.tar.bz2 |
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/elf.c')
-rw-r--r-- | bfd/elf.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -4615,7 +4615,7 @@ elf_modify_segment_map (bfd *abfd, bool _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info, - bool *need_layout ATTRIBUTE_UNUSED) + bool *need_layout) { unsigned int count; struct elf_segment_map *m; @@ -4626,7 +4626,17 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, no_user_phdrs = elf_seg_map (abfd) == NULL; if (info != NULL) - info->user_phdrs = !no_user_phdrs; + { + info->user_phdrs = !no_user_phdrs; + + /* Size the relative relocations if DT_RELR is enabled. */ + if (info->enable_dt_relr + && need_layout != NULL + && bed->size_relative_relocs + && !bed->size_relative_relocs (info, need_layout)) + info->callbacks->einfo + (_("%F%P: failed to size relative relocations\n")); + } if (no_user_phdrs && bfd_count_sections (abfd) != 0) { |