aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2019-04-25 15:07:14 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2019-05-24 15:11:00 +0100
commit823710d5856996d1f54f04ecb2f7647aeae99b5b (patch)
tree7b44adae584db07fd7736ad67b89626e1a757a00 /bfd
parent0b4eac57c44ec4c9e13f5201b40936c3b3e6c639 (diff)
downloadgdb-823710d5856996d1f54f04ecb2f7647aeae99b5b.zip
gdb-823710d5856996d1f54f04ecb2f7647aeae99b5b.tar.gz
gdb-823710d5856996d1f54f04ecb2f7647aeae99b5b.tar.bz2
aarch64: handle STO_AARCH64_VARIANT_PCS in bfd
Propagate STO_AARCH64_VARIANT_PCS st_other attribute to the output and add DT_AARCH64_VARIANT_PCS dynamic tag if necessary. Mismatching attributes are not diagnosed. bfd/ChangeLog: * elfnn-aarch64.c (elfNN_aarch64_merge_symbol_attribute): New function. (struct elf_aarch64_link_hash_table): Add variant_pcs member. (elfNN_aarch64_allocate_dynrelocs): Update variant_pcs. (elfNN_aarch64_size_dynamic_sections): Add DT_AARCH64_VARIANT_PCS. (elf_backend_merge_symbol_attribute): Define. ld/ChangeLog: * testsuite/ld-aarch64/aarch64-elf.exp: Add new tests. * testsuite/ld-aarch64/variant_pcs-1.s: New asm for tests. * testsuite/ld-aarch64/variant_pcs-2.s: New asm for tests. * testsuite/ld-aarch64/variant_pcs-now.d: New test. * testsuite/ld-aarch64/variant_pcs-r.d: New test. * testsuite/ld-aarch64/variant_pcs-shared.d: New test. * testsuite/ld-aarch64/variant_pcs.ld: New linker script for tests.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog8
-rw-r--r--bfd/elfnn-aarch64.c41
2 files changed, 49 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index fe2f5b1..a7603da 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2019-05-24 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ * elfnn-aarch64.c (elfNN_aarch64_merge_symbol_attribute): New function.
+ (struct elf_aarch64_link_hash_table): Add variant_pcs member.
+ (elfNN_aarch64_allocate_dynrelocs): Update variant_pcs.
+ (elfNN_aarch64_size_dynamic_sections): Add DT_AARCH64_VARIANT_PCS.
+ (elf_backend_merge_symbol_attribute): Define.
+
2019-05-24 Alan Modra <amodra@gmail.com>
* po/SRC-POTFILES.in: Regenerate.
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 9e28544..761e6b9 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -2681,6 +2681,9 @@ struct elf_aarch64_link_hash_table
unsigned int top_index;
asection **input_list;
+ /* JUMP_SLOT relocs for variant PCS symbols may be present. */
+ int variant_pcs;
+
/* The offset into splt of the PLT entry for the TLS descriptor
resolver. Special values are 0, if not necessary (or not found
to be necessary yet), and -1 if needed but not determined
@@ -2895,6 +2898,31 @@ elfNN_aarch64_copy_indirect_symbol (struct bfd_link_info *info,
_bfd_elf_link_hash_copy_indirect (info, dir, ind);
}
+/* Merge non-visibility st_other attributes. */
+
+static void
+elfNN_aarch64_merge_symbol_attribute (struct elf_link_hash_entry *h,
+ const Elf_Internal_Sym *isym,
+ bfd_boolean definition ATTRIBUTE_UNUSED,
+ bfd_boolean dynamic ATTRIBUTE_UNUSED)
+{
+ unsigned int isym_sto = isym->st_other & ~ELF_ST_VISIBILITY (-1);
+ unsigned int h_sto = h->other & ~ELF_ST_VISIBILITY (-1);
+
+ if (isym_sto == h_sto)
+ return;
+
+ if (isym_sto & ~STO_AARCH64_VARIANT_PCS)
+ /* Not fatal, this callback cannot fail. */
+ _bfd_error_handler (_("unknown attribute for symbol `%s': 0x%02x"),
+ h->root.root.string, isym_sto);
+
+ /* Note: Ideally we would warn about any attribute mismatch, but
+ this api does not allow that without substantial changes. */
+ if (isym_sto & STO_AARCH64_VARIANT_PCS)
+ h->other |= STO_AARCH64_VARIANT_PCS;
+}
+
/* Destroy an AArch64 elf linker hash table. */
static void
@@ -8571,6 +8599,12 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
updated. */
htab->root.srelplt->reloc_count++;
+
+ /* Mark the DSO in case R_<CLS>_JUMP_SLOT relocs against
+ variant PCS symbols are present. */
+ if (h->other & STO_AARCH64_VARIANT_PCS)
+ htab->variant_pcs = 1;
+
}
else
{
@@ -9159,6 +9193,10 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
|| !add_dynamic_entry (DT_JMPREL, 0))
return FALSE;
+ if (htab->variant_pcs
+ && !add_dynamic_entry (DT_AARCH64_VARIANT_PCS, 0))
+ return FALSE;
+
if (htab->tlsdesc_plt
&& !(info->flags & DF_BIND_NOW)
&& (!add_dynamic_entry (DT_TLSDESC_PLT, 0)
@@ -10083,6 +10121,9 @@ const struct elf_size_info elfNN_aarch64_size_info =
#define elf_backend_copy_indirect_symbol \
elfNN_aarch64_copy_indirect_symbol
+#define elf_backend_merge_symbol_attribute \
+ elfNN_aarch64_merge_symbol_attribute
+
/* Create .dynbss, and .rela.bss sections in DYNOBJ, and set up shortcuts
to them in our hash. */
#define elf_backend_create_dynamic_sections \