Revert bfd part of "Silence gcc-8 warnings"
[deliverable/binutils-gdb.git] / gold / layout.h
index aec0c53be778d890bf8213b58203fac44606f8d7..806f6e53b01ac28650e6bdddb5b5d371e21873d8 100644 (file)
@@ -1,6 +1,6 @@
 // layout.h -- lay out output file sections for gold  -*- C++ -*-
 
-// Copyright (C) 2006-2015 Free Software Foundation, Inc.
+// Copyright (C) 2006-2018 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -66,6 +66,10 @@ struct Timespec;
 extern bool
 is_compressed_debug_section(const char* secname);
 
+// Return the name of the corresponding uncompressed debug section.
+extern std::string
+corresponding_uncompressed_section_name(std::string secname);
+
 // Maintain a list of free space within a section, segment, or file.
 // Used for incremental update links.
 
@@ -418,9 +422,21 @@ enum Output_section_order
   // The PLT.
   ORDER_PLT,
 
+  // The hot text sections, prefixed by .text.hot.
+  ORDER_TEXT_HOT,
+
   // The regular text sections.
   ORDER_TEXT,
 
+  // The startup text sections, prefixed by .text.startup.
+  ORDER_TEXT_STARTUP,
+
+  // The startup text sections, prefixed by .text.startup.
+  ORDER_TEXT_EXIT,
+
+  // The unlikely text sections, prefixed by .text.unlikely.
+  ORDER_TEXT_UNLIKELY,
+
   // The .fini section.
   ORDER_FINI,
 
@@ -521,7 +537,8 @@ class Layout
   Output_section*
   layout(Sized_relobj_file<size, big_endian> *object, unsigned int shndx,
         const char* name, const elfcpp::Shdr<size, big_endian>& shdr,
-        unsigned int reloc_shndx, unsigned int reloc_type, off_t* offset);
+        unsigned int sh_type, unsigned int reloc_shndx,
+        unsigned int reloc_type, off_t* offset);
 
   std::map<Section_id, unsigned int>*
   get_section_order_map()
@@ -535,7 +552,7 @@ class Layout
   // and ALIGN are the extra flags and alignment of the segment.
   struct Unique_segment_info
   {
-    // Identifier for the segment.  ELF segments dont have names.  This
+    // Identifier for the segment.  ELF segments don't have names.  This
     // is used as the name of the output section mapped to the segment.
     const char* name;
     // Additional segment flags.
@@ -635,6 +652,12 @@ class Layout
                  unsigned int reloc_shndx, unsigned int reloc_type,
                  off_t* offset);
 
+  // After processing all input files, we call this to make sure that
+  // the optimized .eh_frame sections have been added to the output
+  // section.
+  void
+  finalize_eh_frame_section();
+
   // Add .eh_frame information for a PLT.  The FDE must start with a
   // 4-byte PC-relative reference to the start of the PLT, followed by
   // a 4-byte size of PLT.
@@ -643,6 +666,13 @@ class Layout
                       size_t cie_length, const unsigned char* fde_data,
                       size_t fde_length);
 
+  // Remove .eh_frame information for a PLT.  FDEs using the CIE must
+  // be removed in reverse order to the order they were added.
+  void
+  remove_eh_frame_for_plt(Output_data* plt, const unsigned char* cie_data,
+                         size_t cie_length, const unsigned char* fde_data,
+                         size_t fde_length);
+
   // Scan a .debug_info or .debug_types section, and add summary
   // information to the .gdb_index section.
   template<int size, bool big_endian>
@@ -754,7 +784,8 @@ class Layout
            || 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);
+           || strncmp(name, ".stab", sizeof(".stab") - 1) == 0
+           || strncmp(name, ".pdr", sizeof(".pdr") - 1) == 0);
   }
 
   // Return true if RELOBJ is an input file whose base name matches
@@ -891,16 +922,13 @@ class Layout
                          const Output_data_reloc_generic* dyn_rel,
                          bool add_debug, bool dynrel_includes_plt);
 
-  // If a treehash is necessary to compute the build ID, then queue
-  // the necessary tasks and return a blocker that will unblock when
-  // they finish.  Otherwise return BUILD_ID_BLOCKER.
-  Task_token*
-  queue_build_id_tasks(Workqueue* workqueue, Task_token* build_id_blocker,
-                      Output_file* of);
+  // Add a target-specific dynamic tag with constant value.
+  void
+  add_target_specific_dynamic_tag(elfcpp::DT tag, unsigned int val);
 
   // Compute and write out the build ID if needed.
   void
