(bfd *abfd, struct bfd_link_info *info, asection *o,
const Elf_Internal_Rela *relocs);
+ /* The SIZE_RELATIVE_RELOCS function is called to size relative
+ relocations when mappig sections to segments. */
+ bool (*size_relative_relocs)
+ (struct bfd_link_info *info, bool *need_layout);
+
+ /* The FINISH_RELATIVE_RELOCS function is called to finish relative
+ relocations in bfd_elf_final_link. */
+ bool (*finish_relative_relocs)
+ (struct bfd_link_info *info);
+
/* The CHECK_DIRECTIVES function is called once per input file by
the add_symbols phase of the ELF backend linker. The function
must inspect the bfd and create any additional symbols according
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;
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)
{
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
#ifndef elf_backend_check_relocs
#define elf_backend_check_relocs 0
#endif
+#ifndef elf_backend_size_relative_relocs
+#define elf_backend_size_relative_relocs 0
+#endif
+#ifndef elf_backend_finish_relative_relocs
+#define elf_backend_finish_relative_relocs 0
+#endif
#ifndef elf_backend_check_directives
#define elf_backend_check_directives 0
#endif
elf_backend_omit_section_dynsym,
elf_backend_relocs_compatible,
elf_backend_check_relocs,
+ elf_backend_size_relative_relocs,
+ elf_backend_finish_relative_relocs,
elf_backend_check_directives,
elf_backend_notice_as_needed,
elf_backend_adjust_dynamic_symbol,