[PATCH 15/15] s390: Use RELA_ENTRY_SIZE instead of sizeof (Elf{32|64}_External_Rela)
Jens Remus
jremus@linux.ibm.com
Fri Nov 7 16:34:58 GMT 2025
Instead of having two variants scattered around that are equivalent
use the one that is shorter.
Additionally this simplifies comparison of elf32-s390.c and
elf64-s390.c, as it reduces the number of unimportant differences.
Non-functional change.
bfd/
* elf32-s390.c: Use RELA_ENTRY_SIZE instead of
sizeof (Elf32_External_Rela).
* elf64-s390.c: Use RELA_ENTRY_SIZE instead of
sizeof (Elf64_External_Rela).
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
bfd/elf32-s390.c | 22 +++++++++++-----------
bfd/elf64-s390.c | 29 ++++++++++++++---------------
2 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index c5cba3ef02c1..f1fb81dd88d5 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -1549,7 +1549,7 @@ elf_s390_adjust_dynamic_symbol (struct bfd_link_info *info,
}
if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
{
- srel->size += sizeof (Elf32_External_Rela);
+ srel->size += RELA_ENTRY_SIZE;
h->needs_copy = 1;
}
@@ -1622,7 +1622,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
htab->elf.sgotplt->size += GOT_ENTRY_SIZE;
/* We also need to make an entry in the .rela.plt section. */
- htab->elf.srelplt->size += sizeof (Elf32_External_Rela);
+ htab->elf.srelplt->size += RELA_ENTRY_SIZE;
}
else
{
@@ -1684,13 +1684,13 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
R_390_TLS_GD32 needs one if local symbol and two if global. */
if ((tls_type == GOT_TLS_GD && h->dynindx == -1)
|| tls_type >= GOT_TLS_IE)
- htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
+ htab->elf.srelgot->size += RELA_ENTRY_SIZE;
else if (tls_type == GOT_TLS_GD)
- htab->elf.srelgot->size += 2 * sizeof (Elf32_External_Rela);
+ htab->elf.srelgot->size += 2 * RELA_ENTRY_SIZE;
else if (!UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)
&& (bfd_link_pic (info)
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
- htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
+ htab->elf.srelgot->size += RELA_ENTRY_SIZE;
}
else
h->got.offset = (bfd_vma) -1;
@@ -1778,7 +1778,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
{
asection *sreloc = elf_section_data (p->sec)->sreloc;
- sreloc->size += p->count * sizeof (Elf32_External_Rela);
+ sreloc->size += p->count * RELA_ENTRY_SIZE;
}
return true;
@@ -1851,7 +1851,7 @@ elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
else if (p->count != 0)
{
srela = elf_section_data (p->sec)->sreloc;
- srela->size += p->count * sizeof (Elf32_External_Rela);
+ srela->size += p->count * RELA_ENTRY_SIZE;
if ((p->sec->output_section->flags & SEC_READONLY) != 0)
info->flags |= DF_TEXTREL;
}
@@ -1877,7 +1877,7 @@ elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
if (*local_tls_type == GOT_TLS_GD)
s->size += GOT_ENTRY_SIZE;
if (bfd_link_pic (info))
- srela->size += sizeof (Elf32_External_Rela);
+ srela->size += RELA_ENTRY_SIZE;
}
else
*local_got = (bfd_vma) -1;
@@ -1904,7 +1904,7 @@ elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
relocs. */
htab->tls_ldm_got.offset = htab->elf.sgot->size;
htab->elf.sgot->size += 2 * GOT_ENTRY_SIZE;
- htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
+ htab->elf.srelgot->size += RELA_ENTRY_SIZE;
}
else
htab->tls_ldm_got.offset = -1;
@@ -3426,7 +3426,7 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd,
htab->elf.splt->contents + h->plt.offset + 24);
}
/* Insert offset into reloc. table here. */
- bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rela),
+ bfd_put_32 (output_bfd, plt_index * RELA_ENTRY_SIZE,
htab->elf.splt->contents + h->plt.offset + 28);
/* Fill in the entry in the global offset table.
@@ -3444,7 +3444,7 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd,
+ got_offset);
rela.r_info = ELF32_R_INFO (h->dynindx, R_390_JMP_SLOT);
rela.r_addend = 0;
- loc = htab->elf.srelplt->contents + plt_index * sizeof (Elf32_External_Rela);
+ loc = htab->elf.srelplt->contents + plt_index * RELA_ENTRY_SIZE;
bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
if (!h->def_regular)
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index 6ba67553f03c..494f9120a74e 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -1559,7 +1559,7 @@ elf_s390_adjust_dynamic_symbol (struct bfd_link_info *info,
}
if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
{
- srel->size += sizeof (Elf64_External_Rela);
+ srel->size += RELA_ENTRY_SIZE;
h->needs_copy = 1;
}
@@ -1762,7 +1762,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
htab->elf.sgotplt->size += GOT_ENTRY_SIZE;
/* We also need to make an entry in the .rela.plt section. */
- htab->elf.srelplt->size += sizeof (Elf64_External_Rela);
+ htab->elf.srelplt->size += RELA_ENTRY_SIZE;
}
else
{
@@ -1824,13 +1824,13 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
R_390_TLS_GD64 needs one if local symbol and two if global. */
if ((tls_type == GOT_TLS_GD && h->dynindx == -1)
|| tls_type >= GOT_TLS_IE)
- htab->elf.srelgot->size += sizeof (Elf64_External_Rela);
+ htab->elf.srelgot->size += RELA_ENTRY_SIZE;
else if (tls_type == GOT_TLS_GD)
- htab->elf.srelgot->size += 2 * sizeof (Elf64_External_Rela);
+ htab->elf.srelgot->size += 2 * RELA_ENTRY_SIZE;
else if (!UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)
&& (bfd_link_pic (info)
|| WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
- htab->elf.srelgot->size += sizeof (Elf64_External_Rela);
+ htab->elf.srelgot->size += RELA_ENTRY_SIZE;
}
else
h->got.offset = (bfd_vma) -1;
@@ -1918,7 +1918,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
{
asection *sreloc = elf_section_data (p->sec)->sreloc;
- sreloc->size += p->count * sizeof (Elf64_External_Rela);
+ sreloc->size += p->count * RELA_ENTRY_SIZE;
}
return true;
@@ -2005,7 +2005,7 @@ elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
else if (p->count != 0)
{
srela = elf_section_data (p->sec)->sreloc;
- srela->size += p->count * sizeof (Elf64_External_Rela);
+ srela->size += p->count * RELA_ENTRY_SIZE;
if ((p->sec->output_section->flags & SEC_READONLY) != 0)
info->flags |= DF_TEXTREL;
}
@@ -2031,7 +2031,7 @@ elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
if (*local_tls_type == GOT_TLS_GD)
s->size += GOT_ENTRY_SIZE;
if (bfd_link_pic (info))
- srela->size += sizeof (Elf64_External_Rela);
+ srela->size += RELA_ENTRY_SIZE;
}
else
*local_got = (bfd_vma) -1;
@@ -2045,7 +2045,7 @@ elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
local_plt[i].plt.offset = htab->elf.iplt->size;
htab->elf.iplt->size += PLT_ENTRY_SIZE;
htab->elf.igotplt->size += GOT_ENTRY_SIZE;
- htab->elf.irelplt->size += sizeof (Elf64_External_Rela);
+ htab->elf.irelplt->size += RELA_ENTRY_SIZE;
}
else
local_plt[i].plt.offset = (bfd_vma) -1;
@@ -2058,7 +2058,7 @@ elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
relocs. */
htab->tls_ldm_got.offset = htab->elf.sgot->size;
htab->elf.sgot->size += 2 * GOT_ENTRY_SIZE;
- htab->elf.srelgot->size += sizeof (Elf64_External_Rela);
+ htab->elf.srelgot->size += RELA_ENTRY_SIZE;
}
else
htab->tls_ldm_got.offset = -1;
@@ -3533,7 +3533,7 @@ elf_s390_finish_ifunc_symbol (bfd *output_bfd,
plt->contents + plt_offset + 24);
/* Fixup offset into .rela.plt section. */
bfd_put_32 (output_bfd, relplt->output_offset +
- plt_index * sizeof (Elf64_External_Rela),
+ plt_index * RELA_ENTRY_SIZE,
plt->contents + plt_offset + 28);
/* Fill in the entry in the global offset table.
@@ -3566,7 +3566,7 @@ elf_s390_finish_ifunc_symbol (bfd *output_bfd,
rela.r_addend = 0;
}
- loc = relplt->contents + plt_index * sizeof (Elf64_External_Rela);
+ loc = relplt->contents + plt_index * RELA_ENTRY_SIZE;
bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
}
@@ -3644,7 +3644,7 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd,
(PLT_ENTRY_SIZE * plt_index) + 22)/2,
htab->elf.splt->contents + h->plt.offset + 24);
/* Fixup offset into .rela.plt section. */
- bfd_put_32 (output_bfd, plt_index * sizeof (Elf64_External_Rela),
+ bfd_put_32 (output_bfd, plt_index * RELA_ENTRY_SIZE,
htab->elf.splt->contents + h->plt.offset + 28);
/* Fill in the entry in the global offset table.
@@ -3662,8 +3662,7 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd,
+ gotplt_offset);
rela.r_info = ELF64_R_INFO (h->dynindx, R_390_JMP_SLOT);
rela.r_addend = 0;
- loc = htab->elf.srelplt->contents + plt_index *
- sizeof (Elf64_External_Rela);
+ loc = htab->elf.srelplt->contents + plt_index * RELA_ENTRY_SIZE;
bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
if (!h->def_regular)
--
2.48.1
More information about the Binutils
mailing list