2e9b04
diff -rup binutils.orig/gold/testsuite/gnu_property_a.S binutils-2.35/gold/testsuite/gnu_property_a.S
2e9b04
--- binutils.orig/gold/testsuite/gnu_property_a.S	2021-01-18 14:01:41.228809868 +0000
2e9b04
+++ binutils-2.35/gold/testsuite/gnu_property_a.S	2021-01-18 14:01:52.542736705 +0000
2e9b04
@@ -1,8 +1,8 @@
2e9b04
 #define NT_GNU_PROPERTY_TYPE_0 5
2e9b04
 
2e9b04
 #define GNU_PROPERTY_STACK_SIZE 1
2e9b04
-#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
2e9b04
-#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
2e9b04
+#define GNU_PROPERTY_X86_ISA_1_USED 0xc0010002
2e9b04
+#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0008002
2e9b04
 #define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
2e9b04
 
2e9b04
 #if __SIZEOF_PTRDIFF_T__  == 8
2e9b04
diff -rup binutils.orig/gold/testsuite/gnu_property_b.S binutils-2.35/gold/testsuite/gnu_property_b.S
2e9b04
--- binutils.orig/gold/testsuite/gnu_property_b.S	2021-01-18 14:01:41.233809836 +0000
2e9b04
+++ binutils-2.35/gold/testsuite/gnu_property_b.S	2021-01-18 14:01:52.542736705 +0000
2e9b04
@@ -2,8 +2,8 @@
2e9b04
 
2e9b04
 #define GNU_PROPERTY_STACK_SIZE 1
2e9b04
 #define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
2e9b04
-#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
2e9b04
-#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
2e9b04
+#define GNU_PROPERTY_X86_ISA_1_USED 0xc0010002
2e9b04
+#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0008002
2e9b04
 #define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
2e9b04
 
2e9b04
 #if __SIZEOF_PTRDIFF_T__  == 8
2e9b04
diff -rup binutils.orig/gold/testsuite/gnu_property_c.S binutils-2.35/gold/testsuite/gnu_property_c.S
2e9b04
--- binutils.orig/gold/testsuite/gnu_property_c.S	2021-01-18 14:01:41.232809843 +0000
2e9b04
+++ binutils-2.35/gold/testsuite/gnu_property_c.S	2021-01-18 14:01:52.542736705 +0000
2e9b04
@@ -2,8 +2,8 @@
2e9b04
 
2e9b04
 #define GNU_PROPERTY_STACK_SIZE 1
2e9b04
 #define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
2e9b04
-#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
2e9b04
-#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
2e9b04
+#define GNU_PROPERTY_X86_ISA_1_USED 0xc0010002
2e9b04
+#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0008002
2e9b04
 #define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
2e9b04
 
2e9b04
 #if __SIZEOF_PTRDIFF_T__  == 8
2e9b04
diff -rup binutils.orig/gold/testsuite/gnu_property_test.sh binutils-2.35/gold/testsuite/gnu_property_test.sh
2e9b04
--- binutils.orig/gold/testsuite/gnu_property_test.sh	2021-01-18 14:01:41.236809817 +0000
2e9b04
+++ binutils-2.35/gold/testsuite/gnu_property_test.sh	2021-01-18 14:01:52.543736699 +0000
2e9b04
@@ -57,8 +57,8 @@ check_count gnu_property_test.stdout "GN
2e9b04
 
2e9b04
 check gnu_property_test.stdout "stack size: 0x111100"
2e9b04
 check gnu_property_test.stdout "no copy on protected"
2e9b04
-check gnu_property_test.stdout "x86 ISA used: i486, SSE2, SSE4_2, AVX512CD"
2e9b04
-check gnu_property_test.stdout "x86 ISA needed: i486, SSE2, SSE4_2, AVX512CD"
2e9b04
+check gnu_property_test.stdout "x86 ISA used: x86-64-v2, <unknown: 10>, <unknown: 100>, <unknown: 1000>"
2e9b04
+check gnu_property_test.stdout "x86 ISA needed: x86-64-v2, <unknown: 10>, <unknown: 100>, <unknown: 1000>"
2e9b04
 check gnu_property_test.stdout "x86 feature: IBT"
2e9b04
 
2e9b04
 exit 0
