gold: Update GNU_PROPERTY_X86_XXX macros
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 13 Oct 2020 12:20:49 +0000 (05:20 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 13 Oct 2020 12:21:05 +0000 (05:21 -0700)
This patch updates GNU_PROPERTY_X86_XXX macros for gold:

1. GNU_PROPERTY_X86_UINT32_AND_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in all relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_AND_LO      0xc0000002
 #define GNU_PROPERTY_X86_UINT32_AND_HI      0xc0007fff

2. GNU_PROPERTY_X86_UINT32_OR_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in any relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_OR_LO    0xc0008000
 #define GNU_PROPERTY_X86_UINT32_OR_HI    0xc000ffff

3. GNU_PROPERTY_X86_UINT32_OR_AND_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in any relocatable inputs and the property is
present in all relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_OR_AND_LO   0xc0010000
 #define GNU_PROPERTY_X86_UINT32_OR_AND_HI   0xc0017fff

4. GNU_PROPERTY_X86_FEATURE_2_NEEDED, GNU_PROPERTY_X86_FEATURE_2_USED
and GNU_PROPERTY_X86_FEATURE_2_XXX bits.

GNU_PROPERTY_X86_FEATURE_1_AND is unchanged.  GNU_PROPERTY_X86_ISA_1_USED
and GNU_PROPERTY_X86_ISA_1_NEEDED are updated to better support targeted
processors since GNU_PROPERTY_X86_ISA_1_?86 aren't isn't very useful.
A new set of GNU_PROPERTY_X86_ISA_1_XXX bits are defined.  The previous
GNU_PROPERTY_X86_ISA_1_XXX macros are deprecated and renamed to
GNU_PROPERTY_X86_COMPAT_ISA_1_XXX and GNU_PROPERTY_X86_COMPAT_2_ISA_1_XXX.

elfcpp/

* elfcpp.h (GNU_PROPERTY_X86_ISA_1_USED): Renamed to ...
(GNU_PROPERTY_X86_COMPAT_ISA_1_USED): This.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Renamed to ...
(GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED): This.
(GNU_PROPERTY_X86_UINT32_AND_LO): New.
(GNU_PROPERTY_X86_UINT32_AND_HI): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_LO): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_HI): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_AND_LO): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_AND_HI): Likewise.
(GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED): New.
(GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED): Likewise.
(GNU_PROPERTY_X86_FEATURE_1_AND): Updated to
(GNU_PROPERTY_X86_UINT32_AND_LO + 0).
(GNU_PROPERTY_X86_ISA_1_NEEDED): New.  Defined to
GNU_PROPERTY_X86_UINT32_OR_LO + 2.
(GNU_PROPERTY_X86_FEATURE_2_NEEDED): New.  Defined to
(GNU_PROPERTY_X86_UINT32_OR_LO + 1).
(GNU_PROPERTY_X86_ISA_1_USED): New.  Defined to
GNU_PROPERTY_X86_UINT32_OR_AND_LO + 2.
(GNU_PROPERTY_X86_FEATURE_2_USED): New.  Defined to
(GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1).

gold/

* x86_64.cc (Target_x86_64::Target_x86_64): Initialize
feature_2_used_, feature_2_needed_ and object_feature_2_used_.
(Target_x86_64::feature_2_used_): New data member.
(Target_x86_64::feature_2_needed_): Likewise.
(Target_x86_64::object_isa_1_used_): Likewise.
(Target_x86_64::record_gnu_property): Support
GNU_PROPERTY_X86_COMPAT_ISA_1_USED,
GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED,
GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED,
GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED,
GNU_PROPERTY_X86_FEATURE_2_USED and
GNU_PROPERTY_X86_FEATURE_2_NEEDED.
(Target_x86_64::merge_gnu_properties): Merge FEATURE_2_USED bits.
Initialize object_feature_2_used_.
(Target_x86_64::do_finalize_gnu_properties): Support
GNU_PROPERTY_X86_FEATURE_2_USED and
GNU_PROPERTY_X86_FEATURE_2_NEEDED.
* testsuite/gnu_property_a.S (GNU_PROPERTY_X86_ISA_1_USED): Set
to 0xc0010002.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
* testsuite/gnu_property_b.S (GNU_PROPERTY_X86_ISA_1_USED): Set
to 0xc0010002.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
* testsuite/gnu_property_c.S (GNU_PROPERTY_X86_ISA_1_USED): Set
to 0xc0010002.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
* testsuite/gnu_property_test.sh: Updated.

