[binutils-gdb] aarch64: refactoring _bfd_aarch64_elf_link_setup_gnu_properties (part 2)

Matthieu Longo mlongo@sourceware.org
Mon Dec 2 15:22:03 GMT 2024


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

commit 518976f1350e41bce6abe0c5c397aa854601420d
Author: Matthieu Longo <matthieu.longo@arm.com>
Date:   Thu Nov 14 16:51:46 2024 +0000

    aarch64: refactoring _bfd_aarch64_elf_link_setup_gnu_properties (part 2)
    
    Simplify this for-loop with too many "break" instructions inside.

Diff:
---
 bfd/elfxx-aarch64.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c
index df62ec12e85..bc823f79c60 100644
--- a/bfd/elfxx-aarch64.c
+++ b/bfd/elfxx-aarch64.c
@@ -775,21 +775,22 @@ _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info)
      outprop accordingly.  */
   if (pbfd != NULL)
     {
-      elf_property_list *p;
-
       /* The property list is sorted in order of type.  */
-      for (p = elf_properties (pbfd); p; p = p->next)
+      for (elf_property_list *p = elf_properties (pbfd);
+	   (p != NULL)
+	     && (GNU_PROPERTY_AARCH64_FEATURE_1_AND <= p->property.pr_type);
+	   p = p->next)
 	{
-	  /* Check for all GNU_PROPERTY_AARCH64_FEATURE_1_AND.  */
-	  if (GNU_PROPERTY_AARCH64_FEATURE_1_AND == p->property.pr_type)
+	  /* This merge of features should happen only once as all the identical
+	     properties are supposed to have been merged at this stage by
+	     _bfd_elf_link_setup_gnu_properties().  */
+	  if (p->property.pr_type == GNU_PROPERTY_AARCH64_FEATURE_1_AND)
 	    {
 	      outprop = (p->property.u.number
-			  & (GNU_PROPERTY_AARCH64_FEATURE_1_PAC
-			      | GNU_PROPERTY_AARCH64_FEATURE_1_BTI));
+			 & (GNU_PROPERTY_AARCH64_FEATURE_1_BTI
+			  | GNU_PROPERTY_AARCH64_FEATURE_1_PAC));
 	      break;
 	    }
-	  else if (GNU_PROPERTY_AARCH64_FEATURE_1_AND < p->property.pr_type)
-	    break;
 	}
     }


More information about the Binutils-cvs mailing list