#ifndef GOLD_OBJECT_H
#define GOLD_OBJECT_H
-#include <cassert>
#include <string>
#include <vector>
Sized_target<size, big_endian>*
sized_target(ACCEPT_SIZE_ENDIAN_ONLY);
+ // Get the number of sections.
+ unsigned int
+ shnum() const
+ { return this->shnum_; }
+
+ // Return a view of the contents of a section. Set *PLEN to the
+ // size.
+ const unsigned char*
+ section_contents(unsigned int shndx, off_t* plen);
+
+ // Return the name of a section given a section index. This is only
+ // used for error messages.
+ std::string
+ section_name(unsigned int shndx)
+ { return this->do_section_name(shndx); }
+
+ // Return the section flags given a section index.
+ uint64_t
+ section_flags(unsigned int shndx)
+ { return this->do_section_flags(shndx); }
+
// Read the symbol information.
void
read_symbols(Read_symbols_data* sd)
add_symbols(Symbol_table* symtab, Read_symbols_data* sd)
{ this->do_add_symbols(symtab, sd); }
- // Return a view of the contents of a section. Set *PLEN to the
- // size.
- const unsigned char*
- section_contents(unsigned int shndx, off_t* plen);
-
- // Return the name of a section given a section index. This is only
- // used for error messages.
- std::string
- section_name(unsigned int shnum)
- { return this->do_section_name(shnum); }
-
// Functions and types for the elfcpp::Elf_file interface. This
// permit us to use Object as the File template parameter for
// elfcpp::Elf_file.
// Return the location of the contents of a section. Implemented by
// child class.
virtual Location
- do_section_contents(unsigned int shnum) = 0;
+ do_section_contents(unsigned int shndx) = 0;
// Get the name of a section--implemented by child class.
virtual std::string
- do_section_name(unsigned int shnum) = 0;
+ do_section_name(unsigned int shndx) = 0;
+
+ // Get section flags--implemented by child class.
+ virtual uint64_t
+ do_section_flags(unsigned int shndx) = 0;
// Get the file.
Input_file*
set_target(int machine, int size, bool big_endian, int osabi,
int abiversion);
- // Get the number of sections.
- unsigned int
- shnum() const
- { return this->shnum_; }
-
// Set the number of sections.
void
set_shnum(int shnum)
inline Sized_target<size, big_endian>*
Object::sized_target(ACCEPT_SIZE_ENDIAN_ONLY)
{
- assert(this->target_->get_size() == size);
- assert(this->target_->is_big_endian() ? big_endian : !big_endian);
+ gold_assert(this->target_->get_size() == size);
+ gold_assert(this->target_->is_big_endian() ? big_endian : !big_endian);
return static_cast<Sized_target<size, big_endian>*>(this->target_);
}
// Return whether an input section is being included in the link.
bool
- is_section_included(unsigned int shnum) const
+ is_section_included(unsigned int shndx) const
{
- assert(shnum < this->map_to_output_.size());
- return this->map_to_output_[shnum].output_section != NULL;
+ gold_assert(shndx < this->map_to_output_.size());
+ return this->map_to_output_[shndx].output_section != NULL;
}
// Given a section index, return the corresponding Output_section
// (which will be NULL if the section is not included in the link)
// and set *POFF to the offset within that section.
inline Output_section*
- output_section(unsigned int shnum, off_t* poff);
+ output_section(unsigned int shndx, off_t* poff);
// Set the offset of an input section within its output section.
void
set_section_offset(unsigned int shndx, off_t off)
{
- assert(shndx < this->map_to_output_.size());
+ gold_assert(shndx < this->map_to_output_.size());
this->map_to_output_[shndx].offset = off;
}
// Implement Object::output_section inline for efficiency.
inline Output_section*
-Relobj::output_section(unsigned int shnum, off_t* poff)
+Relobj::output_section(unsigned int shndx, off_t* poff)
{
- assert(shnum < this->map_to_output_.size());
- const Map_to_output& mo(this->map_to_output_[shnum]);
+ gold_assert(shndx < this->map_to_output_.size());
+ const Map_to_output& mo(this->map_to_output_[shndx]);
*poff = mo.offset;
return mo.output_section;
}
unsigned int
symtab_index(unsigned int sym) const
{
- assert(sym < this->local_indexes_.size());
- assert(this->local_indexes_[sym] != 0);
+ gold_assert(sym < this->local_indexes_.size());
+ gold_assert(this->local_indexes_[sym] != 0);
return this->local_indexes_[sym];
}
do_section_contents(unsigned int shndx)
{ return this->elf_file_.section_contents(shndx); }
+ // Return section flags.
+ uint64_t
+ do_section_flags(unsigned int shndx)
+ { return this->elf_file_.section_flags(shndx); }
+
// Return the appropriate Sized_target structure.
Sized_target<size, big_endian>*
sized_target()
{
public:
Input_objects()
- : relobj_list_(), target_(NULL)
+ : relobj_list_(), dynobj_list_(), target_(NULL), sonames_()
{ }
// The type of the list of input relocateable objects.
typedef std::vector<Dynobj*> Dynobj_list;
typedef Dynobj_list::const_iterator Dynobj_iterator;
- // Add an object to the list.
- void
+ // Add an object to the list. Return true if all is well, or false
+ // if this object should be ignored.
+ bool
add_object(Object*);
// Get the target we should use for the output file.
Input_objects(const Input_objects&);
Input_objects& operator=(const Input_objects&);
+ // The list of ordinary objects included in the link.
Relobj_list relobj_list_;
+ // The list of dynamic objects included in the link.
Dynobj_list dynobj_list_;
+ // The target.
Target* target_;
+ // SONAMEs that we have seen.
+ Unordered_set<std::string> sonames_;
};
// Some of the information we pass to the relocation routines. We