Allow target to decide whether to include a section.
authorCary Coutant <ccoutant@google.com>
Tue, 15 Apr 2014 18:24:30 +0000 (11:24 -0700)
committerCary Coutant <ccoutant@google.com>
Tue, 15 Apr 2014 18:56:18 +0000 (11:56 -0700)
2014-04-15  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>

gold/
* layout.cc (Layout::include_section): Allow a target to decide
whether to include a section.
* target.h (Target::should_include_section): New function.
(Target::do_should_include_section): New function.

gold/ChangeLog
gold/layout.cc
gold/target.h

index 4ddef9a37d7eef7093810e924134b932935a9f4a..f1fea46986b12e1a23f5e966bf7bc0f38896dbb1 100644 (file)
@@ -1,3 +1,10 @@
+2014-04-15  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>
+
+       * layout.cc (Layout::include_section): Allow a target to decide
+       whether to include a section.
+       * target.h (Target::should_include_section): New function.
+       (Target::do_should_include_section): New function.
+
 2014-04-15  Sasa Stankovic  <Sasa.Stankovic@imgtec.com>
 
        * copy-relocs.cc (Copy_relocs::Copy_reloc_entry::emit): Remove and
index c96516c053d8a1df9f9bfbdd7492ff19c4d3954d..02f691edf1e1439647131c02a942f6bafa546188 100644 (file)
@@ -644,7 +644,13 @@ Layout::include_section(Sized_relobj_file<size, big_endian>*, const char* name,
       && (shdr.get_sh_flags() & elfcpp::SHF_EXCLUDE))
     return false;
 
-  switch (shdr.get_sh_type())
+  elfcpp::Elf_Word sh_type = shdr.get_sh_type();
+
+  if ((sh_type >= elfcpp::SHT_LOOS && sh_type <= elfcpp::SHT_HIOS)
+      || (sh_type >= elfcpp::SHT_LOPROC && sh_type <= elfcpp::SHT_HIPROC))
+    return parameters->target().should_include_section(sh_type);
+
+  switch (sh_type)
     {
     case elfcpp::SHT_NULL:
     case elfcpp::SHT_SYMTAB:
index aaf4b1ccaabb1a01769c7de70c69ff875ad811bd..e3805910301f392275bab8b0872a4ceb8e0c74bc 100644 (file)
@@ -480,6 +480,11 @@ class Target
   adjust_dyn_symbol(const Symbol* sym, unsigned char* view) const
   { this->do_adjust_dyn_symbol(sym, view); }
 
+  // Return whether to include the section in the link.
+  bool
+  should_include_section(elfcpp::Elf_Word sh_type) const
+  { return this->do_should_include_section(sh_type); }
+
  protected:
   // This struct holds the constant information for a child class.  We
   // use a struct to avoid the overhead of virtual function calls for
@@ -773,6 +778,11 @@ class Target
   do_adjust_dyn_symbol(const Symbol*, unsigned char*) const
   { }
 
+  // This may be overridden by the child class.
+  virtual bool
+  do_should_include_section(elfcpp::Elf_Word) const
+  { return true; }
+
  private:
   // The implementations of the four do_make_elf_object virtual functions are
   // almost identical except for their sizes and endianness.  We use a template.
This page took 0.033883 seconds and 4 git commands to generate.