bfd/
[deliverable/binutils-gdb.git] / gold / object.h
index b2f470605cf6e9f9097fd3653ba462e013268766..2df04abad85b64d28a357735a969e18efefbea3e 100644 (file)
@@ -3,7 +3,6 @@
 #ifndef GOLD_OBJECT_H
 #define GOLD_OBJECT_H
 
-#include <cassert>
 #include <string>
 #include <vector>
 
@@ -141,6 +140,27 @@ class Object
   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)
@@ -158,17 +178,6 @@ class Object
   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.
@@ -233,11 +242,15 @@ class Object
   // 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*
@@ -272,11 +285,6 @@ class Object
   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)
@@ -324,8 +332,8 @@ template<int size, bool big_endian>
 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_);
 }
 
@@ -365,23 +373,23 @@ class Relobj : public Object
 
   // 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;
   }
 
@@ -429,10 +437,10 @@ class Relobj : public Object
 
 // 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;
 }
@@ -460,8 +468,8 @@ class Sized_relobj : public Relobj
   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];
   }
 
@@ -506,6 +514,11 @@ class Sized_relobj : public Relobj
   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()
@@ -587,7 +600,7 @@ class Input_objects
 {
  public:
   Input_objects()
-    : relobj_list_(), target_(NULL)
+    : relobj_list_(), dynobj_list_(), target_(NULL), sonames_()
   { }
 
   // The type of the list of input relocateable objects.
@@ -598,8 +611,9 @@ class Input_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.
@@ -636,9 +650,14 @@ class Input_objects
   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
This page took 0.024957 seconds and 4 git commands to generate.