From fd06b4aa51e5e4b322f4784e3ea248e25aab733a Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Fri, 5 Dec 2008 21:13:35 +0000 Subject: [PATCH] * layout.cc (Layout::include_section): Check for SHF_EXCLUDE. Handle --strip-lto-sections option. * options.h (strip_lto_sections): New option. --- gold/ChangeLog | 6 ++++++ gold/layout.cc | 11 +++++++++++ gold/options.h | 2 ++ 3 files changed, 19 insertions(+) diff --git a/gold/ChangeLog b/gold/ChangeLog index da757f09109..7d0d9cc5907 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,9 @@ +2008-12-05 Cary Coutant + + * 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 * plugin.cc (ld_plugin_message): Change format parameter to const. diff --git a/gold/layout.cc b/gold/layout.cc index ec9654e0eef..2097b6de7df 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -206,6 +206,9 @@ bool Layout::include_section(Sized_relobj*, const char* name, const elfcpp::Shdr& 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*, 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: diff --git a/gold/options.h b/gold/options.h index be08d99050a..f92184f6751 100644 --- a/gold/options.h +++ b/gold/options.h @@ -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); -- 2.30.2