elfcpp/ChangeLog
elfcpp/elfcpp.h
gold/ChangeLog
gold/testsuite/gnu_property_a.S
gold/testsuite/gnu_property_b.S
gold/testsuite/gnu_property_c.S
gold/testsuite/gnu_property_test.sh
gold/x86_64.cc

index 87e4fc8698f88e8fee68ee74f029be24860c6d43..c72a432e095e0d67780cf91a8efdece6617779c3 100644 (file)
@@ -1,3 +1,28 @@
+2020-10-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elfcpp.h (GNU_PROPERTY_X86_ISA_1_USED): Renamed to ...
+       (GNU_PROPERTY_X86_COMPAT_ISA_1_USED): This.
+       (GNU_PROPERTY_X86_ISA_1_NEEDED): Renamed to ...
+       (GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED): This.
+       (GNU_PROPERTY_X86_UINT32_AND_LO): New.
+       (GNU_PROPERTY_X86_UINT32_AND_HI): Likewise.
+       (GNU_PROPERTY_X86_UINT32_OR_LO): Likewise.
+       (GNU_PROPERTY_X86_UINT32_OR_HI): Likewise.
+       (GNU_PROPERTY_X86_UINT32_OR_AND_LO): Likewise.
+       (GNU_PROPERTY_X86_UINT32_OR_AND_HI): Likewise.
+       (GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED): New.
+       (GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED): Likewise.
+       (GNU_PROPERTY_X86_FEATURE_1_AND): Updated to
+       (GNU_PROPERTY_X86_UINT32_AND_LO + 0).
+       (GNU_PROPERTY_X86_ISA_1_NEEDED): New.  Defined to
+       GNU_PROPERTY_X86_UINT32_OR_LO + 2.
+       (GNU_PROPERTY_X86_FEATURE_2_NEEDED): New.  Defined to
+       (GNU_PROPERTY_X86_UINT32_OR_LO + 1).
+       (GNU_PROPERTY_X86_ISA_1_USED): New.  Defined to
+       GNU_PROPERTY_X86_UINT32_OR_AND_LO + 2.
+       (GNU_PROPERTY_X86_FEATURE_2_USED): New.  Defined to
+       (GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1).
+
 2020-09-25  Alan Modra  <amodra@gmail.com>
 
        * dwarf.h (DW_FIRST_UT, DW_UT, DW_END_UT): Define.
index 65d803c00e270327bfa992b0abe1e163c6765bb4..4b6ff94a654201c819ce08293b09a52b827e1c34 100644 (file)
@@ -1013,9 +1013,21 @@ enum
   GNU_PROPERTY_STACK_SIZE = 1,
   GNU_PROPERTY_NO_COPY_ON_PROTECTED = 2,
   GNU_PROPERTY_LOPROC = 0xc0000000,
-  GNU_PROPERTY_X86_ISA_1_USED = 0xc0000000,
-  GNU_PROPERTY_X86_ISA_1_NEEDED = 0xc0000001,
-  GNU_PROPERTY_X86_FEATURE_1_AND = 0xc0000002,
+  GNU_PROPERTY_X86_COMPAT_ISA_1_USED = 0xc0000000,
+  GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED = 0xc0000001,
+  GNU_PROPERTY_X86_UINT32_AND_LO = 0xc0000002,
+  GNU_PROPERTY_X86_UINT32_AND_HI = 0xc0007fff,
+  GNU_PROPERTY_X86_UINT32_OR_LO = 0xc0008000,
+  GNU_PROPERTY_X86_UINT32_OR_HI = 0xc000ffff,
+  GNU_PROPERTY_X86_UINT32_OR_AND_LO = 0xc0010000,
+  GNU_PROPERTY_X86_UINT32_OR_AND_HI = 0xc0017fff,
+  GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED = GNU_PROPERTY_X86_UINT32_OR_LO + 0,
+  GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED = GNU_PROPERTY_X86_UINT32_OR_AND_LO + 0,
+  GNU_PROPERTY_X86_FEATURE_1_AND = GNU_PROPERTY_X86_UINT32_AND_LO + 0,
+  GNU_PROPERTY_X86_ISA_1_NEEDED = GNU_PROPERTY_X86_UINT32_OR_LO + 2,
+  GNU_PROPERTY_X86_FEATURE_2_NEEDED = GNU_PROPERTY_X86_UINT32_OR_LO + 1,
+  GNU_PROPERTY_X86_ISA_1_USED = GNU_PROPERTY_X86_UINT32_OR_AND_LO + 2,
+  GNU_PROPERTY_X86_FEATURE_2_USED = GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1,
   GNU_PROPERTY_HIPROC = 0xdfffffff,
   GNU_PROPERTY_LOUSER = 0xe0000000,
   GNU_PROPERTY_HIUSER = 0xffffffff
