+2019-03-21 Sudakshina Das <sudi.das@arm.com>
+
+ * elf-bfd.h (struct elf_backend_data): Add argument to
+ merge_gnu_properties.
+ * elf-properties.c (elf_merge_gnu_properties): Add argument to
+ itself and while calling bed->merge_gnu_properties.
+ (elf_merge_gnu_property_list): Update the calls for
+ elf_merge_gnu_properties.
+ * elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update handling
+ of --force-bti warning and add argument.
+ * elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Add
+ warning.
+ * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Add argument.
+ * elfxx-x86.h (_bfd_x86_elf_merge_gnu_properties): Likewise in
+ declaration.
+
2019-03-20 Sudakshina Das <sudi.das@arm.com>
* elfxx-aarch64.c (_bfd_aarch64_elf_link_fixup_gnu_properties): Define.
unsigned int);
/* Merge GNU properties. Return TRUE if property is updated. */
- bfd_boolean (*merge_gnu_properties) (struct bfd_link_info *, bfd *,
+ bfd_boolean (*merge_gnu_properties) (struct bfd_link_info *, bfd *, bfd *,
elf_property *, elf_property *);
/* Set up GNU properties. */
with ABFD. */
static bfd_boolean
-elf_merge_gnu_properties (struct bfd_link_info *info, bfd *abfd,
+elf_merge_gnu_properties (struct bfd_link_info *info, bfd *abfd, bfd *bbfd,
elf_property *aprop, elf_property *bprop)
{
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
if (bed->merge_gnu_properties != NULL
&& pr_type >= GNU_PROPERTY_LOPROC
&& pr_type < GNU_PROPERTY_LOUSER)
- return bed->merge_gnu_properties (info, abfd, aprop, bprop);
+ return bed->merge_gnu_properties (info, abfd, bbfd, aprop, bprop);
switch (pr_type)
{
TRUE);
/* Pass NULL to elf_merge_gnu_properties for the property which
isn't on *LISTP. */
- elf_merge_gnu_properties (info, first_pbfd, &p->property, pr);
+ elf_merge_gnu_properties (info, first_pbfd, abfd, &p->property, pr);
if (p->property.pr_kind == property_remove)
{
if (info->has_map_file)
else
number_p = FALSE;
- if (elf_merge_gnu_properties (info, first_pbfd, NULL, &p->property))
+ if (elf_merge_gnu_properties (info, first_pbfd, abfd, NULL, &p->property))
{
if (p->property.pr_type == GNU_PROPERTY_NO_COPY_ON_PROTECTED)
elf_has_no_copy_on_protected (first_pbfd) = TRUE;
for the effect of GNU properties of the output_bfd. */
static bfd_boolean
elfNN_aarch64_merge_gnu_properties (struct bfd_link_info *info,
- bfd *abfd,
+ bfd *abfd, bfd *bbfd,
elf_property *aprop,
elf_property *bprop)
{
/* If output has been marked with BTI using command line argument, give out
warning if necessary. */
- if ((prop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)
+ /* Properties are merged per type, hence only check for warnings when merging
+ GNU_PROPERTY_AARCH64_FEATURE_1_AND. */
+ if (((aprop && aprop->pr_type == GNU_PROPERTY_AARCH64_FEATURE_1_AND)
+ || (bprop && bprop->pr_type == GNU_PROPERTY_AARCH64_FEATURE_1_AND))
+ && (prop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)
&& (!elf_aarch64_tdata (info->output_bfd)->no_bti_warn))
{
if ((aprop && !(aprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI))
- || (bprop && !(bprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI))
- /* If either property is NULL, it means its bfd did not have any
- property. */
- || !aprop || !bprop)
+ || !aprop)
{
- _bfd_error_handler (_("warning: BTI turned on by --force-bti when "
- "all inputs do not have BTI in NOTE section."));
+ _bfd_error_handler (_("%pB: warning: BTI turned on by --force-bti when "
+ "all inputs do not have BTI in NOTE section."),
+ abfd);
+ }
+ if ((bprop && !(bprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI))
+ || !bprop)
+ {
+ _bfd_error_handler (_("%pB: warning: BTI turned on by --force-bti when "
+ "all inputs do not have BTI in NOTE section."),
+ bbfd);
}
}
prop = _bfd_elf_get_property (ebfd,
GNU_PROPERTY_AARCH64_FEATURE_1_AND,
4);
+ if (gnu_prop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI
+ && !(prop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI))
+ _bfd_error_handler (_("%pB: warning: BTI turned on by --force-bti "
+ "when all inputs do not have BTI in NOTE "
+ "section."), ebfd);
prop->u.number |= gnu_prop;
prop->pr_kind = property_number;
bfd_boolean
_bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info,
bfd *abfd ATTRIBUTE_UNUSED,
+ bfd *bbfd ATTRIBUTE_UNUSED,
elf_property *aprop,
elf_property *bprop)
{
(bfd *, unsigned int, bfd_byte *, unsigned int);
extern bfd_boolean _bfd_x86_elf_merge_gnu_properties
- (struct bfd_link_info *, bfd *, elf_property *, elf_property *);
+ (struct bfd_link_info *, bfd *, bfd *, elf_property *, elf_property *);
extern void _bfd_x86_elf_link_fixup_gnu_properties
(struct bfd_link_info *, elf_property_list **);
+2019-03-21 Sudakshina Das <sudi.das@arm.com>
+
+ * testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
+ * testsuite/ld-aarch64/bti-plt-1.s: Add .ifdef for PAC note section.
+ * testsuite/ld-aarch64/bti-plt-6.d: Update warning.
+ * testsuite/ld-aarch64/bti-plt-7.d: Likewise.
+ * testsuite/ld-aarch64/bti-warn.d: New test.
+
2019-03-21 Alan Modra <amodra@gmail.com>
* testsuite/ld-elf/fini2.s: Reduce alignment.
run_dump_test "pac-plt-2"
run_dump_test "bti-pac-plt-1"
run_dump_test "bti-pac-plt-2"
+
+run_dump_test "bti-warn"
.p2align 3
5:
.endif
+.ifdef __property_pac__
+ .section ".note.gnu.property", "a"
+ .p2align 3
+ .long 1f - 0f /* name length */
+ .long 5f - 2f /* data length */
+ .long 5 /* note type */
+0: .asciz "GNU" /* vendor name */
+1:
+ .p2align 3
+2: .long 0xc0000000 /* pr_type. */
+ .long 4f - 3f /* pr_datasz. */
+3:
+ .long 0x2 /* PAC. */
+4:
+ .p2align 3
+5:
+.endif
#name: Warn with one missing GNU NOTE BTI input
-#source: property-bti-pac1.s
#source: property-bti-pac2.s
+#source: property-bti-pac1.s
#as: -mabi=lp64 -defsym __property_pac__=1
#ld: -shared --force-bti
-#warning: .*: warning: BTI turned on by --force-bti.*$
+#warning: .*property-bti-pac2.*: warning: BTI turned on by --force-bti.*$
#readelf: -n
# Should warn about the missing input BTI NOTE but should
#name: Warn when neither inputs has GNU NOTE BTI
-#source: property-bti-pac1.s
+#source: property-bti-pac2.s
#source: plt_mapping_symbol.s
#as: -mabi=lp64
#ld: -shared --force-bti
-#warning: .*: warning: BTI turned on by --force-bti.*$
+#warning: .*plt_mapping_symbol.*: warning: BTI turned on by --force-bti.*
+#warning: .*property-bti-pac2.*: warning: BTI turned on by --force-bti.*
#readelf: -n
# Should warn about the missing input BTI NOTE but should
--- /dev/null
+#name: Warn when both have GNU prop but neither BTI
+#source: property-bti-pac2.s
+#source: bti-plt-1.s
+#as: -mabi=lp64 --defsym __guard_property_bti__=1 --defsym __property_pac__=1
+#ld: -shared --force-bti
+#warning: .*property-bti-pac2.*: warning: BTI turned on by --force-bti.*
+#warning: .*bti-plt-1.*: warning: BTI turned on by --force-bti.*
+#readelf: -n
+
+# Should warn about the missing input BTI NOTE but should
+# still mark output as BTI
+
+Displaying notes found in: .note.gnu.property
+ Owner Data size Description
+ GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
+ Properties: AArch64 feature: BTI, PAC