+2009-12-30 Ian Lance Taylor <iant@google.com>
+
+ PR 10670
+ * options.h (class General_options): Add -x/--discard-all.
+ * object.cc (Sized_relobj::do_count_local_symbols): Handle
+ --discard-all. If the local symbol needs a dynamic entry, check
+ that before handling --discard-locals.
+
2009-12-30 Ian Lance Taylor <iant@google.com>
PR 10450
unsigned int dyncount = 0;
// Skip the first, dummy, symbol.
psyms += sym_size;
+ bool discard_all = parameters->options().discard_all();
bool discard_locals = parameters->options().discard_locals();
for (unsigned int i = 1; i < loccount; ++i, psyms += sym_size)
{
// Decide whether this symbol should go into the output file.
if ((shndx < shnum && out_sections[shndx] == NULL)
- || (shndx == this->discarded_eh_frame_shndx_))
+ || shndx == this->discarded_eh_frame_shndx_)
{
lv.set_no_output_symtab_entry();
gold_assert(!lv.needs_output_dynsym_entry());
continue;
}
+ const char* name = pnames + sym.get_st_name();
+
+ // If needed, add the symbol to the dynamic symbol table string pool.
+ if (lv.needs_output_dynsym_entry())
+ {
+ dynpool->add(name, true, NULL);
+ ++dyncount;
+ }
+
+ if (discard_all)
+ {
+ lv.set_no_output_symtab_entry();
+ continue;
+ }
+
// 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
// - the symbol has a name.
//
// We do not discard a symbol if it needs a dynamic symbol entry.
- const char* name = pnames + sym.get_st_name();
if (discard_locals
&& sym.get_st_type() != elfcpp::STT_FILE
&& !lv.needs_output_dynsym_entry()
// Add the symbol to the symbol table string pool.
pool->add(name, true, NULL);
++count;
-
- // If needed, add the symbol to the dynamic symbol table string pool.
- if (lv.needs_output_dynsym_entry())
- {
- dynpool->add(name, true, NULL);
- ++dyncount;
- }
}
this->output_local_symbol_count_ = count;
N_("Try to detect violations of the One Definition Rule"),
NULL);
+ DEFINE_bool(discard_all, options::TWO_DASHES, 'x', false,
+ N_("Delete all local symbols"), NULL);
DEFINE_bool(discard_locals, options::TWO_DASHES, 'X', false,
N_("Delete all temporary local symbols"), NULL);