diff options
author | Sudakshina Das <sudi.das@arm.com> | 2019-03-21 16:20:21 +0000 |
---|---|---|
committer | Sudakshina Das <sudi.das@arm.com> | 2019-03-21 16:20:21 +0000 |
commit | 4e5391148d51c58785aad637f1a92d47b91b3ae6 (patch) | |
tree | 39854d98236b1aa76c3ecc067dd66c430804e4da /bfd | |
parent | f84bd4655c17b3ee59b73bd33ec91f75bd58546c (diff) | |
download | gdb-4e5391148d51c58785aad637f1a92d47b91b3ae6.zip gdb-4e5391148d51c58785aad637f1a92d47b91b3ae6.tar.gz gdb-4e5391148d51c58785aad637f1a92d47b91b3ae6.tar.bz2 |
[BFD, AArch64, x86] Improve warning for --force-bti
The AArch64 linker option to turn on BTI (--force-bti) warns in case there are
input objects which have a missing GNU NOTE section for BTI. This patch is trying
to improve the warnings that come out.
In order to do so, I propose adding a new argument to elf_merge_gnu_properties
and the backend function merge_gnu_properties. This new argument makes sure
that we now pass both the objects along with the properties to which they
belong to. The x86 backend function has also been updated to match this
change.
*** bfd/ChangeLog ***
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.
*** ld/ChangeLog ***
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.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 16 | ||||
-rw-r--r-- | bfd/elf-bfd.h | 2 | ||||
-rw-r--r-- | bfd/elf-properties.c | 8 | ||||
-rw-r--r-- | bfd/elfnn-aarch64.c | 25 | ||||
-rw-r--r-- | bfd/elfxx-aarch64.c | 5 | ||||
-rw-r--r-- | bfd/elfxx-x86.c | 1 | ||||
-rw-r--r-- | bfd/elfxx-x86.h | 2 |
7 files changed, 45 insertions, 14 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index d0daa37..31ffadf 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,19 @@ +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. diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 56cddda..0d12f45 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -1473,7 +1473,7 @@ struct elf_backend_data 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. */ diff --git a/bfd/elf-properties.c b/bfd/elf-properties.c index 0c3f19c..94ef235 100644 --- a/bfd/elf-properties.c +++ b/bfd/elf-properties.c @@ -198,7 +198,7 @@ next: 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); @@ -207,7 +207,7 @@ elf_merge_gnu_properties (struct bfd_link_info *info, bfd *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) { @@ -289,7 +289,7 @@ elf_merge_gnu_property_list (struct bfd_link_info *info, bfd *first_pbfd, 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) @@ -365,7 +365,7 @@ elf_merge_gnu_property_list (struct bfd_link_info *info, bfd *first_pbfd, 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; diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 50541f0..57a723d 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -9968,7 +9968,7 @@ elfNN_aarch64_link_setup_gnu_properties (struct bfd_link_info *info) 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) { @@ -9977,17 +9977,26 @@ elfNN_aarch64_merge_gnu_properties (struct bfd_link_info *info, /* 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); } } diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c index 0408140..d16f2ec 100644 --- a/bfd/elfxx-aarch64.c +++ b/bfd/elfxx-aarch64.c @@ -719,6 +719,11 @@ _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info, 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; diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index 584a75f..5703b5f 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -2401,6 +2401,7 @@ _bfd_x86_elf_parse_gnu_properties (bfd *abfd, unsigned int type, 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) { diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h index 28d540b..4df2173 100644 --- a/bfd/elfxx-x86.h +++ b/bfd/elfxx-x86.h @@ -691,7 +691,7 @@ extern enum elf_property_kind _bfd_x86_elf_parse_gnu_properties (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 **); |