]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
aarch64: use only one type for feature marking report
authorMatthieu Longo <matthieu.longo@arm.com>
Thu, 28 Nov 2024 11:13:23 +0000 (11:13 +0000)
committerMatthieu Longo <matthieu.longo@arm.com>
Mon, 2 Dec 2024 15:18:40 +0000 (15:18 +0000)
bfd/elfnn-aarch64.c
bfd/elfxx-aarch64.c
bfd/elfxx-aarch64.h
ld/emultempl/aarch64elf.em

index 8500a50160f17f69994dea1399dfa27a51f1cd53..0350325fd83f569ed1733e5eb626f983d279815b 100644 (file)
@@ -10644,12 +10644,12 @@ elfNN_aarch64_merge_gnu_properties (struct bfd_link_info *info,
     {
       const aarch64_protection_opts *sw_protections
        = &elf_aarch64_tdata (info->output_bfd)->sw_protections;
-      aarch64_bti_report bti_report = sw_protections->bti_report;
+      aarch64_feature_marking_report bti_report = sw_protections->bti_report;
 
       /* If output has been marked with BTI using command line argument, give
         out warning if necessary.  */
       if ((prop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)
-         && (bti_report != BTI_NONE))
+         && (bti_report != MARKING_NONE))
        {
          if ((aprop && !(aprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI))
              || !aprop)
index b4dd523203af455381353d732c320ac8ea521833..1993a97ff028b7c961a645c23705c48c1f141b40 100644 (file)
@@ -926,15 +926,18 @@ _bfd_aarch64_elf_link_fixup_gnu_properties
 
 /* Check AArch64 BTI report.  */
 void
-_bfd_aarch64_elf_check_bti_report (aarch64_bti_report bti_report, bfd *ebfd)
+_bfd_aarch64_elf_check_bti_report (aarch64_feature_marking_report bti_report,
+                                  bfd *ebfd)
 {
-  if (bti_report == BTI_NONE)
+  if (bti_report == MARKING_NONE)
     return;
 
-  const char *log_level = (bti_report == BTI_WARN ? "warning" : "error");
+  const char *msg
+    = (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.");
 
-  const char *msg = _("%pB: %s: BTI turned on by -z force-bti on the output "
-                   "when all inputs do not have BTI in NOTE section.");
-
-  _bfd_error_handler (msg, ebfd, log_level);
+  _bfd_error_handler (msg, ebfd);
 }
\ No newline at end of file
index 298edd4e6ed77499706816200eebd09d777cd679..43db992d8d180a5aca7d94f3508854bec639186f 100644 (file)
@@ -39,16 +39,19 @@ typedef enum
   PLT_BTI_PAC  = PLT_BTI | PLT_PAC
 } aarch64_plt_type;
 
-/* Indicates whether the linker should generate warnings/errors when input
-   objects are missing BTI markings and the output has BTI markings.  */
+/* Indicates whether the linker should generate warnings, errors, or nothing
+   when input objects are missing GNU feature property markings and the output
+   has the markings.  */
 typedef enum
 {
-  BTI_NONE     = 0,  /* Does not emit any warning/error messages.  */
-  BTI_WARN     = 1,  /* Emit warning when the input objects are missing BTI
-                        markings and output have BTI marking.  */
-  BTI_ERROR    = 2,  /* Emit error when the input objects are missing BTI
-                        markings and output have BTI marking.  */
-} aarch64_bti_report;
+  MARKING_NONE = 0,  /* Does not emit any warning/error messages.  */
+  MARKING_WARN = 1,  /* Emit warning when the input objects are missing GNU
+                        feature property markings, and the output has the
+                        markings.  */
+  MARKING_ERROR        = 2,  /* Emit error when the input objects are missing GNU
+                        feature property markings, and the output has the
+                        markings.  */
+} aarch64_feature_marking_report;
 
 /* A structure to encompass all information about software protections coming
    from BTI or PAC related command line options.  */
@@ -58,7 +61,7 @@ struct aarch64_protection_opts
   aarch64_plt_type plt_type;
 
   /* Report level for BTI issues.  */
-  aarch64_bti_report bti_report;
+  aarch64_feature_marking_report bti_report;
 };
 typedef struct aarch64_protection_opts aarch64_protection_opts;
 
@@ -165,7 +168,7 @@ _bfd_aarch64_elf_merge_gnu_properties (struct bfd_link_info *, bfd *,
                                       uint32_t);
 
 extern void
-_bfd_aarch64_elf_check_bti_report (aarch64_bti_report, bfd *);
+_bfd_aarch64_elf_check_bti_report (aarch64_feature_marking_report, bfd *);
 
 extern void
 _bfd_aarch64_elf_link_fixup_gnu_properties (struct bfd_link_info *,
index 33b239b957aa7b5aecba55face7ce7da67646982..726f3567cd74d138105aa9f0ccd50a694467e74a 100644 (file)
@@ -36,7 +36,7 @@ static erratum_84319_opts fix_erratum_843419 = ERRAT_NONE;
 static int no_apply_dynamic_relocs = 0;
 static aarch64_protection_opts sw_protections = {
   .plt_type = PLT_NORMAL,
-  .bti_report = BTI_WARN,
+  .bti_report = MARKING_WARN,
 };
 
 #define COMPILE_TIME_STRLEN(s) \
@@ -362,11 +362,11 @@ aarch64_parse_bti_report_option (const char *optarg)
 
   if (strlen (optarg) == BTI_REPORT_LEN
       || strcmp (optarg + BTI_REPORT_LEN, "=warning") == 0)
-    sw_protections.bti_report = BTI_WARN;
+    sw_protections.bti_report = MARKING_WARN;
   else if (strcmp (optarg + BTI_REPORT_LEN, "=none") == 0)
-    sw_protections.bti_report = BTI_NONE;
+    sw_protections.bti_report = MARKING_NONE;
   else if (strcmp (optarg + BTI_REPORT_LEN, "=error") == 0)
-    sw_protections.bti_report = BTI_ERROR;
+    sw_protections.bti_report = MARKING_ERROR;
   else
     einfo (_("%X%P: error: unrecognized value '-z %s'\n"), optarg);