Layout* layout,
Workqueue* workqueue)
{
+ // Now we have seen all the input files.
+ set_parameters_doing_static_link(!input_objects->any_dynamic());
+
// Define some sections and symbols needed for a dynamic link. This
// handles some cases we want to see before we read the relocs.
layout->create_initial_dynamic_sections(input_objects, symtab);
// Initialize the parameters from the options.
Parameters::Parameters(const General_options* options)
- : is_size_and_endian_valid_(false), size_(0), is_big_endian_(false),
+ : is_doing_static_link_valid_(false), doing_static_link_(false),
+ is_size_and_endian_valid_(false), size_(0), is_big_endian_(false),
optimization_level_(options->optimization_level())
{
if (options->is_shared())
this->output_file_type_ = OUTPUT_EXECUTABLE;
}
+// Set whether we are doing a static link.
+
+void
+Parameters::set_doing_static_link(bool doing_static_link)
+{
+ this->doing_static_link_ = doing_static_link;
+ this->is_doing_static_link_valid_ = true;
+}
+
// Set the size and endianness.
void
parameters = static_parameters = new Parameters(options);
}
+// Set whether we are doing a static link.
+
+void
+set_parameters_doing_static_link(bool doing_static_link)
+{
+ static_parameters->set_doing_static_link(doing_static_link);
+}
+
+// Set the size and endianness.
+
void
set_parameters_size_and_endianness(int size, bool is_big_endian)
{
output_is_object() const
{ return this->output_file_type_ == OUTPUT_OBJECT; }
+ // Whether we are doing a static link--a link in which none of the
+ // input files are shared libraries. This is only known after we
+ // have seen all the input files.
+ bool
+ doing_static_link() const
+ {
+ gold_assert(this->is_doing_static_link_valid_);
+ return this->doing_static_link_;
+ }
+
// The size of the output file we are generating. This should
// return 32 or 64.
int
optimization_level() const
{ return this->optimization_level_; }
+ // Set whether we are doing a static link.
+ void
+ set_doing_static_link(bool doing_static_link);
+
// Set the size and endianness.
void
set_size_and_endianness(int size, bool is_big_endian);
// The type of the output file.
Output_file_type output_file_type_;
+ // Whether the doing_static_link_ field is valid.
+ bool is_doing_static_link_valid_;
+ // Whether we are doing a static link.
+ bool doing_static_link_;
// Whether the size_ and is_big_endian_ fields are valid.
bool is_size_and_endian_valid_;
// The size of the output file--32 or 64.
// Set the size and endianness of the global parameters variable.
extern void set_parameters_size_and_endianness(int size, bool is_big_endian);
+// Set whether we are doing a static link.
+extern void set_parameters_doing_static_link(bool doing_static_link);
+
} // End namespace gold.
#endif // !defined(GOLD_PARAMATERS_H)
this->symsize_ = symsize;
}
+// Return true if the final value of this symbol is known at link
+// time.
+
+bool
+Symbol::final_value_is_known() const
+{
+ // If we are not generating an executable, then no final values are
+ // known, since they will change at runtime.
+ if (!parameters->output_is_executable())
+ return false;
+
+ // If the symbol is not from an object file, then it is defined, and
+ // known.
+ if (this->source_ != FROM_OBJECT)
+ return true;
+
+ // If the symbol is from a dynamic object, then the final value is
+ // not known.
+ if (this->object()->is_dynamic())
+ return false;
+
+ // If the symbol is not undefined (it is defined or common), then
+ // the final value is known.
+ if (!this->is_undefined())
+ return true;
+
+ // If the symbol is undefined, then whether the final value is known
+ // depends on whether we are doing a static link. If we are doing a
+ // dynamic link, then the final value could be filled in at runtime.
+ // This could reasonably be the case for a weak undefined symbol.
+ return parameters->doing_static_link();
+}
+
// Class Symbol_table.
Symbol_table::Symbol_table()
// Return true if the final value of this symbol is known at link
// time.
bool
- final_value_is_known() const
- {
- if (parameters->output_is_shared())
- return false;
- return this->source_ != FROM_OBJECT || !this->object()->is_dynamic();
- }
+ final_value_is_known() const;
// Return whether this is a defined symbol (not undefined or
// common).