Fix group signature handling for relocatable link, add bootstrap
[binutils-gdb.git] / gold / layout.h
index d7f59650432e928ec0e1cb3a3ada4077a5d46d17..674956e68891751fac9a47569897b33ad0016370 100644 (file)
@@ -100,6 +100,29 @@ class Layout
         const char* name, const elfcpp::Shdr<size, big_endian>& shdr,
         unsigned int reloc_shndx, unsigned int reloc_type, off_t* offset);
 
+  // Layout an input reloc section when doing a relocatable link.  The
+  // section is RELOC_SHNDX in OBJECT, with data in SHDR.
+  // DATA_SECTION is the reloc section to which it refers.  RR is the
+  // relocatable information.
+  template<int size, bool big_endian>
+  Output_section*
+  layout_reloc(Sized_relobj<size, big_endian>* object,
+              unsigned int reloc_shndx,
+              const elfcpp::Shdr<size, big_endian>& shdr,
+              Output_section* data_section,
+              Relocatable_relocs* rr);
+
+  // Layout a group section when doing a relocatable link.
+  template<int size, bool big_endian>
+  void
+  layout_group(Symbol_table* symtab,
+              Sized_relobj<size, big_endian>* object,
+              unsigned int group_shndx,
+              const char* group_section_name,
+              const char* signature,
+              const elfcpp::Shdr<size, big_endian>& shdr,
+              const elfcpp::Elf_Word* contents);
+
   // Like layout, only for exception frame sections.  OBJECT is an
   // object file.  SYMBOLS is the contents of the symbol table
   // section, with size SYMBOLS_SIZE.  SYMBOL_NAMES is the contents of
@@ -148,6 +171,10 @@ class Layout
   define_script_symbols(Symbol_table* symtab)
   { this->script_options_->add_symbols_to_table(symtab); }
 
+  // Define symbols for group signatures.
+  void
+  define_group_signatures(Symbol_table*);
+
   // Return the Stringpool used for symbol names.
   const Stringpool*
   sympool() const
@@ -309,6 +336,25 @@ class Layout
   static const Linkonce_mapping linkonce_mapping[];
   static const int linkonce_mapping_count;
 
+  // During a relocatable link, a list of group sections and
+  // signatures.
+  struct Group_signature
+  {
+    // The group section.
+    Output_section* section;
+    // The signature.
+    const char* signature;
+
+    Group_signature()
+      : section(NULL), signature(NULL)
+    { }
+
+    Group_signature(Output_section* sectiona, const char* signaturea)
+      : section(sectiona), signature(signaturea)
+    { }
+  };
+  typedef std::vector<Group_signature> Group_signatures;
+
   // Create a .note section for gold.
   void
   create_gold_note();
@@ -413,6 +459,11 @@ class Layout
   off_t
   set_segment_offsets(const Target*, Output_segment*, unsigned int* pshndx);
 
+  // Set the file offsets of the sections when doing a relocatable
+  // link.
+  off_t
+  set_relocatable_section_offsets(Output_data*, unsigned int* pshndx);
+
   // Set the final file offsets of all the sections not associated
   // with a segment.  We set section offsets in three passes: the
   // first handles all allocated sections, the second sections that
@@ -509,6 +560,8 @@ class Layout
   Eh_frame* eh_frame_data_;
   // The exception frame header output section if there is one.
   Output_section* eh_frame_hdr_section_;
+  // A list of group sections and their signatures.
+  Group_signatures group_signatures_;
   // The size of the output file.
   off_t output_file_size_;
   // Whether we have seen an object file marked to require an