aboutsummaryrefslogtreecommitdiff
path: root/gold/object.cc
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@gmail.com>2015-06-04 20:58:08 -0700
committerCary Coutant <ccoutant@gmail.com>2015-06-04 20:58:08 -0700
commitcd3c333f43f03d6e41668a82a68a99c14000a681 (patch)
tree111fa29f0aff6318e7df16f84d90003775adc8f0 /gold/object.cc
parentdc302c00611b6973fbc55e9fdd643ad24c370bd1 (diff)
downloadfsf-binutils-gdb-cd3c333f43f03d6e41668a82a68a99c14000a681.zip
fsf-binutils-gdb-cd3c333f43f03d6e41668a82a68a99c14000a681.tar.gz
fsf-binutils-gdb-cd3c333f43f03d6e41668a82a68a99c14000a681.tar.bz2
Change default to discard temporary local symbols in merge sections.
Add --discard-none to keep all local symbols. gold/ PR gold/17498 * object.cc (Sized_relobj_file::do_count_local_symbols): Discard temporary locals in merge sections. * options.cc (General_options::parse_discard_all): New method. (General_options::parse_discard_locals): New method. (General_options::parse_discard_none): New method. (General_options::General_options): Initialize discard_locals_. * options.h (--discard-all): Convert to special option. (--discard-locals): Likewise. (--discard-none): New option. (General_options::discard_all): New method. (General_options::discard_locals): New method. (General_options::discard_sec_merge): New method. (General_options::Discard_locals): New enum. (General_options::discard_locals_): New data member.
Diffstat (limited to 'gold/object.cc')
-rw-r--r--gold/object.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/gold/object.cc b/gold/object.cc
index 18c6670..4e94f7e 100644
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -2174,6 +2174,7 @@ Sized_relobj_file<size, big_endian>::do_count_local_symbols(Stringpool* pool,
// Loop over the local symbols.
const Output_sections& out_sections(this->output_sections());
+ std::vector<Address>& out_section_offsets(this->section_offsets());
unsigned int shnum = this->shnum();
unsigned int count = 0;
unsigned int dyncount = 0;
@@ -2182,6 +2183,7 @@ Sized_relobj_file<size, big_endian>::do_count_local_symbols(Stringpool* pool,
bool strip_all = parameters->options().strip_all();
bool discard_all = parameters->options().discard_all();
bool discard_locals = parameters->options().discard_locals();
+ bool discard_sec_merge = parameters->options().discard_sec_merge();
for (unsigned int i = 1; i < loccount; ++i, psyms += sym_size)
{
elfcpp::Sym<size, big_endian> sym(psyms);
@@ -2246,6 +2248,7 @@ Sized_relobj_file<size, big_endian>::do_count_local_symbols(Stringpool* pool,
continue;
}
+ // By default, discard temporary local symbols in merge sections.
// If --discard-locals option is used, discard all temporary local
// symbols. These symbols start with system-specific local label
// prefixes, typically .L for ELF system. We want to be compatible
@@ -2258,7 +2261,10 @@ Sized_relobj_file<size, big_endian>::do_count_local_symbols(Stringpool* pool,
// - the symbol has a name.
//
// We do not discard a symbol if it needs a dynamic symbol entry.
- if (discard_locals
+ if ((discard_locals
+ || (discard_sec_merge
+ && is_ordinary
+ && out_section_offsets[shndx] == invalid_address))
&& sym.get_st_type() != elfcpp::STT_FILE
&& !lv.needs_output_dynsym_entry()
&& lv.may_be_discarded_from_output_symtab()