diff options
author | Matthieu Longo <matthieu.longo@arm.com> | 2024-11-14 17:34:04 +0000 |
---|---|---|
committer | Matthieu Longo <matthieu.longo@arm.com> | 2024-12-02 15:18:40 +0000 |
commit | 827a2b93fe9551dbe788d838e6c6562bfe98920a (patch) | |
tree | 70cede17e0ed404697783da761d4868453faf0d1 | |
parent | d350b1501777553d6742bc5eb2982efc5103b84d (diff) | |
download | binutils-827a2b93fe9551dbe788d838e6c6562bfe98920a.zip binutils-827a2b93fe9551dbe788d838e6c6562bfe98920a.tar.gz binutils-827a2b93fe9551dbe788d838e6c6562bfe98920a.tar.bz2 |
aarch64: refactoring _bfd_aarch64_elf_link_setup_gnu_properties (part 5)
Use _bfd_aarch64_elf_check_bti_report to report any BTI issue on the
first input object.
-rw-r--r-- | bfd/elfxx-aarch64.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c index 9a27988..406b2fa 100644 --- a/bfd/elfxx-aarch64.c +++ b/bfd/elfxx-aarch64.c @@ -756,9 +756,6 @@ _bfd_aarch64_elf_create_gnu_property_section (struct bfd_link_info *info, bfd * _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info) { - bfd *pbfd; - elf_property *prop; - struct elf_aarch64_obj_tdata *tdata = elf_aarch64_tdata (info->output_bfd); uint32_t outprop = tdata->gnu_property_aarch64_feature_1_and; @@ -767,29 +764,38 @@ _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info) _bfd_aarch64_elf_find_1st_bfd_input_with_gnu_property (info, &has_gnu_property); - /* If ebfd != NULL it is either an input with property note or the last - input. Either way if we have gnu_prop, we should add it (by creating - a section if needed). */ + /* If ebfd != NULL it is either an input with property note or the last input. + Either way if we have an output GNU property that was provided, we should + add it (by creating a section if needed). */ if (ebfd != NULL && outprop) { - prop = _bfd_elf_get_property (ebfd, - GNU_PROPERTY_AARCH64_FEATURE_1_AND, - 4); - if (outprop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI - && !(prop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) - _bfd_error_handler (_("%pB: warning: BTI turned on by -z force-bti " - "when all inputs do not have BTI in NOTE " - "section."), ebfd); - prop->u.number |= outprop; - prop->pr_kind = property_number; - /* If no GNU property node was found, create the GNU property note section. */ if (!has_gnu_property) _bfd_aarch64_elf_create_gnu_property_section (info, ebfd); + + /* Merge the found input property with output properties. Note: if no + property was found, _bfd_elf_get_property will create one. */ + elf_property *prop = + _bfd_elf_get_property (ebfd, + GNU_PROPERTY_AARCH64_FEATURE_1_AND, + 4); + + /* Check for a feature mismatch and report issue (if any) before this + information get lost as the value of ebfd will be overriden with + outprop. */ + if ((outprop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) + && !(prop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) + _bfd_aarch64_elf_check_bti_report (info, ebfd); + + prop->u.number |= outprop; + prop->pr_kind = property_number; } - pbfd = _bfd_elf_link_setup_gnu_properties (info); + /* Set up generic GNU properties, and merge them with the backend-specific + ones (if any). pbfd points to the first relocatable ELF input with + GNU properties (if found). */ + bfd *pbfd = _bfd_elf_link_setup_gnu_properties (info); if (bfd_link_relocatable (info)) return pbfd; |