This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] x86: Properly merge GNU_PROPERTY_X86_ISA_1_USED


Without the GNU_PROPERTY_X86_ISA_1_USED property, all ISAs may be used.
If a bit in the GNU_PROPERTY_X86_ISA_1_USED property is unset, the
corresponding x86 instruction set isn’t used.  When merging properties
from 2 input files and one input file doesn't have the
GNU_PROPERTY_X86_ISA_1_USED property, the output file shouldn't have
it neither.  This patch removes the GNU_PROPERTY_X86_ISA_1_USED
property if an input file doesn't have it.

This patch replaces the GNU_PROPERTY_X86_ISA_1_USED property with the
GNU_PROPERTY_X86_ISA_1_NEEDED property which is the minimum ISA
requirement.

bfd/

	PR ld/23486
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Remove
	GNU_PROPERTY_X86_ISA_1_USED if an input file doesn't have it.
	(_bfd_x86_elf_link_setup_gnu_properties): Adding the
	GNU_PROPERTY_X86_ISA_1_NEEDED, instead of
	GNU_PROPERTY_X86_ISA_1_USED, property.

ld/

	PR ld/23486
	* testsuite/ld-i386/property-3.r: Remove "x86 ISA used".
	* testsuite/ld-i386/property-4.r: Likewise.
	* testsuite/ld-i386/property-5.r: Likewise.
	* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-x86-64/property-3.r: Likewise.
	* testsuite/ld-x86-64/property-4.r: Likewise.
	* testsuite/ld-x86-64/property-5.r: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
---
 bfd/elfxx-x86.c                               | 25 +++++++++++++++----
 ld/testsuite/ld-i386/property-3.r             |  1 -
 ld/testsuite/ld-i386/property-4.r             |  1 -
 ld/testsuite/ld-i386/property-5.r             |  1 -
 ld/testsuite/ld-i386/property-x86-ibt3a.d     |  5 ++--
 ld/testsuite/ld-i386/property-x86-ibt3b.d     |  5 ++--
 ld/testsuite/ld-i386/property-x86-shstk3a.d   |  5 ++--
 ld/testsuite/ld-i386/property-x86-shstk3b.d   |  5 ++--
 ld/testsuite/ld-x86-64/property-3.r           |  1 -
 ld/testsuite/ld-x86-64/property-4.r           |  1 -
 ld/testsuite/ld-x86-64/property-5.r           |  1 -
 .../ld-x86-64/property-x86-ibt3a-x32.d        |  5 ++--
 ld/testsuite/ld-x86-64/property-x86-ibt3a.d   |  5 ++--
 .../ld-x86-64/property-x86-ibt3b-x32.d        |  5 ++--
 ld/testsuite/ld-x86-64/property-x86-ibt3b.d   |  5 ++--
 .../ld-x86-64/property-x86-shstk3a-x32.d      |  5 ++--
 ld/testsuite/ld-x86-64/property-x86-shstk3a.d |  5 ++--
 .../ld-x86-64/property-x86-shstk3b-x32.d      |  5 ++--
 ld/testsuite/ld-x86-64/property-x86-shstk3b.d |  5 ++--
 19 files changed, 44 insertions(+), 47 deletions(-)

diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index 2e4ff88f1f..7ccfd25815 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -2407,12 +2407,27 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info,
   switch (pr_type)
     {
     case GNU_PROPERTY_X86_ISA_1_USED:
+      if (aprop == NULL || bprop == NULL)
+	{
+	  /* Only one of APROP and BPROP can be NULL.  */
+	  if (aprop != NULL)
+	    {
+	      /* Remove this property since the other input file doesn't
+		 have it.  */
+	      aprop->pr_kind = property_remove;
+	      updated = TRUE;
+	    }
+	  break;
+	}
+      goto or_property;
+
     case GNU_PROPERTY_X86_ISA_1_NEEDED:
       if (aprop != NULL && bprop != NULL)
 	{
+or_property:
 	  number = aprop->u.number;
 	  aprop->u.number = number | bprop->u.number;
-	  /* Remove the property if ISA bits are empty.  */
+	  /* Remove the property if all bits are empty.  */
 	  if (aprop->u.number == 0)
 	    {
 	      aprop->pr_kind = property_remove;
@@ -2428,14 +2443,14 @@ _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info,
 	    {
 	      if (aprop->u.number == 0)
 		{
-		  /* Remove APROP if ISA bits are empty.  */
+		  /* Remove APROP if all bits are empty.  */
 		  aprop->pr_kind = property_remove;
 		  updated = TRUE;
 		}
 	    }
 	  else
 	    {
-	      /* Return TRUE if APROP is NULL and ISA bits of BPROP
+	      /* Return TRUE if APROP is NULL and all bits of BPROP
 		 aren't empty to indicate that BPROP should be added
 		 to ABFD.  */
 	      updated = bprop->u.number != 0;
@@ -2582,9 +2597,9 @@ _bfd_x86_elf_link_setup_gnu_properties
 	{
 	  /* If the separate code program header is needed, make sure
 	     that the first read-only PT_LOAD segment has no code by
-	     adding a GNU_PROPERTY_X86_ISA_1_USED note.  */
+	     adding a GNU_PROPERTY_X86_ISA_1_NEEDED note.  */
 	  prop = _bfd_elf_get_property (ebfd,
-					GNU_PROPERTY_X86_ISA_1_USED,
+					GNU_PROPERTY_X86_ISA_1_NEEDED,
 					4);
 	  prop->u.number = GNU_PROPERTY_X86_ISA_1_486;
 	  prop->pr_kind = property_number;
diff --git a/ld/testsuite/ld-i386/property-3.r b/ld/testsuite/ld-i386/property-3.r
index 0ed91f5922..d03203c1e5 100644
--- a/ld/testsuite/ld-i386/property-3.r
+++ b/ld/testsuite/ld-i386/property-3.r
@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
   GNU                  0x[0-9a-f]+	NT_GNU_PROPERTY_TYPE_0
       Properties: stack size: 0x800000
-	x86 ISA used: 586, SSE
 	x86 ISA needed: i486, 586
 #pass
diff --git a/ld/testsuite/ld-i386/property-4.r b/ld/testsuite/ld-i386/property-4.r
index cb2bc15d9a..da295eb6c7 100644
--- a/ld/testsuite/ld-i386/property-4.r
+++ b/ld/testsuite/ld-i386/property-4.r
@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
   GNU                  0x[0-9a-f]+	NT_GNU_PROPERTY_TYPE_0
       Properties: stack size: 0x800000
-	x86 ISA used: i486, 586, SSE
 	x86 ISA needed: i486, 586, SSE
 #pass
diff --git a/ld/testsuite/ld-i386/property-5.r b/ld/testsuite/ld-i386/property-5.r
index 552965058c..e4141594b3 100644
--- a/ld/testsuite/ld-i386/property-5.r
+++ b/ld/testsuite/ld-i386/property-5.r
@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
   GNU                  0x[0-9a-f]+	NT_GNU_PROPERTY_TYPE_0
       Properties: stack size: 0x900000
-	x86 ISA used: i486, 586, SSE
 	x86 ISA needed: i486, 586, SSE
 #pass
diff --git a/ld/testsuite/ld-i386/property-x86-ibt3a.d b/ld/testsuite/ld-i386/property-x86-ibt3a.d
index 4bb35b00fb..0aedea1614 100644
--- a/ld/testsuite/ld-i386/property-x86-ibt3a.d
+++ b/ld/testsuite/ld-i386/property-x86-ibt3a.d
@@ -6,6 +6,5 @@
 
 Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
-  GNU                  0x00000018	NT_GNU_PROPERTY_TYPE_0
-      Properties: x86 ISA used: i486, 586, SSE2, SSE3
-	x86 ISA needed: 586, SSE, SSE3, SSE4_1
+  GNU                  0x0000000c	NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1
diff --git a/ld/testsuite/ld-i386/property-x86-ibt3b.d b/ld/testsuite/ld-i386/property-x86-ibt3b.d
index 418d58a8f7..bd69ac6478 100644
--- a/ld/testsuite/ld-i386/property-x86-ibt3b.d
+++ b/ld/testsuite/ld-i386/property-x86-ibt3b.d
@@ -6,6 +6,5 @@
 
 Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
-  GNU                  0x00000018	NT_GNU_PROPERTY_TYPE_0
-      Properties: x86 ISA used: i486, 586, SSE2, SSE3
-	x86 ISA needed: 586, SSE, SSE3, SSE4_1
+  GNU                  0x0000000c	NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1
diff --git a/ld/testsuite/ld-i386/property-x86-shstk3a.d b/ld/testsuite/ld-i386/property-x86-shstk3a.d
index e261038f60..76d2a39f2c 100644
--- a/ld/testsuite/ld-i386/property-x86-shstk3a.d
+++ b/ld/testsuite/ld-i386/property-x86-shstk3a.d
@@ -6,6 +6,5 @@
 
 Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
-  GNU                  0x00000018	NT_GNU_PROPERTY_TYPE_0
-      Properties: x86 ISA used: i486, 586, SSE2, SSE3
-	x86 ISA needed: 586, SSE, SSE3, SSE4_1
+  GNU                  0x0000000c	NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1
diff --git a/ld/testsuite/ld-i386/property-x86-shstk3b.d b/ld/testsuite/ld-i386/property-x86-shstk3b.d
index 25f3d2361e..e770ecffa5 100644
--- a/ld/testsuite/ld-i386/property-x86-shstk3b.d
+++ b/ld/testsuite/ld-i386/property-x86-shstk3b.d
@@ -6,6 +6,5 @@
 
 Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
-  GNU                  0x00000018	NT_GNU_PROPERTY_TYPE_0
-      Properties: x86 ISA used: i486, 586, SSE2, SSE3
-	x86 ISA needed: 586, SSE, SSE3, SSE4_1
+  GNU                  0x0000000c	NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1
diff --git a/ld/testsuite/ld-x86-64/property-3.r b/ld/testsuite/ld-x86-64/property-3.r
index 0ed91f5922..d03203c1e5 100644
--- a/ld/testsuite/ld-x86-64/property-3.r
+++ b/ld/testsuite/ld-x86-64/property-3.r
@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
   GNU                  0x[0-9a-f]+	NT_GNU_PROPERTY_TYPE_0
       Properties: stack size: 0x800000
-	x86 ISA used: 586, SSE
 	x86 ISA needed: i486, 586
 #pass
diff --git a/ld/testsuite/ld-x86-64/property-4.r b/ld/testsuite/ld-x86-64/property-4.r
index cb2bc15d9a..da295eb6c7 100644
--- a/ld/testsuite/ld-x86-64/property-4.r
+++ b/ld/testsuite/ld-x86-64/property-4.r
@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
   GNU                  0x[0-9a-f]+	NT_GNU_PROPERTY_TYPE_0
       Properties: stack size: 0x800000
-	x86 ISA used: i486, 586, SSE
 	x86 ISA needed: i486, 586, SSE
 #pass
diff --git a/ld/testsuite/ld-x86-64/property-5.r b/ld/testsuite/ld-x86-64/property-5.r
index 552965058c..e4141594b3 100644
--- a/ld/testsuite/ld-x86-64/property-5.r
+++ b/ld/testsuite/ld-x86-64/property-5.r
@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
   GNU                  0x[0-9a-f]+	NT_GNU_PROPERTY_TYPE_0
       Properties: stack size: 0x900000
-	x86 ISA used: i486, 586, SSE
 	x86 ISA needed: i486, 586, SSE
 #pass
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d b/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d
index 011426f5a4..4cec728dc7 100644
--- a/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d
@@ -6,6 +6,5 @@
 
 Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
-  GNU                  0x00000018	NT_GNU_PROPERTY_TYPE_0
-      Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-	x86 ISA needed: i486, 586, SSE2, SSE3
+  GNU                  0x0000000c	NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA needed: i486, 586, SSE2, SSE3
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3a.d b/ld/testsuite/ld-x86-64/property-x86-ibt3a.d
index 1b4229a037..a8df49a351 100644
--- a/ld/testsuite/ld-x86-64/property-x86-ibt3a.d
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt3a.d
@@ -6,6 +6,5 @@
 
 Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
-  GNU                  0x00000020	NT_GNU_PROPERTY_TYPE_0
-      Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-	x86 ISA needed: i486, 586, SSE2, SSE3
+  GNU                  0x00000010	NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA needed: i486, 586, SSE2, SSE3
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d b/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d
index 290ed6abf1..c112626711 100644
--- a/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d
@@ -6,6 +6,5 @@
 
 Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
-  GNU                  0x00000018	NT_GNU_PROPERTY_TYPE_0
-      Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-	x86 ISA needed: i486, 586, SSE2, SSE3
+  GNU                  0x0000000c	NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA needed: i486, 586, SSE2, SSE3
diff --git a/ld/testsuite/ld-x86-64/property-x86-ibt3b.d b/ld/testsuite/ld-x86-64/property-x86-ibt3b.d
index 1142e03272..f10dffdc2c 100644
--- a/ld/testsuite/ld-x86-64/property-x86-ibt3b.d
+++ b/ld/testsuite/ld-x86-64/property-x86-ibt3b.d
@@ -6,6 +6,5 @@
 
 Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
-  GNU                  0x00000020	NT_GNU_PROPERTY_TYPE_0
-      Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-	x86 ISA needed: i486, 586, SSE2, SSE3
+  GNU                  0x00000010	NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA needed: i486, 586, SSE2, SSE3
diff --git a/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d b/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d
index 819542d181..0147a3c7b6 100644
--- a/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d
+++ b/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d
@@ -6,6 +6,5 @@
 
 Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
-  GNU                  0x00000018	NT_GNU_PROPERTY_TYPE_0
-      Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-	x86 ISA needed: i486, 586, SSE2, SSE3
+  GNU                  0x0000000c	NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA needed: i486, 586, SSE2, SSE3
diff --git a/ld/testsuite/ld-x86-64/property-x86-shstk3a.d b/ld/testsuite/ld-x86-64/property-x86-shstk3a.d
index 4c5d0e0a18..1f8c2dc929 100644
--- a/ld/testsuite/ld-x86-64/property-x86-shstk3a.d
+++ b/ld/testsuite/ld-x86-64/property-x86-shstk3a.d
@@ -6,6 +6,5 @@
 
 Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
-  GNU                  0x00000020	NT_GNU_PROPERTY_TYPE_0
-      Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-	x86 ISA needed: i486, 586, SSE2, SSE3
+  GNU                  0x00000010	NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA needed: i486, 586, SSE2, SSE3
diff --git a/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d b/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d
index ba181e0bc5..7ca2539ca5 100644
--- a/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d
+++ b/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d
@@ -6,6 +6,5 @@
 
 Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
-  GNU                  0x00000018	NT_GNU_PROPERTY_TYPE_0
-      Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-	x86 ISA needed: i486, 586, SSE2, SSE3
+  GNU                  0x0000000c	NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA needed: i486, 586, SSE2, SSE3
diff --git a/ld/testsuite/ld-x86-64/property-x86-shstk3b.d b/ld/testsuite/ld-x86-64/property-x86-shstk3b.d
index 5216f385dd..f66a40e449 100644
--- a/ld/testsuite/ld-x86-64/property-x86-shstk3b.d
+++ b/ld/testsuite/ld-x86-64/property-x86-shstk3b.d
@@ -6,6 +6,5 @@
 
 Displaying notes found in: .note.gnu.property
   Owner                 Data size	Description
-  GNU                  0x00000020	NT_GNU_PROPERTY_TYPE_0
-      Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1
-	x86 ISA needed: i486, 586, SSE2, SSE3
+  GNU                  0x00000010	NT_GNU_PROPERTY_TYPE_0
+      Properties: x86 ISA needed: i486, 586, SSE2, SSE3
-- 
2.17.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]