[binutils-gdb] aarch64: use only one type for feature marking report

Matthieu Longo mlongo@sourceware.org
Mon Dec 2 15:21:26 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=caded0cf73cb914e5d2d61f4696af154c2ba4360

commit caded0cf73cb914e5d2d61f4696af154c2ba4360
Author: Matthieu Longo <matthieu.longo@arm.com>
Date:   Thu Nov 28 11:13:23 2024 +0000

    aarch64: use only one type for feature marking report

Diff:
---
 bfd/elfnn-aarch64.c        |  4 ++--
 bfd/elfxx-aarch64.c        | 17 ++++++++++-------
 bfd/elfxx-aarch64.h        | 23 +++++++++++++----------
 ld/emultempl/aarch64elf.em |  8 ++++----
 4 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 8500a50160f..0350325fd83 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -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)
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c
index b4dd523203a..1993a97ff02 100644
--- a/bfd/elfxx-aarch64.c
+++ b/bfd/elfxx-aarch64.c
@@ -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
diff --git a/bfd/elfxx-aarch64.h b/bfd/elfxx-aarch64.h
index 298edd4e6ed..43db992d8d1 100644
--- a/bfd/elfxx-aarch64.h
+++ b/bfd/elfxx-aarch64.h
@@ -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 *,
diff --git a/ld/emultempl/aarch64elf.em b/ld/emultempl/aarch64elf.em
index 33b239b957a..726f3567cd7 100644
--- a/ld/emultempl/aarch64elf.em
+++ b/ld/emultempl/aarch64elf.em
@@ -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);


More information about the Binutils-cvs mailing list