2e9b04
diff -rup binutils.orig/gold/x86_64.cc binutils-2.35/gold/x86_64.cc
2e9b04
--- binutils.orig/gold/x86_64.cc	2021-01-18 14:01:41.225809888 +0000
2e9b04
+++ binutils-2.35/gold/x86_64.cc	2021-01-18 14:01:52.543736699 +0000
2e9b04
@@ -706,8 +706,9 @@ class Target_x86_64 : public Sized_targe
2e9b04
       rela_irelative_(NULL), copy_relocs_(elfcpp::R_X86_64_COPY),
2e9b04
       got_mod_index_offset_(-1U), tlsdesc_reloc_info_(),
2e9b04
       tls_base_symbol_defined_(false), isa_1_used_(0), isa_1_needed_(0),
2e9b04
-      feature_1_(0), object_isa_1_used_(0), object_feature_1_(0),
2e9b04
-      seen_first_object_(false)
2e9b04
+      feature_1_(0), feature_2_used_(0), feature_2_needed_(0),
2e9b04
+      object_isa_1_used_(0), object_feature_1_(0),
2e9b04
+      object_feature_2_used_(0), seen_first_object_(false)
2e9b04
   { }
2e9b04
 
2e9b04
   // Hook for a new output section.
2e9b04
@@ -1382,6 +1383,8 @@ class Target_x86_64 : public Sized_targe
2e9b04
   uint32_t isa_1_used_;
2e9b04
   uint32_t isa_1_needed_;
2e9b04
   uint32_t feature_1_;
2e9b04
+  uint32_t feature_2_used_;
2e9b04
+  uint32_t feature_2_needed_;
2e9b04
   // Target-specific properties from the current object.
2e9b04
   // These bits get ORed into ISA_1_USED_ after all properties for the object
2e9b04
   // have been processed. But if either is all zeroes (as when the property
2e9b04
@@ -1391,6 +1394,7 @@ class Target_x86_64 : public Sized_targe
2e9b04
   // These bits get ANDed into FEATURE_1_ after all properties for the object
2e9b04
   // have been processed.
2e9b04
   uint32_t object_feature_1_;
2e9b04
+  uint32_t object_feature_2_used_;
2e9b04
   // Whether we have seen our first object, for use in initializing FEATURE_1_.
2e9b04
   bool seen_first_object_;
2e9b04
 };
2e9b04
@@ -1594,9 +1598,15 @@ Target_x86_64<size>::record_gnu_property
2e9b04
 
2e9b04
   switch (pr_type)
2e9b04
     {
2e9b04
+    case elfcpp::GNU_PROPERTY_X86_COMPAT_ISA_1_USED:
2e9b04
+    case elfcpp::GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED:
2e9b04
+    case elfcpp::GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED:
2e9b04
+    case elfcpp::GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED:
2e9b04
     case elfcpp::GNU_PROPERTY_X86_ISA_1_USED:
2e9b04
     case elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED:
2e9b04
     case elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND:
2e9b04
+    case elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED:
2e9b04
+    case elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED:
2e9b04
       if (pr_datasz != 4)
2e9b04
 	{
2e9b04
 	  gold_warning(_("%s: corrupt .note.gnu.property section "
2e9b04
@@ -1625,6 +1635,12 @@ Target_x86_64<size>::record_gnu_property
2e9b04
       // If we see multiple feature props in one object, OR them together.
2e9b04
       this->object_feature_1_ |= val;
2e9b04
       break;
2e9b04
+    case elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED:
2e9b04
+      this->object_feature_2_used_ |= val;
2e9b04
+      break;
2e9b04
+    case elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED:
2e9b04
+      this->feature_2_needed_ |= val;
2e9b04
+      break;
2e9b04
     }
2e9b04
 }
2e9b04
 
2e9b04
@@ -1642,15 +1658,23 @@ Target_x86_64<size>::merge_gnu_propertie
2e9b04
       else if (this->isa_1_used_ != 0)
2e9b04
 	this->isa_1_used_ |= this->object_isa_1_used_;
2e9b04
       this->feature_1_ &= this->object_feature_1_;
2e9b04
+      // If any object is missing the FEATURE_2_USED property, we must
2e9b04
+      // omit it from the output file.
2e9b04
+      if (this->object_feature_2_used_ == 0)
2e9b04
+	this->feature_2_used_ = 0;
2e9b04
+      else if (this->feature_2_used_ != 0)
2e9b04
+	this->feature_2_used_ |= this->object_feature_2_used_;
2e9b04
     }
2e9b04
   else
2e9b04
     {
2e9b04
       this->isa_1_used_ = this->object_isa_1_used_;
2e9b04
       this->feature_1_ = this->object_feature_1_;
2e9b04
+      this->feature_2_used_ = this->object_feature_2_used_;
2e9b04
       this->seen_first_object_ = true;
2e9b04
     }
2e9b04
   this->object_isa_1_used_ = 0;
2e9b04
   this->object_feature_1_ = 0;
2e9b04
+  this->object_feature_2_used_ = 0;
2e9b04
 }
