aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2009-12-30 20:23:29 +0000
committerIan Lance Taylor <ian@airs.com>2009-12-30 20:23:29 +0000
commitebcc83046fa1227ac895ae9a2d715b547d62ad08 (patch)
tree954725e482503e8a0f81d1963e57408fe353fe63
parent7b838ca220ab177d288bca2629d73b50ebbe7abc (diff)
downloadgdb-ebcc83046fa1227ac895ae9a2d715b547d62ad08.zip
gdb-ebcc83046fa1227ac895ae9a2d715b547d62ad08.tar.gz
gdb-ebcc83046fa1227ac895ae9a2d715b547d62ad08.tar.bz2
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.
-rw-r--r--gold/ChangeLog8
-rw-r--r--gold/object.cc26
-rw-r--r--gold/options.h2
3 files changed, 27 insertions, 9 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 12dc7f0..ea16c7a 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,13 @@
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
* output.cc (Output_segment::Output_segment): If PT_TLS, set the
flags to PF_R.
diff --git a/gold/object.cc b/gold/object.cc
index efcb26b..34b59b5 100644
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -1527,6 +1527,7 @@ Sized_relobj<size, big_endian>::do_count_local_symbols(Stringpool* pool,
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)
{
@@ -1550,7 +1551,7 @@ Sized_relobj<size, big_endian>::do_count_local_symbols(Stringpool* pool,
// 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());
@@ -1573,6 +1574,21 @@ Sized_relobj<size, big_endian>::do_count_local_symbols(Stringpool* pool,
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
@@ -1585,7 +1601,6 @@ Sized_relobj<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.
- const char* name = pnames + sym.get_st_name();
if (discard_locals
&& sym.get_st_type() != elfcpp::STT_FILE
&& !lv.needs_output_dynsym_entry()
@@ -1606,13 +1621,6 @@ Sized_relobj<size, big_endian>::do_count_local_symbols(Stringpool* pool,
// 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;
diff --git a/gold/options.h b/gold/options.h
index 399c301..be7b018 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -654,6 +654,8 @@ class General_options
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);