From: Matthieu Longo Date: Thu, 14 Nov 2024 17:34:04 +0000 (+0000) Subject: aarch64: refactoring _bfd_aarch64_elf_link_setup_gnu_properties (part 5) X-Git-Tag: gdb-16-branchpoint~231 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=827a2b93fe9551dbe788d838e6c6562bfe98920a;p=thirdparty%2Fbinutils-gdb.git 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. --- diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c index 9a27988b1c4..406b2fac0d3 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;