-  write_build_id(Output_file*) const;
+  write_build_id(Output_file*, unsigned char*, size_t) const;
 
   // Rewrite output file in binary format.
   void
@@ -1000,6 +1028,14 @@ class Layout
   };
   static const Section_name_mapping section_name_mapping[];
   static const int section_name_mapping_count;
+  static const Section_name_mapping text_section_name_mapping[];
+  static const int text_section_name_mapping_count;
+
+  // Find section name NAME in map and return the mapped name if found
+  // with the length set in PLEN.
+  static const char* match_section_name(const Section_name_mapping* map,
+                                       const int count, const char* name,
+                                       size_t* plen);
 
   // During a relocatable link, a list of group sections and
   // signatures.
@@ -1029,9 +1065,9 @@ class Layout
   void
   create_gold_note();
 
-  // Record whether the stack must be executable.
+  // Record whether the stack must be executable, and a user-supplied size.
   void
-  create_executable_stack_info();
+  create_stack_segment();
 
   // Create a build ID note if needed.
   void
@@ -1059,7 +1095,7 @@ class Layout
   // Create the output sections for the symbol table.
   void
   create_symtab_sections(const Input_objects*, Symbol_table*,
-                        unsigned int, off_t*);
+                        unsigned int, off_t*, unsigned int);
 
   // Create the .shstrtab section.
   Output_section*
@@ -1074,6 +1110,7 @@ class Layout
   create_dynamic_symtab(const Input_objects*, Symbol_table*,
                        Output_section** pdynstr,
                        unsigned int* plocal_dynamic_count,
+                       unsigned int* pforced_local_dynamic_count,
                        std::vector<Symbol*>* pdynamic_symbols,
                        Versions* versions);
 
@@ -1141,7 +1178,7 @@ class Layout
   choose_output_section(const Relobj* relobj, const char* name,
                        elfcpp::Elf_Word type, elfcpp::Elf_Xword flags,
                        bool is_input_section, Output_section_order order,
-                       bool is_relro);
+                       bool is_relro, bool is_reloc, bool match_input_spec);
 
   // Create a new Output_section.
   Output_section*
@@ -1374,12 +1411,6 @@ class Layout
   Gdb_index* gdb_index_data_;
   // The space for the build ID checksum if there is one.
   Output_section_data* build_id_note_;
-  // Temporary storage for tree hash of build ID.
-  unsigned char* array_of_hashes_;
-  // Size of array_of_hashes_ (in bytes).
-  size_t size_of_array_of_hashes_;
-  // Input view for computing tree hash of build ID.  Freed in write_build_id().
-  const unsigned char* input_view_;
   // The output section containing dwarf abbreviations
   Output_reduced_debug_abbrev_section* debug_abbrev_;
   // The output section containing the dwarf debug info tree
@@ -1596,14 +1627,40 @@ class Write_after_input_sections_task : public Task
   Task_token* final_blocker_;
 };
 
+// This task function handles computation of the build id.
+// When using --build-id=tree, it schedules the tasks that
+// compute the hashes for each chunk of the file. This task
+// cannot run until we have finalized the size of the output
+// file, after the completion of Write_after_input_sections_task.
+
+class Build_id_task_runner : public Task_function_runner
+{
+ public:
+  Build_id_task_runner(const General_options* options, const Layout* layout,
+                      Output_file* of)
+    : options_(options), layout_(layout), of_(of)
+  { }
+
+  // Run the operation.
+  void
+  run(Workqueue*, const Task*);
+
+ private:
+  const General_options* options_;
+  const Layout* layout_;
+  Output_file* of_;
+};
+
 // This task function handles closing the file.
 
 class Close_task_runner : public Task_function_runner
 {
  public:
   Close_task_runner(const General_options* options, const Layout* layout,
-                   Output_file* of)
-    : options_(options), layout_(layout), of_(of)
+                   Output_file* of, unsigned char* array_of_hashes,
+                   size_t size_of_hashes)
+    : options_(options), layout_(layout), of_(of),
+      array_of_hashes_(array_of_hashes), size_of_hashes_(size_of_hashes)
   { }
 
   // Run the operation.
@@ -1614,6 +1671,8 @@ class Close_task_runner : public Task_function_runner
   const General_options* options_;
   const Layout* layout_;
   Output_file* of_;
+  unsigned char* const array_of_hashes_;
+  const size_t size_of_hashes_;
 };
 
 // A small helper function to align an address.
This page took 0.026227 seconds and 4 git commands to generate.