* Makefile.am (spu_ovl.o_c): Add missing line continuations.
[binutils-gdb.git] / gold / layout.h
index efa8b61d5aa3c03d32a9bb6c42db156648cb7429..ca8b7c79cf424be2b61cc72ef08f67686938bced 100644 (file)
@@ -23,6 +23,7 @@
 #ifndef GOLD_LAYOUT_H
 #define GOLD_LAYOUT_H
 
+#include <cstring>
 #include <list>
 #include <string>
 #include <utility>
@@ -39,6 +40,7 @@ namespace gold
 
 class General_options;
 class Input_objects;
+class Mapfile;
 class Symbol_table;
 class Output_section_data;
 class Output_section;
@@ -47,6 +49,8 @@ class Output_segment;
 class Output_data;
 class Output_data_dynamic;
 class Output_symtab_xindex;
+class Output_reduced_debug_abbrev_section;
+class Output_reduced_debug_info_section;
 class Eh_frame;
 class Target;
 
@@ -63,9 +67,10 @@ class Layout_task_runner : public Task_function_runner
                     const Input_objects* input_objects,
                     Symbol_table* symtab,
                      Target* target,
-                    Layout* layout)
+                    Layout* layout,
+                    Mapfile* mapfile)
     : options_(options), input_objects_(input_objects), symtab_(symtab),
-      target_(target), layout_(layout)
+      target_(target), layout_(layout), mapfile_(mapfile)
   { }
 
   // Run the operation.
@@ -81,6 +86,7 @@ class Layout_task_runner : public Task_function_runner
   Symbol_table* symtab_;
   Target* target_;
   Layout* layout_;
+  Mapfile* mapfile_;
 };
 
 // This class handles the details of laying out input sections.
@@ -124,7 +130,8 @@ class Layout
               const char* group_section_name,
               const char* signature,
               const elfcpp::Shdr<size, big_endian>& shdr,
-              const elfcpp::Elf_Word* contents);
+              elfcpp::Elf_Word flags,
+              std::vector<unsigned int>* shndxes);
 
   // Like layout, only for exception frame sections.  OBJECT is an
   // object file.  SYMBOLS is the contents of the symbol table
@@ -156,7 +163,7 @@ class Layout
 
   // Add an Output_section_data to the layout.  This is used for
   // special sections like the GOT section.
-  void
+  Output_section*
   add_output_section_data(const char* name, elfcpp::Elf_Word type,
                          elfcpp::Elf_Xword flags,
                          Output_section_data*);
@@ -212,12 +219,29 @@ class Layout
   is_linkonce(const char* name)
   { return strncmp(name, ".gnu.linkonce", sizeof(".gnu.linkonce") - 1) == 0; }
 
+  // Return true if a section is a debugging section.
+  static inline bool
+  is_debug_info_section(const char* name)
+  {
+    // Debugging sections can only be recognized by name.
+    return (strncmp(name, ".debug", sizeof(".debug") - 1) == 0
+            || strncmp(name, ".gnu.linkonce.wi.", 
+                       sizeof(".gnu.linkonce.wi.") - 1) == 0
+            || strncmp(name, ".line", sizeof(".line") - 1) == 0
+            || strncmp(name, ".stab", sizeof(".stab") - 1) == 0);
+  }
+
   // Record the signature of a comdat section, and return whether to
   // include it in the link.  The GROUP parameter is true for a
   // section group signature, false for a signature derived from a
   // .gnu.linkonce section.
   bool
-  add_comdat(const char*, bool group);
+  add_comdat(Relobj*, unsigned int, const std::string&, bool group);
+
+  // Find the given comdat signature, and return the object and section
+  // index of the kept group.
+  Relobj*
+  find_kept_object(const std::string&, unsigned int*) const;
 
   // Finalize the layout after all the input sections have been added.
   off_t
@@ -315,6 +339,10 @@ class Layout
   void
   write_binary(Output_file* in) const;
 
+  // Print output sections to the map file.
+  void
+  print_to_mapfile(Mapfile*) const;
+
   // Dump statistical information to stderr.
   void
   print_stats() const;
@@ -550,7 +578,19 @@ class Layout
   segment_precedes(const Output_segment* seg1, const Output_segment* seg2);
 
   // A mapping used for group signatures.
-  typedef Unordered_map<std::string, bool> Signatures;
+  struct Kept_section
+    {
+      Kept_section()
+        : object_(NULL), shndx_(0), group_(false)
+      { }
+      Kept_section(Relobj* object, unsigned int shndx, bool group)
+        : object_(object), shndx_(shndx), group_(group)
+      { }
+      Relobj* object_;
+      unsigned int shndx_;
+      bool group_;
+    };
+  typedef Unordered_map<std::string, Kept_section> Signatures;
 
   // Mapping from input section name/type/flags to output section.  We
   // use canonicalized strings here.
@@ -605,6 +645,8 @@ class Layout
   Output_section_headers* section_headers_;
   // A pointer to the PT_TLS segment if there is one.
   Output_segment* tls_segment_;
+  // A pointer to the PT_GNU_RELRO segment if there is one.
+  Output_segment* relro_segment_;
   // The SHT_SYMTAB output section.
   Output_section* symtab_section_;
   // The SHT_SYMTAB_SHNDX for the regular symbol table if there is one.
@@ -627,6 +669,10 @@ class Layout
   Output_section* eh_frame_hdr_section_;
   // The space for the build ID checksum if there is one.
   Output_section_data* build_id_note_;
+  // The output section containing dwarf abbreviations
+  Output_reduced_debug_abbrev_section* debug_abbrev_;
+  // The output section containing the dwarf debug info tree
+  Output_reduced_debug_info_section* debug_info_;
   // A list of group sections and their signatures.
   Group_signatures group_signatures_;
   // The size of the output file.