diff options
author | Matthieu Longo <matthieu.longo@arm.com> | 2024-11-28 23:21:05 +0000 |
---|---|---|
committer | Matthieu Longo <matthieu.longo@arm.com> | 2024-12-02 15:18:40 +0000 |
commit | d364a2ddb4bfe3680f03dd24b724a867e35ee372 (patch) | |
tree | c1e89be5316fb250a2ac36738ae0d22108e047b8 | |
parent | 946b753836b65ef5785e488e6b1527bb78d62694 (diff) | |
download | binutils-d364a2ddb4bfe3680f03dd24b724a867e35ee372.zip binutils-d364a2ddb4bfe3680f03dd24b724a867e35ee372.tar.gz binutils-d364a2ddb4bfe3680f03dd24b724a867e35ee372.tar.bz2 |
aarch64: refactoring _bfd_aarch64_elf_check_bti_report
Before this patch, warnings were reported normally, and errors
(introduced by a previous patch adding '-z bti-report' option)
were logged as error but were not provoking a link failure.
The root of the issue was a misuse of _bfd_error_handler to
report the errors.
Replacing _bfd_error_handler by info->callbacks->einfo, with the
addition of the formatter '%X' for errors fixed the issue.
-rw-r--r-- | bfd/elfnn-aarch64.c | 4 | ||||
-rw-r--r-- | bfd/elfxx-aarch64.c | 17 | ||||
-rw-r--r-- | bfd/elfxx-aarch64.h | 2 |
3 files changed, 12 insertions, 11 deletions
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 482ce6a..374b17a 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -10636,9 +10636,9 @@ elfNN_aarch64_merge_gnu_properties (struct bfd_link_info *info, && (bti_report != MARKING_NONE)) { if (!aprop || !(aprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) - _bfd_aarch64_elf_check_bti_report (bti_report, abfd); + _bfd_aarch64_elf_check_bti_report (info, abfd); if (!bprop || !(bprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) - _bfd_aarch64_elf_check_bti_report (bti_report, bbfd); + _bfd_aarch64_elf_check_bti_report (info, bbfd); } } diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c index 5d2c9e9..df62ec1 100644 --- a/bfd/elfxx-aarch64.c +++ b/bfd/elfxx-aarch64.c @@ -927,18 +927,19 @@ _bfd_aarch64_elf_link_fixup_gnu_properties /* Check AArch64 BTI report. */ void -_bfd_aarch64_elf_check_bti_report (aarch64_feature_marking_report bti_report, - bfd *ebfd) +_bfd_aarch64_elf_check_bti_report (struct bfd_link_info *info, bfd *ebfd) { - if (bti_report == MARKING_NONE) + struct elf_aarch64_obj_tdata *tdata = elf_aarch64_tdata (info->output_bfd); + + if (tdata->sw_protections.bti_report == MARKING_NONE) return; const char *msg - = (bti_report == MARKING_WARN) + = (tdata->sw_protections.bti_report == MARKING_WARN) ? _("%pB: warning: BTI turned on by -z force-bti on the output when all " - "inputs do not have BTI in NOTE section.") - : _("%pB: error: BTI turned on by -z force-bti on the output when all " - "inputs do not have BTI in NOTE section."); + "inputs do not have BTI in NOTE section.\n") + : _("%X%pB: error: BTI turned on by -z force-bti on the output when all " + "inputs do not have BTI in NOTE section.\n"); - _bfd_error_handler (msg, ebfd); + info->callbacks->einfo (msg, ebfd); }
\ No newline at end of file diff --git a/bfd/elfxx-aarch64.h b/bfd/elfxx-aarch64.h index 8302654..f08b092 100644 --- a/bfd/elfxx-aarch64.h +++ b/bfd/elfxx-aarch64.h @@ -191,7 +191,7 @@ _bfd_aarch64_elf_merge_gnu_properties (struct bfd_link_info *, bfd *, uint32_t); extern void -_bfd_aarch64_elf_check_bti_report (aarch64_feature_marking_report, bfd *); +_bfd_aarch64_elf_check_bti_report (struct bfd_link_info *, bfd *); extern void _bfd_aarch64_elf_link_fixup_gnu_properties (struct bfd_link_info *, |