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