Add Spanish translation to gold.
[binutils-gdb.git] / gold / layout.h
index 2a173d700f5a3fa80101f6dd801310a8ca3767de..ca0f89a9d4670b7fc99847b9d672ca325f5bade9 100644 (file)
@@ -1,6 +1,6 @@
 // layout.h -- lay out output file sections for gold  -*- C++ -*-
 
-// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -40,6 +40,7 @@ namespace gold
 
 class General_options;
 class Input_objects;
+class Mapfile;
 class Symbol_table;
 class Output_section_data;
 class Output_section;
@@ -48,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;
 
@@ -64,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.
@@ -82,6 +86,38 @@ class Layout_task_runner : public Task_function_runner
   Symbol_table* symtab_;
   Target* target_;
   Layout* layout_;
+  Mapfile* mapfile_;
+};
+
+// This struct holds information about the comdat or .gnu.linkonce
+// that will be kept.
+
+struct Kept_section
+{
+  Kept_section()
+    : object(NULL), shndx(0), is_group(false), group_sections(NULL)
+  { }
+  Kept_section(Relobj* a_object, unsigned int a_shndx, bool a_is_group)
+    : object(a_object), shndx(a_shndx), is_group(a_is_group),
+      group_sections(NULL)
+  { }
+
+  typedef Unordered_map<std::string, unsigned int> Comdat_group;
+
+  // The object containing the comdat or .gnu.linkonce.
+  Relobj* object;
+  // Index to the group section for comdats and the section itself for
+  // .gnu.linkonce.
+  unsigned int shndx;
+  // The Kept_sections are values of a mapping, that maps names to
+  // them.  This field is true if this struct is associated with the
+  // name of a comdat or .gnu.linkonce, false if it is associated with
+  // the name of a symbol obtained from the .gnu.linkonce.* name
+  // through some heuristics.
+  bool is_group;
+  // For comdats, a map from names of the sections in the group to
+  // indexes in OBJECT_.  NULL for .gnu.linkonce.
+  Comdat_group* group_sections;
 };
 
 // This class handles the details of laying out input sections.
@@ -158,7 +194,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*);
@@ -220,18 +256,24 @@ class Layout
   {
     // Debugging sections can only be recognized by name.
     return (strncmp(name, ".debug", sizeof(".debug") - 1) == 0
-            || strncmp(name, ".gnu.linkonce.wi.", 
+            || 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.
+  // Check if a comdat group or .gnu.linkonce section with the given
+  // NAME is selected for the link.  If there is already a section,
+  // *KEPT_SECTION is set to point to the signature and the function
+  // returns false.  Otherwise, the CANDIDATE signature is recorded
+  // for this NAME in the layout object, *KEPT_SECTION is set to the
+  // internal copy and the function return false.  In some cases, with
+  // CANDIDATE->GROUP_ being false, KEPT_SECTION can point back to
+  // CANDIDATE.
   bool
-  add_comdat(Relobj*, unsigned int, const std::string&, bool group);
+  find_or_add_kept_section(const std::string name,
+                           Kept_section* candidate,
+                           Kept_section** kept_section);
 
   // Find the given comdat signature, and return the object and section
   // index of the kept group.
@@ -334,6 +376,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;
@@ -568,19 +614,7 @@ class Layout
   static bool
   segment_precedes(const Output_segment* seg1, const Output_segment* seg2);
 
-  // A mapping used for group 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_;
-    };
+  // A mapping used for kept comdats/.gnu.linkonce group signatures.
   typedef Unordered_map<std::string, Kept_section> Signatures;
 
   // Mapping from input section name/type/flags to output section.  We
@@ -636,6 +670,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.
@@ -658,6 +694,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.