class General_options;
class Task;
+class Cref;
+class Archive;
class Layout;
class Output_section;
class Output_file;
class Output_symtab_xindex;
+class Pluginobj;
class Dynobj;
class Object_merge_map;
class Relocatable_relocs;
is_dynamic() const
{ return this->is_dynamic_; }
+ // Returns NULL for Objects that are not plugin objects. This method
+ // is overridden in the Pluginobj class.
+ Pluginobj*
+ pluginobj()
+ { return this->do_pluginobj(); }
+
// Return the target structure associated with this object.
Target*
target() const
// Read data from the underlying file.
void
- read(off_t start, section_size_type size, void* p) const
+ read(off_t start, section_size_type size, void* p)
{ this->input_file()->file().read(start + this->offset_, size, p); }
// Read multiple data from the underlying file.
clear_view_cache_marks()
{ this->input_file()->file().clear_view_cache_marks(); }
+ // Get the number of global symbols defined by this object, and the
+ // number of the symbols whose final definition came from this
+ // object.
+ void
+ get_global_symbol_counts(const Symbol_table* symtab, size_t* defined,
+ size_t* used) const
+ { this->do_get_global_symbol_counts(symtab, defined, used); }
+
+ // Set the target.
+ void
+ set_target(Target* target)
+ { this->target_ = target; }
+
protected:
+ // Returns NULL for Objects that are not plugin objects. This method
+ // is overridden in the Pluginobj class.
+ virtual Pluginobj*
+ do_pluginobj()
+ { return NULL; }
+
// Read the symbols--implemented by child class.
virtual void
do_read_symbols(Read_symbols_data*) = 0;
virtual Xindex*
do_initialize_xindex() = 0;
+ // Implement get_global_symbol_counts--implemented by child class.
+ virtual void
+ do_get_global_symbol_counts(const Symbol_table*, size_t*, size_t*) const = 0;
+
// Get the file. We pass on const-ness.
Input_file*
input_file()
Value
value(const Relobj* object, unsigned int input_shndx, Value addend) const
{
- Value input_offset = this->input_value_ + addend;
+ // This is a relocation against a section symbol. ADDEND is the
+ // offset in the section. The result should be the start of some
+ // merge area. If the object file wants something else, it should
+ // use a regular symbol rather than a section symbol.
+ // Unfortunately, PR 6658 shows a case in which the object file
+ // refers to the section symbol, but uses a negative ADDEND to
+ // compensate for a PC relative reloc. We can't handle the
+ // general case. However, we can handle the special case of a
+ // negative addend, by assuming that it refers to the start of the
+ // section. Of course, that means that we have to guess when
+ // ADDEND is negative. It is normal to see a 32-bit value here
+ // even when the template parameter size is 64, as 64-bit object
+ // file formats have 32-bit relocations. We know this is a merge
+ // section, so we know it has to fit into memory. So we assume
+ // that we won't see a value larger than a large 32-bit unsigned
+ // value. This will break objects with very very large merge
+ // sections; they probably break in other ways anyhow.
+ Value input_offset = this->input_value_;
+ if (addend < 0xffffff00)
+ {
+ input_offset += addend;
+ addend = 0;
+ }
typename Output_addresses::const_iterator p =
this->output_addresses_.find(input_offset);
if (p != this->output_addresses_.end())
- return p->second;
+ return p->second + addend;
- return this->value_from_output_section(object, input_shndx, input_offset);
+ return (this->value_from_output_section(object, input_shndx, input_offset)
+ + addend);
}
private:
typedef std::vector<Symbol*> Symbols;
typedef std::vector<Symbol_value<size> > Local_values;
+ static const Address invalid_address = static_cast<Address>(0) - 1;
+
Sized_relobj(const std::string& name, Input_file* input_file, off_t offset,
const typename elfcpp::Ehdr<size, big_endian>&);
Xindex*
do_initialize_xindex();
+ // Get symbol counts.
+ void
+ do_get_global_symbol_counts(const Symbol_table*, size_t*, size_t*) const;
+
// Get the offset of a section.
uint64_t
do_output_section_offset(unsigned int shndx) const
- { return this->get_output_section_offset(shndx); }
+ {
+ Address off = this->get_output_section_offset(shndx);
+ if (off == invalid_address)
+ return -1ULL;
+ return off;
+ }
// Set the offset of a section.
void
unsigned int output_local_dynsym_count_;
// The entries in the symbol table for the external symbols.
Symbols symbols_;
+ // Number of symbols defined in object file itself.
+ size_t defined_count_;
// File offset for local symbols.
off_t local_symbol_offset_;
// File offset for local dynamic symbols.
// for TLS symbols, indexed by symbol number.
Local_got_offsets local_got_offsets_;
// For each input section, the offset of the input section in its
- // output section. This is -1U if the input section requires a
+ // output section. This is INVALID_ADDRESS if the input section requires a
// special mapping.
std::vector<Address> section_offsets_;
// Table mapping discarded comdat sections to corresponding kept sections.
{
public:
Input_objects()
- : relobj_list_(), dynobj_list_(), sonames_(), system_library_directory_()
+ : relobj_list_(), dynobj_list_(), sonames_(), system_library_directory_(),
+ cref_(NULL)
{ }
// The type of the list of input relocateable objects.
bool
add_object(Object*);
+ // Start processing an archive.
+ void
+ archive_start(Archive*);
+
+ // Stop processing an archive.
+ void
+ archive_stop(Archive*);
+
// For each dynamic object, check whether we've seen all of its
// explicit dependencies.
void
bool
found_in_system_library_directory(const Object*) const;
+ // Print symbol counts.
+ void
+ print_symbol_counts(const Symbol_table*) const;
+
// Iterate over all regular objects.
Relobj_iterator
Unordered_set<std::string> sonames_;
// The directory in which we find the libc.so.
std::string system_library_directory_;
+ // Manage cross-references if requested.
+ Cref* cref_;
};
// Some of the information we pass to the relocation routines. We