+ // If this is a regular object, return a pointer to the Sized_relobj_file
+ // object. Otherwise, return NULL.
+ virtual Sized_relobj_file<size, big_endian>*
+ sized_relobj()
+ { return NULL; }
+
+ const virtual Sized_relobj_file<size, big_endian>*
+ sized_relobj() const
+ { return NULL; }
+
+ // Checks if the offset of input section SHNDX within its output
+ // section is invalid.
+ bool
+ is_output_section_offset_invalid(unsigned int shndx) const
+ { return this->get_output_section_offset(shndx) == invalid_address; }
+
+ // Get the offset of input section SHNDX within its output section.
+ // This is -1 if the input section requires a special mapping, such
+ // as a merge section. The output section can be found in the
+ // output_sections_ field of the parent class Relobj.
+ Address
+ get_output_section_offset(unsigned int shndx) const
+ {
+ gold_assert(shndx < this->section_offsets_.size());
+ return this->section_offsets_[shndx];
+ }
+
+ // Iterate over local symbols, calling a visitor class V for each GOT offset
+ // associated with a local symbol.
+ void
+ do_for_all_local_got_entries(Got_offset_list::Visitor* v) const;
+
+ protected:
+ typedef Relobj::Output_sections Output_sections;
+
+ // Clear the local symbol information.
+ void
+ clear_got_offsets()
+ { this->local_got_offsets_.clear(); }
+
+ // Return the vector of section offsets.
+ std::vector<Address>&
+ section_offsets()
+ { return this->section_offsets_; }
+
+ // Get the address of an output section.
+ uint64_t
+ do_output_section_address(unsigned int shndx);
+
+ // Get the offset of a section.
+ uint64_t
+ do_output_section_offset(unsigned int shndx) const
+ {
+ Address off = this->get_output_section_offset(shndx);
+ if (off == invalid_address)
+ return -1ULL;
+ return off;
+ }
+
+ // Set the offset of a section.
+ void
+ do_set_section_offset(unsigned int shndx, uint64_t off)
+ {
+ gold_assert(shndx < this->section_offsets_.size());
+ this->section_offsets_[shndx] =
+ (off == static_cast<uint64_t>(-1)
+ ? invalid_address
+ : convert_types<Address, uint64_t>(off));
+ }
+
+ // Return whether the local symbol SYMNDX plus ADDEND has a GOT offset
+ // of type GOT_TYPE.
+ bool
+ do_local_has_got_offset(unsigned int symndx, unsigned int got_type,
+ uint64_t addend) const
+ {
+ Local_got_entry_key key(symndx, addend);
+ Local_got_offsets::const_iterator p =
+ this->local_got_offsets_.find(key);
+ return (p != this->local_got_offsets_.end()
+ && p->second->get_offset(got_type) != -1U);
+ }
+
+ // Return the GOT offset of type GOT_TYPE of the local symbol
+ // SYMNDX plus ADDEND.
+ unsigned int
+ do_local_got_offset(unsigned int symndx, unsigned int got_type,
+ uint64_t addend) const
+ {
+ Local_got_entry_key key(symndx, addend);
+ Local_got_offsets::const_iterator p =
+ this->local_got_offsets_.find(key);
+ gold_assert(p != this->local_got_offsets_.end());
+ unsigned int off = p->second->get_offset(got_type);
+ gold_assert(off != -1U);
+ return off;
+ }
+
+ // Set the GOT offset with type GOT_TYPE of the local symbol SYMNDX
+ // plus ADDEND to GOT_OFFSET.
+ void
+ do_set_local_got_offset(unsigned int symndx, unsigned int got_type,
+ unsigned int got_offset, uint64_t addend)
+ {
+ Local_got_entry_key key(symndx, addend);
+ Local_got_offsets::const_iterator p =
+ this->local_got_offsets_.find(key);
+ if (p != this->local_got_offsets_.end())
+ p->second->set_offset(got_type, got_offset);
+ else
+ {
+ Got_offset_list* g = new Got_offset_list(got_type, got_offset);
+ std::pair<Local_got_offsets::iterator, bool> ins =
+ this->local_got_offsets_.insert(std::make_pair(key, g));
+ gold_assert(ins.second);
+ }
+ }
+
+ // Return the word size of the object file.
+ virtual int
+ do_elfsize() const
+ { return size; }
+
+ // Return TRUE if this is a big-endian object file.
+ virtual bool
+ do_is_big_endian() const
+ { return big_endian; }
+
+ private:
+ // The GOT offsets of local symbols. This map also stores GOT offsets
+ // for tp-relative offsets for TLS symbols.
+ typedef Unordered_map<Local_got_entry_key, Got_offset_list*,
+ Local_got_entry_key::hash,
+ Local_got_entry_key::equal_to> Local_got_offsets;
+
+ // GOT offsets for local non-TLS symbols, and tp-relative offsets
+ // for TLS symbols, indexed by local got entry key class.
+ Local_got_offsets local_got_offsets_;
+ // For each input section, the offset of the input section in its
+ // output section. This is INVALID_ADDRESS if the input section requires a
+ // special mapping.
+ std::vector<Address> section_offsets_;
+};
+
+// A regular object file. This is size and endian specific.
+
+template<int size, bool big_endian>
+class Sized_relobj_file : public Sized_relobj<size, big_endian>
+{
+ public:
+ typedef typename elfcpp::Elf_types<size>::Elf_Addr Address;
+ typedef typename Sized_relobj<size, big_endian>::Symbols Symbols;
+ typedef std::vector<Symbol_value<size> > Local_values;
+
+ static const Address invalid_address = static_cast<Address>(0) - 1;
+
+ enum Compute_final_local_value_status
+ {
+ // No error.
+ CFLV_OK,
+ // An error occurred.
+ CFLV_ERROR,
+ // The local symbol has no output section.
+ CFLV_DISCARDED
+ };
+
+ Sized_relobj_file(const std::string& name,
+ Input_file* input_file,
+ off_t offset,
+ const typename elfcpp::Ehdr<size, big_endian>&);
+
+ ~Sized_relobj_file();
+
+ // Set up the object file based on TARGET.
+ void
+ setup()
+ { this->do_setup(); }
+
+ // Return a pointer to the Sized_relobj_file object.
+ Sized_relobj_file<size, big_endian>*
+ sized_relobj()
+ { return this; }
+
+ const Sized_relobj_file<size, big_endian>*
+ sized_relobj() const
+ { return this; }
+
+ // Return the ELF file type.
+ int
+ e_type() const
+ { return this->e_type_; }
+
+ // Return the number of symbols. This is only valid after
+ // Object::add_symbols has been called.
+ unsigned int
+ symbol_count() const
+ { return this->local_symbol_count_ + this->symbols_.size(); }
+
+ // If SYM is the index of a global symbol in the object file's