|
|
5044c7 |
diff --git a/gold/i386.cc b/gold/i386.cc
|
|
|
5044c7 |
index bf209fe9a86..31161ff091c 100644
|
|
|
5044c7 |
--- a/gold/i386.cc
|
|
|
5044c7 |
+++ b/gold/i386.cc
|
|
|
5044c7 |
@@ -360,7 +360,11 @@ class Target_i386 : public Sized_target<32, false>
|
|
|
5044c7 |
got_(NULL), plt_(NULL), got_plt_(NULL), got_irelative_(NULL),
|
|
|
5044c7 |
got_tlsdesc_(NULL), global_offset_table_(NULL), rel_dyn_(NULL),
|
|
|
5044c7 |
rel_irelative_(NULL), copy_relocs_(elfcpp::R_386_COPY),
|
|
|
5044c7 |
- got_mod_index_offset_(-1U), tls_base_symbol_defined_(false)
|
|
|
5044c7 |
+ got_mod_index_offset_(-1U), tls_base_symbol_defined_(false),
|
|
|
5044c7 |
+ isa_1_used_(0), isa_1_needed_(0),
|
|
|
5044c7 |
+ feature_1_(0), feature_2_used_(0), feature_2_needed_(0),
|
|
|
5044c7 |
+ object_isa_1_used_(0), object_feature_1_(0),
|
|
|
5044c7 |
+ object_feature_2_used_(0), seen_first_object_(false)
|
|
|
5044c7 |
{ }
|
|
|
5044c7 |
|
|
|
5044c7 |
// Process the relocations to determine unreferenced sections for
|
|
|
5044c7 |
@@ -859,6 +863,21 @@ class Target_i386 : public Sized_target<32, false>
|
|
|
5044c7 |
this->rel_dyn_section(layout));
|
|
|
5044c7 |
}
|
|
|
5044c7 |
|
|
|
5044c7 |
+ // Record a target-specific program property in the .note.gnu.property
|
|
|
5044c7 |
+ // section.
|
|
|
5044c7 |
+ void
|
|
|
5044c7 |
+ record_gnu_property(unsigned int, unsigned int, size_t,
|
|
|
5044c7 |
+ const unsigned char*, const Object*);
|
|
|
5044c7 |
+
|
|
|
5044c7 |
+ // Merge the target-specific program properties from the current object.
|
|
|
5044c7 |
+ void
|
|
|
5044c7 |
+ merge_gnu_properties(const Object*);
|
|
|
5044c7 |
+
|
|
|
5044c7 |
+ // Finalize the target-specific program properties and add them back to
|
|
|
5044c7 |
+ // the layout.
|
|
|
5044c7 |
+ void
|
|
|
5044c7 |
+ do_finalize_gnu_properties(Layout*) const;
|
|
|
5044c7 |
+
|
|
|
5044c7 |
// Information about this specific target which we pass to the
|
|
|
5044c7 |
// general Target structure.
|
|
|
5044c7 |
static const Target::Target_info i386_info;
|
|
|
5044c7 |
@@ -898,6 +917,26 @@ class Target_i386 : public Sized_target<32, false>
|
|
|
5044c7 |
unsigned int got_mod_index_offset_;
|
|
|
5044c7 |
// True if the _TLS_MODULE_BASE_ symbol has been defined.
|
|
|
5044c7 |
bool tls_base_symbol_defined_;
|
|
|
5044c7 |
+
|
|
|
5044c7 |
+ // Target-specific program properties, from .note.gnu.property section.
|
|
|
5044c7 |
+ // Each bit represents a specific feature.
|
|
|
5044c7 |
+ uint32_t isa_1_used_;
|
|
|
5044c7 |
+ uint32_t isa_1_needed_;
|
|
|
5044c7 |
+ uint32_t feature_1_;
|
|
|
5044c7 |
+ uint32_t feature_2_used_;
|
|
|
5044c7 |
+ uint32_t feature_2_needed_;
|
|
|
5044c7 |
+ // Target-specific properties from the current object.
|
|
|
5044c7 |
+ // These bits get ORed into ISA_1_USED_ after all properties for the object
|
|
|
5044c7 |
+ // have been processed. But if either is all zeroes (as when the property
|
|
|
5044c7 |
+ // is absent from an object), the result should be all zeroes.
|
|
|
5044c7 |
+ // (See PR ld/23486.)
|
|
|
5044c7 |
+ uint32_t object_isa_1_used_;
|
|
|
5044c7 |
+ // These bits get ANDed into FEATURE_1_ after all properties for the object
|
|
|
5044c7 |
+ // have been processed.
|
|
|
5044c7 |
+ uint32_t object_feature_1_;
|
|
|
5044c7 |
+ uint32_t object_feature_2_used_;
|
|
|
5044c7 |
+ // Whether we have seen our first object, for use in initializing FEATURE_1_.
|
|
|
5044c7 |
+ bool seen_first_object_;
|
|
|
5044c7 |
};
|
|
|
5044c7 |
|
|
|
5044c7 |
const Target::Target_info Target_i386::i386_info =
|
|
|
5044c7 |
@@ -1042,6 +1081,126 @@ Target_i386::rel_irelative_section(Layout* layout)
|
|
|
5044c7 |
return this->rel_irelative_;
|
|
|
5044c7 |
}
|
|
|
5044c7 |
|
|
|
5044c7 |
+// Record a target-specific program property from the .note.gnu.property
|
|
|
5044c7 |
+// section.
|
|
|
5044c7 |
+void
|
|
|
5044c7 |
+Target_i386::record_gnu_property(
|
|
|
5044c7 |
+ unsigned int, unsigned int pr_type,
|
|
|
5044c7 |
+ size_t pr_datasz, const unsigned char* pr_data,
|
|
|
5044c7 |
+ const Object* object)
|
|
|
5044c7 |
+{
|
|
|
5044c7 |
+ uint32_t val = 0;
|
|
|
5044c7 |
+
|
|
|
5044c7 |
+ switch (pr_type)
|
|
|
5044c7 |
+ {
|
|
|
5044c7 |
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_ISA_1_USED:
|
|
|
5044c7 |
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED:
|
|
|
5044c7 |
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED:
|
|
|
5044c7 |
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED:
|
|
|
5044c7 |
+ case elfcpp::GNU_PROPERTY_X86_ISA_1_USED:
|
|
|
5044c7 |
+ case elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED:
|
|
|
5044c7 |
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND:
|
|
|
5044c7 |
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED:
|
|
|
5044c7 |
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED:
|
|
|
5044c7 |
+ if (pr_datasz != 4)
|
|
|
5044c7 |
+ {
|
|
|
5044c7 |
+ gold_warning(_("%s: corrupt .note.gnu.property section "
|
|
|
5044c7 |
+ "(pr_datasz for property %d is not 4)"),
|
|
|
5044c7 |
+ object->name().c_str(), pr_type);
|
|
|
5044c7 |
+ return;
|
|
|
5044c7 |
+ }
|
|
|
5044c7 |
+ val = elfcpp::Swap<32, false>::readval(pr_data);
|
|
|
5044c7 |
+ break;
|
|
|
5044c7 |
+ default:
|
|
|
5044c7 |
+ gold_warning(_("%s: unknown program property type 0x%x "
|
|
|
5044c7 |
+ "in .note.gnu.property section"),
|
|
|
5044c7 |
+ object->name().c_str(), pr_type);
|
|
|
5044c7 |
+ break;
|
|
|
5044c7 |
+ }
|
|
|
5044c7 |
+
|
|
|
5044c7 |
+ switch (pr_type)
|
|
|
5044c7 |
+ {
|
|
|
5044c7 |
+ case elfcpp::GNU_PROPERTY_X86_ISA_1_USED:
|
|
|
5044c7 |
+ this->object_isa_1_used_ |= val;
|
|
|
5044c7 |
+ break;
|
|
|
5044c7 |
+ case elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED:
|
|
|
5044c7 |
+ this->isa_1_needed_ |= val;
|
|
|
5044c7 |
+ break;
|
|
|
5044c7 |
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND:
|
|
|
5044c7 |
+ // If we see multiple feature props in one object, OR them together.
|
|
|
5044c7 |
+ this->object_feature_1_ |= val;
|
|
|
5044c7 |
+ break;
|
|
|
5044c7 |
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED:
|
|
|
5044c7 |
+ this->object_feature_2_used_ |= val;
|
|
|
5044c7 |
+ break;
|
|
|
5044c7 |
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED:
|
|
|
5044c7 |
+ this->feature_2_needed_ |= val;
|
|
|
5044c7 |
+ break;
|
|
|
5044c7 |
+ }
|
|
|
5044c7 |
+}
|
|
|
5044c7 |
+
|
|
|
5044c7 |
+// Merge the target-specific program properties from the current object.
|
|
|
5044c7 |
+void
|
|
|
5044c7 |
+Target_i386::merge_gnu_properties(const Object*)
|
|
|
5044c7 |
+{
|
|
|
5044c7 |
+ if (this->seen_first_object_)
|
|
|
5044c7 |
+ {
|
|
|
5044c7 |
+ // If any object is missing the ISA_1_USED property, we must omit
|
|
|
5044c7 |
+ // it from the output file.
|
|
|
5044c7 |
+ if (this->object_isa_1_used_ == 0)
|
|
|
5044c7 |
+ this->isa_1_used_ = 0;
|
|
|
5044c7 |
+ else if (this->isa_1_used_ != 0)
|
|
|
5044c7 |
+ this->isa_1_used_ |= this->object_isa_1_used_;
|
|
|
5044c7 |
+ this->feature_1_ &= this->object_feature_1_;
|
|
|
5044c7 |
+ // If any object is missing the FEATURE_2_USED property, we must
|
|
|
5044c7 |
+ // omit it from the output file.
|
|
|
5044c7 |
+ if (this->object_feature_2_used_ == 0)
|
|
|
5044c7 |
+ this->feature_2_used_ = 0;
|
|
|
5044c7 |
+ else if (this->feature_2_used_ != 0)
|
|
|
5044c7 |
+ this->feature_2_used_ |= this->object_feature_2_used_;
|
|
|
5044c7 |
+ }
|
|
|
5044c7 |
+ else
|
|
|
5044c7 |
+ {
|
|
|
5044c7 |
+ this->isa_1_used_ = this->object_isa_1_used_;
|
|
|
5044c7 |
+ this->feature_1_ = this->object_feature_1_;
|
|
|
5044c7 |
+ this->feature_2_used_ = this->object_feature_2_used_;
|
|
|
5044c7 |
+ this->seen_first_object_ = true;
|
|
|
5044c7 |
+ }
|
|
|
5044c7 |
+ this->object_isa_1_used_ = 0;
|
|
|
5044c7 |
+ this->object_feature_1_ = 0;
|
|
|
5044c7 |
+ this->object_feature_2_used_ = 0;
|
|
|
5044c7 |
+}
|
|
|
5044c7 |
+
|
|
|
5044c7 |
+static inline void
|
|
|
5044c7 |
+add_property(Layout* layout, unsigned int pr_type, uint32_t val)
|
|
|
5044c7 |
+{
|
|
|
5044c7 |
+ unsigned char buf[4];
|
|
|
5044c7 |
+ elfcpp::Swap<32, false>::writeval(buf, val);
|
|
|
5044c7 |
+ layout->add_gnu_property(elfcpp::NT_GNU_PROPERTY_TYPE_0, pr_type, 4, buf);
|
|
|
5044c7 |
+}
|
|
|
5044c7 |
+
|
|
|
5044c7 |
+// Finalize the target-specific program properties and add them back to
|
|
|
5044c7 |
+// the layout.
|
|
|
5044c7 |
+void
|
|
|
5044c7 |
+Target_i386::do_finalize_gnu_properties(Layout* layout) const
|
|
|
5044c7 |
+{
|
|
|
5044c7 |
+ if (this->isa_1_used_ != 0)
|
|
|
5044c7 |
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_ISA_1_USED,
|
|
|
5044c7 |
+ this->isa_1_used_);
|
|
|
5044c7 |
+ if (this->isa_1_needed_ != 0)
|
|
|
5044c7 |
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED,
|
|
|
5044c7 |
+ this->isa_1_needed_);
|
|
|
5044c7 |
+ if (this->feature_1_ != 0)
|
|
|
5044c7 |
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND,
|
|
|
5044c7 |
+ this->feature_1_);
|
|
|
5044c7 |
+ if (this->feature_2_used_ != 0)
|
|
|
5044c7 |
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED,
|
|
|
5044c7 |
+ this->feature_2_used_);
|
|
|
5044c7 |
+ if (this->feature_2_needed_ != 0)
|
|
|
5044c7 |
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED,
|
|
|
5044c7 |
+ this->feature_2_needed_);
|
|
|
5044c7 |
+}
|
|
|
5044c7 |
+
|
|
|
5044c7 |
// Write the first three reserved words of the .got.plt section.
|
|
|
5044c7 |
// The remainder of the section is written while writing the PLT
|
|
|
5044c7 |
// in Output_data_plt_i386::do_write.
|