2e9b04
 
2e9b04
 static inline void
2e9b04
@@ -1676,6 +1700,12 @@ Target_x86_64<size>::do_finalize_gnu_pro
2e9b04
   if (this->feature_1_ != 0)
2e9b04
     add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND,
2e9b04
 		 this->feature_1_);
2e9b04
+  if (this->feature_2_used_ != 0)
2e9b04
+    add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED,
2e9b04
+		 this->feature_2_used_);
2e9b04
+  if (this->feature_2_needed_ != 0)
2e9b04
+    add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED,
2e9b04
+		 this->feature_2_needed_);
2e9b04
 }
2e9b04
 
2e9b04
 // Write the first three reserved words of the .got.plt section.
2e9b04
--- binutils.orig/elfcpp/elfcpp.h	2021-01-18 14:01:40.778812778 +0000
2e9b04
+++ binutils-2.35/elfcpp/elfcpp.h	2021-01-18 14:50:05.144035077 +0000
2e9b04
@@ -1009,9 +1009,21 @@ enum
2e9b04
   GNU_PROPERTY_STACK_SIZE = 1,
2e9b04
   GNU_PROPERTY_NO_COPY_ON_PROTECTED = 2,
2e9b04
   GNU_PROPERTY_LOPROC = 0xc0000000,
2e9b04
-  GNU_PROPERTY_X86_ISA_1_USED = 0xc0000000,
2e9b04
-  GNU_PROPERTY_X86_ISA_1_NEEDED = 0xc0000001,
2e9b04
-  GNU_PROPERTY_X86_FEATURE_1_AND = 0xc0000002,
2e9b04
+  GNU_PROPERTY_X86_COMPAT_ISA_1_USED = 0xc0000000,
2e9b04
+  GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED = 0xc0000001,
2e9b04
+  GNU_PROPERTY_X86_UINT32_AND_LO = 0xc0000002,
2e9b04
+  GNU_PROPERTY_X86_UINT32_AND_HI = 0xc0007fff,
2e9b04
+  GNU_PROPERTY_X86_UINT32_OR_LO = 0xc0008000,
2e9b04
+  GNU_PROPERTY_X86_UINT32_OR_HI = 0xc000ffff,
2e9b04
+  GNU_PROPERTY_X86_UINT32_OR_AND_LO = 0xc0010000,
2e9b04
+  GNU_PROPERTY_X86_UINT32_OR_AND_HI = 0xc0017fff,
2e9b04
+  GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED = GNU_PROPERTY_X86_UINT32_OR_LO + 0,
2e9b04
+  GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED = GNU_PROPERTY_X86_UINT32_OR_AND_LO + 0,
2e9b04
+  GNU_PROPERTY_X86_FEATURE_1_AND = GNU_PROPERTY_X86_UINT32_AND_LO + 0,
2e9b04
+  GNU_PROPERTY_X86_ISA_1_NEEDED = GNU_PROPERTY_X86_UINT32_OR_LO + 2,
2e9b04
+  GNU_PROPERTY_X86_FEATURE_2_NEEDED = GNU_PROPERTY_X86_UINT32_OR_LO + 1,
2e9b04
+  GNU_PROPERTY_X86_ISA_1_USED = GNU_PROPERTY_X86_UINT32_OR_AND_LO + 2,
2e9b04
+  GNU_PROPERTY_X86_FEATURE_2_USED = GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1,
2e9b04
   GNU_PROPERTY_HIPROC = 0xdfffffff,
2e9b04
   GNU_PROPERTY_LOUSER = 0xe0000000,
2e9b04
   GNU_PROPERTY_HIUSER = 0xffffffff