index 2ebe2c1c3c684c0d8190e3e5ee696e926d2981f1..41fe6e033e95b5bc913ac57c5341e6178d82eda7 100644 (file)
@@ -1,3 +1,33 @@
+2020-10-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * x86_64.cc (Target_x86_64::Target_x86_64): Initialize
+       feature_2_used_, feature_2_needed_ and object_feature_2_used_.
+       (Target_x86_64::feature_2_used_): New data member.
+       (Target_x86_64::feature_2_needed_): Likewise.
+       (Target_x86_64::object_isa_1_used_): Likewise.
+       (Target_x86_64::record_gnu_property): Support
+       GNU_PROPERTY_X86_COMPAT_ISA_1_USED,
+       GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED,
+       GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED,
+       GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED,
+       GNU_PROPERTY_X86_FEATURE_2_USED and
+       GNU_PROPERTY_X86_FEATURE_2_NEEDED.
+       (Target_x86_64::merge_gnu_properties): Merge FEATURE_2_USED bits.
+       Initialize object_feature_2_used_.
+       (Target_x86_64::do_finalize_gnu_properties): Support
+       GNU_PROPERTY_X86_FEATURE_2_USED and
+       GNU_PROPERTY_X86_FEATURE_2_NEEDED.
+       * testsuite/gnu_property_a.S (GNU_PROPERTY_X86_ISA_1_USED): Set
+       to 0xc0010002.
+       (GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
+       * testsuite/gnu_property_b.S (GNU_PROPERTY_X86_ISA_1_USED): Set
+       to 0xc0010002.
+       (GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
+       * testsuite/gnu_property_c.S (GNU_PROPERTY_X86_ISA_1_USED): Set
+       to 0xc0010002.
+       (GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
+       * testsuite/gnu_property_test.sh: Updated.
+
 2020-10-13  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR gold/22914
index 463bc8e52feabcc80b4570aeeb11de193d3aabce..5fbbbc9c4bb95e1b7a0016d76fa5e4e22ee177ed 100644 (file)
@@ -1,8 +1,8 @@
 #define NT_GNU_PROPERTY_TYPE_0 5
 
 #define GNU_PROPERTY_STACK_SIZE 1
-#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
-#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
+#define GNU_PROPERTY_X86_ISA_1_USED 0xc0010002
+#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0008002
 #define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
 
 #if __SIZEOF_PTRDIFF_T__  == 8
index 0c0c038ead172bb864db27ea696675a562925679..7028f73d7ab1f836fd16faa603f288e6bea92b7a 100644 (file)
@@ -2,8 +2,8 @@
 
 #define GNU_PROPERTY_STACK_SIZE 1
 #define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
-#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
-#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
+#define GNU_PROPERTY_X86_ISA_1_USED 0xc0010002
+#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0008002
 #define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
 
 #if __SIZEOF_PTRDIFF_T__  == 8
index ace159a9a9d8702bff9b68fe9b6e3461235331bb..c8cbd8bce28c51cd47cad08355a86a804b406be5 100644 (file)
@@ -2,8 +2,8 @@
 
 #define GNU_PROPERTY_STACK_SIZE 1
 #define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
-#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
-#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
+#define GNU_PROPERTY_X86_ISA_1_USED 0xc0010002
+#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0008002
 #define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
 
 #if __SIZEOF_PTRDIFF_T__  == 8
index 1806d3474cca687e00c79619528c8750d038f23a..a4096005b787bcd15d9eb28c65b980c2eabf32b8 100755 (executable)
@@ -77,8 +77,8 @@ check_count gnu_property_test.stdout "^  NOTE" 2
 
 check gnu_property_test.stdout "stack size: 0x111100"
 check gnu_property_test.stdout "no copy on protected"
-check gnu_property_test.stdout "x86 ISA used: i486, SSE2, SSE4_2, AVX512CD"
-check gnu_property_test.stdout "x86 ISA needed: i486, SSE2, SSE4_2, AVX512CD"
+check gnu_property_test.stdout "x86 ISA used: x86-64-v2, <unknown: 10>, <unknown: 100>, <unknown: 1000>"
+check gnu_property_test.stdout "x86 ISA needed: x86-64-v2, <unknown: 10>, <unknown: 100>, <unknown: 1000>"
 check gnu_property_test.stdout "x86 feature: IBT"
 
 exit 0
index 9cb2cf0a322467e3e7c12cbd43c04097792345e8..378bac16f78db660793e002f4c9f964658f7dc0c 100644 (file)
@@ -706,8 +706,9 @@ class Target_x86_64 : public Sized_target<size, false>
       rela_irelative_(NULL), copy_relocs_(elfcpp::R_X86_64_COPY),
       got_mod_index_offset_(-1U), tlsdesc_reloc_info_(),
       tls_base_symbol_defined_(false), isa_1_used_(0), isa_1_needed_(0),
-      feature_1_(0), object_isa_1_used_(0), object_feature_1_(0),
-      seen_first_object_(false)
+      feature_1_(0), feature_2_used_(0), feature_2_needed_(0),
+      object_isa_1_used_(0), object_feature_1_(0),
+      object_feature_2_used_(0), seen_first_object_(false)
   { }
 
   // Hook for a new output section.
@@ -1382,6 +1383,8 @@ class Target_x86_64 : public Sized_target<size, false>
   uint32_t isa_1_used_;
   uint32_t isa_1_needed_;
   uint32_t feature_1_;
+  uint32_t feature_2_used_;
+  uint32_t feature_2_needed_;
   // Target-specific properties from the current object.
   // These bits get ORed into ISA_1_USED_ after all properties for the object
   // have been processed. But if either is all zeroes (as when the property
@@ -1391,6 +1394,7 @@ class Target_x86_64 : public Sized_target<size, false>
   // These bits get ANDed into FEATURE_1_ after all properties for the object
   // have been processed.
   uint32_t object_feature_1_;
+  uint32_t object_feature_2_used_;
   // Whether we have seen our first object, for use in initializing FEATURE_1_.
   bool seen_first_object_;
 };
@@ -1594,9 +1598,15 @@ Target_x86_64<size>::record_gnu_property(
 
   switch (pr_type)
     {
+    case elfcpp::GNU_PROPERTY_X86_COMPAT_ISA_1_USED:
+    case elfcpp::GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED:
+    case elfcpp::GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED:
+    case elfcpp::GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED:
     case elfcpp::GNU_PROPERTY_X86_ISA_1_USED:
     case elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED:
     case elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND:
+    case elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED:
+    case elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED:
       if (pr_datasz != 4)
        {
          gold_warning(_("%s: corrupt .note.gnu.property section "
@@ -1625,6 +1635,12 @@ Target_x86_64<size>::record_gnu_property(
       // If we see multiple feature props in one object, OR them together.
       this->object_feature_1_ |= val;
       break;
+    case elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED:
+      this->object_feature_2_used_ |= val;
+      break;
+    case elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED:
+      this->feature_2_needed_ |= val;
+      break;
     }
 }
 
@@ -1642,15 +1658,23 @@ Target_x86_64<size>::merge_gnu_properties(const Object*)
       else if (this->isa_1_used_ != 0)
        this->isa_1_used_ |= this->object_isa_1_used_;
       this->feature_1_ &= this->object_feature_1_;
+      // If any object is missing the FEATURE_2_USED property, we must
+      // omit it from the output file.
+      if (this->object_feature_2_used_ == 0)
+       this->feature_2_used_ = 0;
+      else if (this->feature_2_used_ != 0)
+       this->feature_2_used_ |= this->object_feature_2_used_;
     }
   else
     {
       this->isa_1_used_ = this->object_isa_1_used_;
       this->feature_1_ = this->object_feature_1_;
+      this->feature_2_used_ = this->object_feature_2_used_;
       this->seen_first_object_ = true;
     }
   this->object_isa_1_used_ = 0;
   this->object_feature_1_ = 0;
+  this->object_feature_2_used_ = 0;
 }
 
 static inline void
@@ -1676,6 +1700,12 @@ Target_x86_64<size>::do_finalize_gnu_properties(Layout* layout) const
   if (this->feature_1_ != 0)
     add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND,
                 this->feature_1_);
+  if (this->feature_2_used_ != 0)
+    add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED,
+                this->feature_2_used_);
+  if (this->feature_2_needed_ != 0)
+    add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED,
+                this->feature_2_needed_);
 }
 
 // Write the first three reserved words of the .got.plt section.