aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@arm.com>2023-01-02 15:46:31 +0000
committerChristophe Lyon <christophe.lyon@arm.com>2023-01-09 16:51:53 +0100
commit2b70b1b838388cc4186933a724eccd0be6b2a955 (patch)
tree69036d38b22879b05c0edbf1bb07b20caa97b434 /bfd
parent4004cf83310e7f8e4cc699261cb69a8fbf6c4dda (diff)
downloadgdb-2b70b1b838388cc4186933a724eccd0be6b2a955.zip
gdb-2b70b1b838388cc4186933a724eccd0be6b2a955.tar.gz
gdb-2b70b1b838388cc4186933a724eccd0be6b2a955.tar.bz2
Fix PR18841 ifunc relocation ordering
In order to get the ifunc relocs properly sorted the correct class needs to be returned. The code mimics what has been done for AArch64. Fixes: FAIL: Run pr18841 with libpr18841b.so FAIL: Run pr18841 with libpr18841c.so FAIL: Run pr18841 with libpr18841bn.so (-z now) FAIL: Run pr18841 with libpr18841cn.so (-z now) bfd/ PR ld/18841 * elf32-arm.c (elf32_arm_reloc_type_class): Return reloc_class_ifunc for ifunc symbols. ld/testsuite/ * ld-arm/ifunc-12.rd: Update relocations order. * ld-arm/ifunc-3.rd: Likewise. * ld-arm/ifunc-4.rd: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/elf32-arm.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 0cd3aec..96ba509 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -17691,6 +17691,35 @@ elf32_arm_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
const asection *rel_sec ATTRIBUTE_UNUSED,
const Elf_Internal_Rela *rela)
{
+ struct elf32_arm_link_hash_table *htab = elf32_arm_hash_table (info);
+
+ if (htab->root.dynsym != NULL
+ && htab->root.dynsym->contents != NULL)
+ {
+ /* Check relocation against STT_GNU_IFUNC symbol if there are
+ dynamic symbols. */
+ bfd *abfd = info->output_bfd;
+ const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ unsigned long r_symndx = ELF32_R_SYM (rela->r_info);
+ if (r_symndx != STN_UNDEF)
+ {
+ Elf_Internal_Sym sym;
+ if (!bed->s->swap_symbol_in (abfd,
+ (htab->root.dynsym->contents
+ + r_symndx * bed->s->sizeof_sym),
+ 0, &sym))
+ {
+ /* xgettext:c-format */
+ _bfd_error_handler (_("%pB symbol number %lu references"
+ " nonexistent SHT_SYMTAB_SHNDX section"),
+ abfd, r_symndx);
+ /* Ideally an error class should be returned here. */
+ }
+ else if (ELF_ST_TYPE (sym.st_info) == STT_GNU_IFUNC)
+ return reloc_class_ifunc;
+ }
+ }
+
switch ((int) ELF32_R_TYPE (rela->r_info))
{
case R_ARM_RELATIVE: