* layout.cc (Layout::include_section): Check for SHF_EXCLUDE.
authorCary Coutant <ccoutant@google.com>
Fri, 5 Dec 2008 21:13:35 +0000 (21:13 +0000)
committerCary Coutant <ccoutant@google.com>
Fri, 5 Dec 2008 21:13:35 +0000 (21:13 +0000)
Handle --strip-lto-sections option.
* options.h (strip_lto_sections): New option.

gold/ChangeLog
gold/layout.cc
gold/options.h

index da757f09109082ca57c777176c0c5569b858f2ca..7d0d9cc59071162e849faebb33d5023a59ff699f 100644 (file)
@@ -1,3 +1,9 @@
+2008-12-05  Cary Coutant  <ccoutant@google.com>
+
+       * layout.cc (Layout::include_section): Check for SHF_EXCLUDE.
+       Handle --strip-lto-sections option.
+       * options.h (strip_lto_sections): New option.
+
 2008-12-01  Cary Coutant  <ccoutant@google.com>
 
        * plugin.cc (ld_plugin_message): Change format parameter to const.
index ec9654e0eefa97fd6a78d112e43dd451bfdb7076..2097b6de7df2fc2668a1bf90bfcfd12003262b77 100644 (file)
@@ -206,6 +206,9 @@ bool
 Layout::include_section(Sized_relobj<size, big_endian>*, const char* name,
                        const elfcpp::Shdr<size, big_endian>& shdr)
 {
+  if (shdr.get_sh_flags() & elfcpp::SHF_EXCLUDE)
+    return false;
+
   switch (shdr.get_sh_type())
     {
     case elfcpp::SHT_NULL:
@@ -256,6 +259,14 @@ Layout::include_section(Sized_relobj<size, big_endian>*, const char* name,
               && !is_gdb_debug_section(name))
            return false;
        }
+      if (parameters->options().strip_lto_sections()
+          && !parameters->options().relocatable()
+          && (shdr.get_sh_flags() & elfcpp::SHF_ALLOC) == 0)
+        {
+          // Ignore LTO sections containing intermediate code.
+          if (is_prefix_of(".gnu.lto_", name))
+            return false;
+        }
       return true;
 
     default:
index be08d99050a400d9a3d820c5e546373c032f1c7b..f92184f6751e4e4350773d589456e82583ec6056 100644 (file)
@@ -748,6 +748,8 @@ class General_options
   DEFINE_bool(strip_debug_gdb, options::TWO_DASHES, '\0', false,
               N_("Strip debug symbols that are unused by gdb "
                  "(at least versions <= 6.7)"), NULL);
+  DEFINE_bool(strip_lto_sections, options::TWO_DASHES, '\0', true,
+              N_("Strip LTO intermediate code sections"), NULL);
 
   DEFINE_bool(shared, options::ONE_DASH, '\0', false,
               N_("Generate shared library"), NULL);