/* Pending relaxation (byte deletion) operations meant for roughly
sequential access. */
splay_tree pending_delete_ops;
+
+ /* If any input contains a reloc potentially removing bytes, i.e.
+ R_LARCH_ALIGN or R_LARCH_RELAX. */
+ bool reloc_may_remove_bytes;
};
struct loongarch_elf_section_data
const Elf_Internal_Rela *rel;
asection *sreloc = NULL;
+ htab = loongarch_elf_hash_table (info);
+
if (bfd_link_relocatable (info))
- return true;
+ {
+ if (!htab->reloc_may_remove_bytes)
+ for (rel = relocs; rel < relocs + sec->reloc_count; rel++)
+ switch (ELFNN_R_TYPE (rel->r_info))
+ {
+ case R_LARCH_ALIGN:
+ case R_LARCH_RELAX:
+ htab->reloc_may_remove_bytes = true;
+ return true;
+ default:
+ continue;
+ }
+
+ /* No need for more checks with ld -r. */
+ return true;
+ }
- htab = loongarch_elf_hash_table (info);
symtab_hdr = &elf_symtab_hdr (abfd);
sym_hashes = elf_sym_hashes (abfd);
(const char *, asection *),
void (*layout_sections_again) (void))
{
+
+ struct loongarch_elf_link_hash_table *htab;
bool need_laying_out = false;
+
+ htab = loongarch_elf_hash_table (info);
+ if (!htab->reloc_may_remove_bytes)
+ return true;
+
for (bfd *input_bfd = info->input_bfds; input_bfd != NULL;
input_bfd = input_bfd->link.next)
{