]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
aarch64: refactoring _bfd_aarch64_elf_check_bti_report
authorMatthieu Longo <matthieu.longo@arm.com>
Thu, 28 Nov 2024 23:21:05 +0000 (23:21 +0000)
committerMatthieu Longo <matthieu.longo@arm.com>
Mon, 2 Dec 2024 15:18:40 +0000 (15:18 +0000)
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.

bfd/elfnn-aarch64.c
bfd/elfxx-aarch64.c
bfd/elfxx-aarch64.h

index 482ce6aac24ad4448f83d6d8b39e4f0e8f0c6e28..374b17a9eaa9d60e19faa9532e882fc829ee01e7 100644 (file)
@@ -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);
        }
     }
 
index 5d2c9e9d30c471e034b9b0b8352db5730e693f0a..df62ec12e85ba2e1d5e985357eb5e63d70c25a7b 100644 (file)
@@ -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
index 8302654eeffd2ea37babc59d008882556102fae4..f08b092c4deea9704af6e54ade178824297a37c7 100644 (file)
@@ -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 *,