|
|
5affbb |
diff -rup binutils.orig/bfd/elfnn-aarch64.c binutils-2.30/bfd/elfnn-aarch64.c
|
|
|
5affbb |
--- binutils.orig/bfd/elfnn-aarch64.c 2020-11-04 14:53:52.144476367 +0000
|
|
|
5affbb |
+++ binutils-2.30/bfd/elfnn-aarch64.c 2020-11-04 14:56:42.275422499 +0000
|
|
|
5affbb |
@@ -2191,6 +2191,9 @@ struct elf_aarch64_obj_tdata
|
|
|
5affbb |
|
|
|
5affbb |
/* Zero to warn when linking objects with incompatible wchar_t sizes. */
|
|
|
5affbb |
int no_wchar_size_warning;
|
|
|
5affbb |
+
|
|
|
5affbb |
+ /* All GNU_PROPERTY_AARCH64_FEATURE_1_AND properties. */
|
|
|
5affbb |
+ uint32_t gnu_and_prop;
|
|
|
5affbb |
};
|
|
|
5affbb |
|
|
|
5affbb |
#define elf_aarch64_tdata(bfd) \
|
|
|
5affbb |
@@ -9311,6 +9314,32 @@ elfNN_aarch64_backend_symbol_processing
|
|
|
5affbb |
sym->flags |= BSF_KEEP;
|
|
|
5affbb |
}
|
|
|
5affbb |
|
|
|
5affbb |
+/* Implement elf_backend_setup_gnu_properties for AArch64. It serves as a
|
|
|
5affbb |
+ wrapper function for _bfd_aarch64_elf_link_setup_gnu_properties to account
|
|
|
5affbb |
+ for the effect of GNU properties of the output_bfd. */
|
|
|
5affbb |
+static bfd *
|
|
|
5affbb |
+elfNN_aarch64_link_setup_gnu_properties (struct bfd_link_info *info)
|
|
|
5affbb |
+{
|
|
|
5affbb |
+ uint32_t prop = elf_aarch64_tdata (info->output_bfd)->gnu_and_prop;
|
|
|
5affbb |
+ bfd *pbfd = _bfd_aarch64_elf_link_setup_gnu_properties (info, &prop);
|
|
|
5affbb |
+ elf_aarch64_tdata (info->output_bfd)->gnu_and_prop = prop;
|
|
|
5affbb |
+ return pbfd;
|
|
|
5affbb |
+}
|
|
|
5affbb |
+
|
|
|
5affbb |
+/* Implement elf_backend_merge_gnu_properties for AArch64. It serves as a
|
|
|
5affbb |
+ wrapper function for _bfd_aarch64_elf_merge_gnu_properties to account
|
|
|
5affbb |
+ for the effect of GNU properties of the output_bfd. */
|
|
|
5affbb |
+static bfd_boolean
|
|
|
5affbb |
+elfNN_aarch64_merge_gnu_properties (struct bfd_link_info *info,
|
|
|
5affbb |
+ bfd *abfd,
|
|
|
5affbb |
+ elf_property *aprop,
|
|
|
5affbb |
+ elf_property *bprop)
|
|
|
5affbb |
+{
|
|
|
5affbb |
+ uint32_t prop
|
|
|
5affbb |
+ = elf_aarch64_tdata (info->output_bfd)->gnu_and_prop;
|
|
|
5affbb |
+ return _bfd_aarch64_elf_merge_gnu_properties (info, abfd, aprop,
|
|
|
5affbb |
+ bprop, prop);
|
|
|
5affbb |
+}
|
|
|
5affbb |
|
|
|
5affbb |
/* We use this so we can override certain functions
|
|
|
5affbb |
(though currently we don't). */
|
|
|
5affbb |
@@ -9453,6 +9482,12 @@ const struct elf_size_info elfNN_aarch64
|
|
|
5affbb |
#define elf_backend_symbol_processing \
|
|
|
5affbb |
elfNN_aarch64_backend_symbol_processing
|
|
|
5affbb |
|
|
|
5affbb |
+#define elf_backend_setup_gnu_properties \
|
|
|
5affbb |
+ elfNN_aarch64_link_setup_gnu_properties
|
|
|
5affbb |
+
|
|
|
5affbb |
+#define elf_backend_merge_gnu_properties \
|
|
|
5affbb |
+ elfNN_aarch64_merge_gnu_properties
|
|
|
5affbb |
+
|
|
|
5affbb |
#define elf_backend_can_refcount 1
|
|
|
5affbb |
#define elf_backend_can_gc_sections 1
|
|
|
5affbb |
#define elf_backend_plt_readonly 1
|
|
|
5affbb |
diff -rup binutils.orig/bfd/elfxx-aarch64.c binutils-2.30/bfd/elfxx-aarch64.c
|
|
|
5affbb |
--- binutils.orig/bfd/elfxx-aarch64.c 2020-11-04 14:53:52.138476401 +0000
|
|
|
5affbb |
+++ binutils-2.30/bfd/elfxx-aarch64.c 2020-11-04 14:56:42.276422492 +0000
|
|
|
5affbb |
@@ -660,3 +660,183 @@ _bfd_aarch64_elf_write_core_note (bfd *a
|
|
|
5affbb |
}
|
|
|
5affbb |
}
|
|
|
5affbb |
}
|
|
|
5affbb |
+
|
|
|
5affbb |
+/* Find the first input bfd with GNU property and merge it with GPROP. If no
|
|
|
5affbb |
+ such input is found, add it to a new section at the last input. Update
|
|
|
5affbb |
+ GPROP accordingly. */
|
|
|
5affbb |
+bfd *
|
|
|
5affbb |
+_bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info,
|
|
|
5affbb |
+ uint32_t *gprop)
|
|
|
5affbb |
+{
|
|
|
5affbb |
+ asection *sec;
|
|
|
5affbb |
+ bfd *pbfd;
|
|
|
5affbb |
+ bfd *ebfd = NULL;
|
|
|
5affbb |
+ elf_property *prop;
|
|
|
5affbb |
+
|
|
|
5affbb |
+ uint32_t gnu_prop = *gprop;
|
|
|
5affbb |
+
|
|
|
5affbb |
+ /* Find a normal input file with GNU property note. */
|
|
|
5affbb |
+ for (pbfd = info->input_bfds;
|
|
|
5affbb |
+ pbfd != NULL;
|
|
|
5affbb |
+ pbfd = pbfd->link.next)
|
|
|
5affbb |
+ if (bfd_get_flavour (pbfd) == bfd_target_elf_flavour
|
|
|
5affbb |
+ && bfd_count_sections (pbfd) != 0)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ ebfd = pbfd;
|
|
|
5affbb |
+
|
|
|
5affbb |
+ if (elf_properties (pbfd) != NULL)
|
|
|
5affbb |
+ break;
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+
|
|
|
5affbb |
+ /* If ebfd != NULL it is either an input with property note or the last
|
|
|
5affbb |
+ input. Either way if we have gnu_prop, we should add it (by creating
|
|
|
5affbb |
+ a section if needed). */
|
|
|
5affbb |
+ if (ebfd != NULL && gnu_prop)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ prop = _bfd_elf_get_property (ebfd,
|
|
|
5affbb |
+ GNU_PROPERTY_AARCH64_FEATURE_1_AND,
|
|
|
5affbb |
+ 4);
|
|
|
5affbb |
+ prop->u.number |= gnu_prop;
|
|
|
5affbb |
+ prop->pr_kind = property_number;
|
|
|
5affbb |
+
|
|
|
5affbb |
+ /* pbfd being NULL implies ebfd is the last input. Create the GNU
|
|
|
5affbb |
+ property note section. */
|
|
|
5affbb |
+ if (pbfd == NULL)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ sec = bfd_make_section_with_flags (ebfd,
|
|
|
5affbb |
+ NOTE_GNU_PROPERTY_SECTION_NAME,
|
|
|
5affbb |
+ (SEC_ALLOC
|
|
|
5affbb |
+ | SEC_LOAD
|
|
|
5affbb |
+ | SEC_IN_MEMORY
|
|
|
5affbb |
+ | SEC_READONLY
|
|
|
5affbb |
+ | SEC_HAS_CONTENTS
|
|
|
5affbb |
+ | SEC_DATA));
|
|
|
5affbb |
+ if (sec == NULL)
|
|
|
5affbb |
+ info->callbacks->einfo (
|
|
|
5affbb |
+ _("%F%P: failed to create GNU property section\n"));
|
|
|
5affbb |
+
|
|
|
5affbb |
+ elf_section_type (sec) = SHT_NOTE;
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+
|
|
|
5affbb |
+ pbfd = _bfd_elf_link_setup_gnu_properties (info);
|
|
|
5affbb |
+
|
|
|
5affbb |
+ if (bfd_link_relocatable (info))
|
|
|
5affbb |
+ return pbfd;
|
|
|
5affbb |
+
|
|
|
5affbb |
+ /* If pbfd has any GNU_PROPERTY_AARCH64_FEATURE_1_AND properties, update
|
|
|
5affbb |
+ gnu_prop accordingly. */
|
|
|
5affbb |
+ if (pbfd != NULL)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ elf_property_list *p;
|
|
|
5affbb |
+
|
|
|
5affbb |
+ /* The property list is sorted in order of type. */
|
|
|
5affbb |
+ for (p = elf_properties (pbfd); p; p = p->next)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ /* Check for all GNU_PROPERTY_AARCH64_FEATURE_1_AND. */
|
|
|
5affbb |
+ if (GNU_PROPERTY_AARCH64_FEATURE_1_AND == p->property.pr_type)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ gnu_prop = (p->property.u.number
|
|
|
5affbb |
+ & (GNU_PROPERTY_AARCH64_FEATURE_1_PAC
|
|
|
5affbb |
+ | GNU_PROPERTY_AARCH64_FEATURE_1_BTI));
|
|
|
5affbb |
+ break;
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+ else if (GNU_PROPERTY_AARCH64_FEATURE_1_AND < p->property.pr_type)
|
|
|
5affbb |
+ break;
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+ *gprop = gnu_prop;
|
|
|
5affbb |
+ return pbfd;
|
|
|
5affbb |
+}
|
|
|
5affbb |
+
|
|
|
5affbb |
+/* Define elf_backend_parse_gnu_properties for AArch64. */
|
|
|
5affbb |
+enum elf_property_kind
|
|
|
5affbb |
+_bfd_aarch64_elf_parse_gnu_properties (bfd *abfd, unsigned int type,
|
|
|
5affbb |
+ bfd_byte *ptr, unsigned int datasz)
|
|
|
5affbb |
+{
|
|
|
5affbb |
+ elf_property *prop;
|
|
|
5affbb |
+
|
|
|
5affbb |
+ switch (type)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ case GNU_PROPERTY_AARCH64_FEATURE_1_AND:
|
|
|
5affbb |
+ if (datasz != 4)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ _bfd_error_handler
|
|
|
5affbb |
+ ( _("error: %pB: <corrupt AArch64 used size: 0x%x>"),
|
|
|
5affbb |
+ abfd, datasz);
|
|
|
5affbb |
+ return property_corrupt;
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+ prop = _bfd_elf_get_property (abfd, type, datasz);
|
|
|
5affbb |
+ /* Combine properties of the same type. */
|
|
|
5affbb |
+ prop->u.number |= bfd_h_get_32 (abfd, ptr);
|
|
|
5affbb |
+ prop->pr_kind = property_number;
|
|
|
5affbb |
+ break;
|
|
|
5affbb |
+
|
|
|
5affbb |
+ default:
|
|
|
5affbb |
+ return property_ignored;
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+
|
|
|
5affbb |
+ return property_number;
|
|
|
5affbb |
+}
|
|
|
5affbb |
+
|
|
|
5affbb |
+/* Merge AArch64 GNU property BPROP with APROP also accounting for PROP.
|
|
|
5affbb |
+ If APROP isn't NULL, merge it with BPROP and/or PROP. Vice-versa if BROP
|
|
|
5affbb |
+ isn't NULL. Return TRUE if there is any update to APROP or if BPROP should
|
|
|
5affbb |
+ be merge with ABFD. */
|
|
|
5affbb |
+bfd_boolean
|
|
|
5affbb |
+_bfd_aarch64_elf_merge_gnu_properties (struct bfd_link_info *info
|
|
|
5affbb |
+ ATTRIBUTE_UNUSED,
|
|
|
5affbb |
+ bfd *abfd ATTRIBUTE_UNUSED,
|
|
|
5affbb |
+ elf_property *aprop,
|
|
|
5affbb |
+ elf_property *bprop,
|
|
|
5affbb |
+ uint32_t prop)
|
|
|
5affbb |
+{
|
|
|
5affbb |
+ unsigned int orig_number;
|
|
|
5affbb |
+ bfd_boolean updated = FALSE;
|
|
|
5affbb |
+ unsigned int pr_type = aprop != NULL ? aprop->pr_type : bprop->pr_type;
|
|
|
5affbb |
+
|
|
|
5affbb |
+ switch (pr_type)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ case GNU_PROPERTY_AARCH64_FEATURE_1_AND:
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ if (aprop != NULL && bprop != NULL)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ orig_number = aprop->u.number;
|
|
|
5affbb |
+ aprop->u.number = (orig_number & bprop->u.number) | prop;
|
|
|
5affbb |
+ updated = orig_number != aprop->u.number;
|
|
|
5affbb |
+ /* Remove the property if all feature bits are cleared. */
|
|
|
5affbb |
+ if (aprop->u.number == 0)
|
|
|
5affbb |
+ aprop->pr_kind = property_remove;
|
|
|
5affbb |
+ break;
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+ /* If either is NULL, the AND would be 0 so, if there is
|
|
|
5affbb |
+ any PROP, asign it to the input that is not NULL. */
|
|
|
5affbb |
+ if (prop)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ if (aprop != NULL)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ orig_number = aprop->u.number;
|
|
|
5affbb |
+ aprop->u.number = prop;
|
|
|
5affbb |
+ updated = orig_number != aprop->u.number;
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+ else
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ bprop->u.number = prop;
|
|
|
5affbb |
+ updated = TRUE;
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+ /* No PROP and BPROP is NULL, so remove APROP. */
|
|
|
5affbb |
+ else if (aprop != NULL)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ aprop->pr_kind = property_remove;
|
|
|
5affbb |
+ updated = TRUE;
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+ break;
|
|
|
5affbb |
+
|
|
|
5affbb |
+ default:
|
|
|
5affbb |
+ abort ();
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+
|
|
|
5affbb |
+ return updated;
|
|
|
5affbb |
+}
|
|
|
5affbb |
diff -rup binutils.orig/bfd/elfxx-aarch64.h binutils-2.30/bfd/elfxx-aarch64.h
|
|
|
5affbb |
--- binutils.orig/bfd/elfxx-aarch64.h 2020-11-04 14:53:52.134476424 +0000
|
|
|
5affbb |
+++ binutils-2.30/bfd/elfxx-aarch64.h 2020-11-04 14:56:42.276422492 +0000
|
|
|
5affbb |
@@ -65,3 +65,19 @@ _bfd_aarch64_elf_write_core_note (bfd *,
|
|
|
5affbb |
#define elf_backend_grok_prstatus _bfd_aarch64_elf_grok_prstatus
|
|
|
5affbb |
#define elf_backend_grok_psinfo _bfd_aarch64_elf_grok_psinfo
|
|
|
5affbb |
#define elf_backend_write_core_note _bfd_aarch64_elf_write_core_note
|
|
|
5affbb |
+
|
|
|
5affbb |
+extern bfd *
|
|
|
5affbb |
+_bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *,
|
|
|
5affbb |
+ uint32_t *);
|
|
|
5affbb |
+
|
|
|
5affbb |
+extern enum elf_property_kind
|
|
|
5affbb |
+_bfd_aarch64_elf_parse_gnu_properties (bfd *, unsigned int,
|
|
|
5affbb |
+ bfd_byte *, unsigned int);
|
|
|
5affbb |
+
|
|
|
5affbb |
+extern bfd_boolean
|
|
|
5affbb |
+_bfd_aarch64_elf_merge_gnu_properties (struct bfd_link_info *, bfd *,
|
|
|
5affbb |
+ elf_property *, elf_property *,
|
|
|
5affbb |
+ uint32_t);
|
|
|
5affbb |
+
|
|
|
5affbb |
+#define elf_backend_parse_gnu_properties \
|
|
|
5affbb |
+ _bfd_aarch64_elf_parse_gnu_properties
|
|
|
5affbb |
diff -rup binutils.orig/binutils/readelf.c binutils-2.30/binutils/readelf.c
|
|
|
5affbb |
--- binutils.orig/binutils/readelf.c 2020-11-04 14:53:51.723478764 +0000
|
|
|
5affbb |
+++ binutils-2.30/binutils/readelf.c 2020-11-04 14:56:42.277422485 +0000
|
|
|
5affbb |
@@ -17103,6 +17103,33 @@ decode_x86_feature_2 (unsigned int bitma
|
|
|
5affbb |
}
|
|
|
5affbb |
|
|
|
5affbb |
static void
|
|
|
5affbb |
+decode_aarch64_feature_1_and (unsigned int bitmask)
|
|
|
5affbb |
+{
|
|
|
5affbb |
+ while (bitmask)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ unsigned int bit = bitmask & (- bitmask);
|
|
|
5affbb |
+
|
|
|
5affbb |
+ bitmask &= ~ bit;
|
|
|
5affbb |
+ switch (bit)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ case GNU_PROPERTY_AARCH64_FEATURE_1_BTI:
|
|
|
5affbb |
+ printf ("BTI");
|
|
|
5affbb |
+ break;
|
|
|
5affbb |
+
|
|
|
5affbb |
+ case GNU_PROPERTY_AARCH64_FEATURE_1_PAC:
|
|
|
5affbb |
+ printf ("PAC");
|
|
|
5affbb |
+ break;
|
|
|
5affbb |
+
|
|
|
5affbb |
+ default:
|
|
|
5affbb |
+ printf (_("<unknown: %x>"), bit);
|
|
|
5affbb |
+ break;
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+ if (bitmask)
|
|
|
5affbb |
+ printf (", ");
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+}
|
|
|
5affbb |
+
|
|
|
5affbb |
+static void
|
|
|
5affbb |
print_gnu_property_note (Filedata * filedata, Elf_Internal_Note * pnote)
|
|
|
5affbb |
{
|
|
|
5affbb |
unsigned char * ptr = (unsigned char *) pnote->descdata;
|
|
|
5affbb |
@@ -17236,6 +17263,18 @@ print_gnu_property_note (Filedata * file
|
|
|
5affbb |
break;
|
|
|
5affbb |
}
|
|
|
5affbb |
}
|
|
|
5affbb |
+ else if (filedata->file_header.e_machine == EM_AARCH64)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ if (type == GNU_PROPERTY_AARCH64_FEATURE_1_AND)
|
|
|
5affbb |
+ {
|
|
|
5affbb |
+ printf ("AArch64 feature: ");
|
|
|
5affbb |
+ if (datasz != 4)
|
|
|
5affbb |
+ printf (_("<corrupt length: %#x> "), datasz);
|
|
|
5affbb |
+ else
|
|
|
5affbb |
+ decode_aarch64_feature_1_and (byte_get (ptr, 4));
|
|
|
5affbb |
+ goto next;
|
|
|
5affbb |
+ }
|
|
|
5affbb |
+ }
|
|
|
5affbb |
}
|
|
|
5affbb |
else
|
|
|
5affbb |
{
|
|
|
5affbb |
diff -rup binutils.orig/include/elf/common.h binutils-2.30/include/elf/common.h
|
|
|
5affbb |
--- binutils.orig/include/elf/common.h 2020-11-04 14:53:52.155476304 +0000
|
|
|
5affbb |
+++ binutils-2.30/include/elf/common.h 2020-11-04 14:56:42.277422485 +0000
|
|
|
5affbb |
@@ -832,6 +832,12 @@
|
|
|
5affbb |
#define GNU_PROPERTY_X86_FEATURE_2_XSAVEOPT (1U << 8)
|
|
|
5affbb |
#define GNU_PROPERTY_X86_FEATURE_2_XSAVEC (1U << 9)
|
|
|
5affbb |
|
|
|
5affbb |
+/* AArch64 specific GNU PROPERTY. */
|
|
|
5affbb |
+#define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000
|
|
|
5affbb |
+
|
|
|
5affbb |
+#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1U << 0)
|
|
|
5affbb |
+#define GNU_PROPERTY_AARCH64_FEATURE_1_PAC (1U << 1)
|
|
|
5affbb |
+
|
|
|
5affbb |
/* Values used in GNU .note.ABI-tag notes (NT_GNU_ABI_TAG). */
|
|
|
5affbb |
#define GNU_ABI_TAG_LINUX 0
|
|
|
5affbb |
#define GNU_ABI_TAG_HURD 1
|
|
|
5affbb |
diff -rup binutils.orig/ld/testsuite/ld-aarch64/aarch64-elf.exp binutils-2.30/ld/testsuite/ld-aarch64/aarch64-elf.exp
|
|
|
5affbb |
--- binutils.orig/ld/testsuite/ld-aarch64/aarch64-elf.exp 2020-11-04 14:53:51.843478081 +0000
|
|
|
5affbb |
+++ binutils-2.30/ld/testsuite/ld-aarch64/aarch64-elf.exp 2020-11-04 14:56:42.278422479 +0000
|
|
|
5affbb |
@@ -337,6 +337,10 @@ run_dump_test_lp64 "variant_pcs-r"
|
|
|
5affbb |
run_dump_test_lp64 "variant_pcs-shared"
|
|
|
5affbb |
run_dump_test_lp64 "variant_pcs-now"
|
|
|
5affbb |
|
|
|
5affbb |
+run_dump_test "property-bti-pac1"
|
|
|
5affbb |
+run_dump_test "property-bti-pac2"
|
|
|
5affbb |
+run_dump_test "property-bti-pac3"
|
|
|
5affbb |
+
|
|
|
5affbb |
set aarch64elflinktests {
|
|
|
5affbb |
{"ld-aarch64/so with global symbol" "-shared" "" "" {copy-reloc-so.s}
|
|
|
5affbb |
{} "copy-reloc-so.so"}
|
|
|
5affbb |
--- /dev/null 2020-11-04 08:04:13.849482156 +0000
|
|
|
5affbb |
+++ binutils-2.30/ld/testsuite/ld-aarch64/property-bti-pac1.d 2020-11-04 14:56:42.278422479 +0000
|
|
|
5affbb |
@@ -0,0 +1,11 @@
|
|
|
5affbb |
+#name: GNU Property (single input, combine section)
|
|
|
5affbb |
+#source: property-bti-pac1.s
|
|
|
5affbb |
+#as: -march=armv8.5-a -defsym __mult__=0
|
|
|
5affbb |
+#ld: -shared
|
|
|
5affbb |
+#readelf: -n
|
|
|
5affbb |
+#target: *linux*
|
|
|
5affbb |
+
|
|
|
5affbb |
+Displaying notes found in: .note.gnu.property
|
|
|
5affbb |
+ Owner Data size Description
|
|
|
5affbb |
+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
|
|
|
5affbb |
+ Properties: AArch64 feature: BTI, PAC
|
|
|
5affbb |
--- /dev/null 2020-11-04 08:04:13.849482156 +0000
|
|
|
5affbb |
+++ binutils-2.30/ld/testsuite/ld-aarch64/property-bti-pac1.s 2020-11-04 14:56:42.278422479 +0000
|
|
|
5affbb |
@@ -0,0 +1,37 @@
|
|
|
5affbb |
+ .text
|
|
|
5affbb |
+ .globl _start
|
|
|
5affbb |
+ .type _start,@function
|
|
|
5affbb |
+_start:
|
|
|
5affbb |
+ mov x1, #2
|
|
|
5affbb |
+.ifndef __mult__
|
|
|
5affbb |
+ bl foo
|
|
|
5affbb |
+.endif
|
|
|
5affbb |
+ .section ".note.gnu.property", "a"
|
|
|
5affbb |
+ .p2align 3
|
|
|
5affbb |
+ .long 1f - 0f /* name length */
|
|
|
5affbb |
+ .long 5f - 2f /* data length */
|
|
|
5affbb |
+ .long 5 /* note type */
|
|
|
5affbb |
+0: .asciz "GNU" /* vendor name */
|
|
|
5affbb |
+1:
|
|
|
5affbb |
+ .p2align 3
|
|
|
5affbb |
+2: .long 0xc0000000 /* pr_type. */
|
|
|
5affbb |
+ .long 4f - 3f /* pr_datasz. */
|
|
|
5affbb |
+3:
|
|
|
5affbb |
+ .long 0x2 /* PAC. */
|
|
|
5affbb |
+4:
|
|
|
5affbb |
+ .p2align 3
|
|
|
5affbb |
+5:
|
|
|
5affbb |
+ .p2align 3
|
|
|
5affbb |
+ .long 1f - 0f /* name length */
|
|
|
5affbb |
+ .long 5f - 2f /* data length */
|
|
|
5affbb |
+ .long 5 /* note type */
|
|
|
5affbb |
+0: .asciz "GNU" /* vendor name */
|
|
|
5affbb |
+1:
|
|
|
5affbb |
+ .p2align 3
|
|
|
5affbb |
+2: .long 0xc0000000 /* pr_type. */
|
|
|
5affbb |
+ .long 4f - 3f /* pr_datasz. */
|
|
|
5affbb |
+3:
|
|
|
5affbb |
+ .long 0x1 /* BTI. */
|
|
|
5affbb |
+4:
|
|
|
5affbb |
+ .p2align 3
|
|
|
5affbb |
+5:
|
|
|
5affbb |
--- /dev/null 2020-11-04 08:04:13.849482156 +0000
|
|
|
5affbb |
+++ binutils-2.30/ld/testsuite/ld-aarch64/property-bti-pac2.s 2020-11-04 14:56:42.278422479 +0000
|
|
|
5affbb |
@@ -0,0 +1,50 @@
|
|
|
5affbb |
+ .text
|
|
|
5affbb |
+ .global foo
|
|
|
5affbb |
+ .type foo, %function
|
|
|
5affbb |
+foo:
|
|
|
5affbb |
+ sub sp, sp, #16
|
|
|
5affbb |
+ mov w0, 9
|
|
|
5affbb |
+ str w0, [sp, 12]
|
|
|
5affbb |
+ ldr w0, [sp, 12]
|
|
|
5affbb |
+ add w0, w0, 4
|
|
|
5affbb |
+ str w0, [sp, 12]
|
|
|
5affbb |
+ nop
|
|
|
5affbb |
+ add sp, sp, 16
|
|
|
5affbb |
+ ret
|
|
|
5affbb |
+ .size foo, .-foo
|
|
|
5affbb |
+ .global bar
|
|
|
5affbb |
+ .type bar, %function
|
|
|
5affbb |
+.ifdef __property_bti__
|
|
|
5affbb |
+ .section ".note.gnu.property", "a"
|
|
|
5affbb |
+ .p2align 3
|
|
|
5affbb |
+ .long 1f - 0f /* name length */
|
|
|
5affbb |
+ .long 5f - 2f /* data length */
|
|
|
5affbb |
+ .long 5 /* note type */
|
|
|
5affbb |
+0: .asciz "GNU" /* vendor name */
|
|
|
5affbb |
+1:
|
|
|
5affbb |
+ .p2align 3
|
|
|
5affbb |
+2: .long 0xc0000000 /* pr_type. */
|
|
|
5affbb |
+ .long 4f - 3f /* pr_datasz. */
|
|
|
5affbb |
+3:
|
|
|
5affbb |
+ .long 0x1 /* BTI. */
|
|
|
5affbb |
+4:
|
|
|
5affbb |
+ .p2align 3
|
|
|
5affbb |
+5:
|
|
|
5affbb |
+.endif
|
|
|
5affbb |
+.ifdef __property_pac__
|
|
|
5affbb |
+ .section ".note.gnu.property", "a"
|
|
|
5affbb |
+ .p2align 3
|
|
|
5affbb |
+ .long 1f - 0f /* name length */
|
|
|
5affbb |
+ .long 5f - 2f /* data length */
|
|
|
5affbb |
+ .long 5 /* note type */
|
|
|
5affbb |
+0: .asciz "GNU" /* vendor name */
|
|
|
5affbb |
+1:
|
|
|
5affbb |
+ .p2align 3
|
|
|
5affbb |
+2: .long 0xc0000000 /* pr_type. */
|
|
|
5affbb |
+ .long 4f - 3f /* pr_datasz. */
|
|
|
5affbb |
+3:
|
|
|
5affbb |
+ .long 0x2 /* PAC. */
|
|
|
5affbb |
+4:
|
|
|
5affbb |
+ .p2align 3
|
|
|
5affbb |
+5:
|
|
|
5affbb |
+.endif
|
|
|
5affbb |
--- /dev/null 2020-11-04 08:04:13.849482156 +0000
|
|
|
5affbb |
+++ binutils-2.30/ld/testsuite/ld-aarch64/property-bti-pac2.d 2020-11-04 14:56:42.278422479 +0000
|
|
|
5affbb |
@@ -0,0 +1,12 @@
|
|
|
5affbb |
+#name: GNU Property (combine multiple with BTI)
|
|
|
5affbb |
+#source: property-bti-pac1.s
|
|
|
5affbb |
+#source: property-bti-pac2.s
|
|
|
5affbb |
+#as: -mabi=lp64 -defsym __property_bti__=1
|
|
|
5affbb |
+#ld: -e _start
|
|
|
5affbb |
+#readelf: -n
|
|
|
5affbb |
+#target: *linux*
|
|
|
5affbb |
+
|
|
|
5affbb |
+Displaying notes found in: .note.gnu.property
|
|
|
5affbb |
+ Owner Data size Description
|
|
|
5affbb |
+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
|
|
|
5affbb |
+ Properties: AArch64 feature: BTI
|
|
|
5affbb |
--- /dev/null 2020-11-04 08:04:13.849482156 +0000
|
|
|
5affbb |
+++ binutils-2.30/ld/testsuite/ld-aarch64/property-bti-pac3.d 2020-11-04 14:56:42.278422479 +0000
|
|
|
5affbb |
@@ -0,0 +1,12 @@
|
|
|
5affbb |
+#name: GNU Property (combine multiple with PAC)
|
|
|
5affbb |
+#source: property-bti-pac1.s
|
|
|
5affbb |
+#source: property-bti-pac2.s
|
|
|
5affbb |
+#as: -mabi=lp64 -defsym __property_pac__=1
|
|
|
5affbb |
+#ld: -e _start
|
|
|
5affbb |
+#readelf: -n
|
|
|
5affbb |
+#target: *linux*
|
|
|
5affbb |
+
|
|
|
5affbb |
+Displaying notes found in: .note.gnu.property
|
|
|
5affbb |
+ Owner Data size Description
|
|
|
5affbb |
+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
|
|
|
5affbb |
+ Properties: AArch64 feature: PAC
|
|
|
5affbb |
diff -rup binutils.orig/bfd/elfnn-aarch64.c binutils-2.30/bfd/elfnn-aarch64.c
|
|
|
5affbb |
--- binutils.orig/bfd/elfnn-aarch64.c 2020-11-25 11:53:26.648275978 +0000
|
|
|
5affbb |
+++ binutils-2.30/bfd/elfnn-aarch64.c 2020-11-25 12:21:39.276864970 +0000
|
|
|
5affbb |
@@ -9331,12 +9331,14 @@ elfNN_aarch64_link_setup_gnu_properties
|
|
|
5affbb |
for the effect of GNU properties of the output_bfd. */
|
|
|
5affbb |
static bfd_boolean
|
|
|
5affbb |
elfNN_aarch64_merge_gnu_properties (struct bfd_link_info *info,
|
|
|
5affbb |
- bfd *abfd,
|
|
|
5affbb |
- elf_property *aprop,
|
|
|
5affbb |
- elf_property *bprop)
|
|
|
5affbb |
+ bfd *abfd,
|
|
|
5affbb |
+ bfd *bbfd ATTRIBUTE_UNUSED,
|
|
|
5affbb |
+ elf_property *aprop,
|
|
|
5affbb |
+ elf_property *bprop)
|
|
|
5affbb |
{
|
|
|
5affbb |
uint32_t prop
|
|
|
5affbb |
= elf_aarch64_tdata (info->output_bfd)->gnu_and_prop;
|
|
|
5affbb |
+
|
|
|
5affbb |
return _bfd_aarch64_elf_merge_gnu_properties (info, abfd, aprop,
|
|
|
5affbb |
bprop, prop);
|
|
|
5affbb |
}
|
|
|
5affbb |
diff -rup binutils.orig/bfd/elfxx-aarch64.c binutils-2.30/bfd/elfxx-aarch64.c
|
|
|
5affbb |
--- binutils.orig/bfd/elfxx-aarch64.c 2020-11-25 11:53:26.655275930 +0000
|
|
|
5affbb |
+++ binutils-2.30/bfd/elfxx-aarch64.c 2020-11-25 12:21:34.689895875 +0000
|
|
|
5affbb |
@@ -22,6 +22,7 @@
|
|
|
5affbb |
#include "elfxx-aarch64.h"
|
|
|
5affbb |
#include <stdarg.h>
|
|
|
5affbb |
#include <string.h>
|
|
|
5affbb |
+#include "libbfd.h"
|
|
|
5affbb |
|
|
|
5affbb |
#define MASK(n) ((1u << (n)) - 1)
|
|
|
5affbb |
|
|
|
5affbb |
@@ -835,7 +836,10 @@ _bfd_aarch64_elf_merge_gnu_properties (s
|
|
|
5affbb |
break;
|
|
|
5affbb |
|
|
|
5affbb |
default:
|
|
|
5affbb |
- abort ();
|
|
|
5affbb |
+ _bfd_error_handler
|
|
|
5affbb |
+ ( _("error: %pB: <corrupt AArch64 property note: 0x%x>"),
|
|
|
5affbb |
+ abfd, pr_type);
|
|
|
5affbb |
+ return FALSE;
|
|
|
5affbb |
}
|
|
|
5affbb |
|
|
|
5affbb |
return updated;
|
|
|
5affbb |
diff -rup binutils.orig/ld/testsuite/ld-aarch64/property-bti-pac1.d binutils-2.30/ld/testsuite/ld-aarch64/property-bti-pac1.d
|
|
|
5affbb |
--- binutils.orig/ld/testsuite/ld-aarch64/property-bti-pac1.d 2020-11-25 11:53:26.344278044 +0000
|
|
|
5affbb |
+++ binutils-2.30/ld/testsuite/ld-aarch64/property-bti-pac1.d 2020-11-25 11:57:53.179471900 +0000
|
|
|
5affbb |
@@ -1,6 +1,6 @@
|
|
|
5affbb |
#name: GNU Property (single input, combine section)
|
|
|
5affbb |
#source: property-bti-pac1.s
|
|
|
5affbb |
-#as: -march=armv8.5-a -defsym __mult__=0
|
|
|
5affbb |
+#as: -defsym __mult__=0
|
|
|
5affbb |
#ld: -shared
|
|
|
5affbb |
#readelf: -n
|
|
|
5affbb |
#target: *linux*
|