aboutsummaryrefslogtreecommitdiff
path: root/gold/symtab.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2010-08-02 13:34:33 +0000
committerIan Lance Taylor <ian@airs.com>2010-08-02 13:34:33 +0000
commit88a4108bde4d02cccd632048b45458e84bc8b40b (patch)
treee020b29ea8793617ea774963998d2de40cd349fe /gold/symtab.cc
parent93d90f466b0a6faa6a7811187139f66a2b9c9c74 (diff)
downloadgdb-88a4108bde4d02cccd632048b45458e84bc8b40b.zip
gdb-88a4108bde4d02cccd632048b45458e84bc8b40b.tar.gz
gdb-88a4108bde4d02cccd632048b45458e84bc8b40b.tar.bz2
PR 11855
* script.cc (Script_options::Script_options): Initialize symbol_definitions_ and symbol_references_. (Script_options::add_symbol_assignment): Update symbol_definitions_ and symbol_references_. (Script_options::add_symbol_reference): New function. (script_symbol): New function. * script.h (class Script_options): Add symbol_definitions_ and symbol_references_ fields. (Script_options::referenced_const_iterator): New type. (Script_options::referenced_begin): New function. (Script_options::referenced_end): New function. (Script_options::is_referenced): New function. (Script_options::any_unreferenced): New function. * script-c.h (script_symbol): Declare. * yyscript.y (exp): Call script_symbol. * symtab.cc: Include "script.h". (Symbol_table::gc_mark_undef_symbols): Add layout parameter. Change all callers. Check symbols referenced by scripts. (Symbol_table::add_undefined_symbols_from_command_line): Add layout parameter. Change all callers. (Symbol_table::do_add_undefined_symbols_from_command_line): Likewise. Break out loop body. Check symbols referenced by scripts. (Symbol_table::add_undefined_symbol_from_command_line): New function broken out of do_add_undefined_symbols_from_command_line. * symtab.h (class Symbol_table): Update declarations. * archive.cc: Include "layout.h". (Archive::should_include_member): Add layout parameter. Change all callers. Check for symbol mentioned in expression. * archive.h (class Archive): Update declaration. * object.cc (Sized_relobj::do_should_include_member): Add layout parameter. * object.h (Object::should_include_member): Add layout parameter. Change all callers. (Object::do_should_include_member): Add layout parameter. (class Sized_relobj): Update declaration. * dynobj.cc (Sized_dynobj::do_should_include_member): Add layout parameter. * dynobj.h (class Sized_dynobj): Update declaration. * plugin.cc (Sized_pluginobj::do_should_include_member): Add layout parameter. * plugin.h (class Sized_pluginobj): Update declaration.
Diffstat (limited to 'gold/symtab.cc')
-rw-r--r--gold/symtab.cc99
1 files changed, 65 insertions, 34 deletions
diff --git a/gold/symtab.cc b/gold/symtab.cc
index a29e6ad..f46d8de 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -38,7 +38,7 @@
#include "target.h"
#include "workqueue.h"
#include "symtab.h"
-#include "demangle.h" // needed for --dynamic-list-cpp-new
+#include "script.h"
#include "plugin.h"
namespace gold
@@ -530,7 +530,7 @@ Symbol_table::is_section_folded(Object* obj, unsigned int shndx) const
// work list to avoid gc'ing them.
void
-Symbol_table::gc_mark_undef_symbols()
+Symbol_table::gc_mark_undef_symbols(Layout* layout)
{
for (options::String_set::const_iterator p =
parameters->options().undefined_begin();
@@ -553,6 +553,27 @@ Symbol_table::gc_mark_undef_symbols()
}
}
}
+
+ for (Script_options::referenced_const_iterator p =
+ layout->script_options()->referenced_begin();
+ p != layout->script_options()->referenced_end();
+ ++p)
+ {
+ Symbol* sym = this->lookup(p->c_str());
+ gold_assert(sym != NULL);
+ if (sym->source() == Symbol::FROM_OBJECT
+ && !sym->object()->is_dynamic())
+ {
+ Relobj* obj = static_cast<Relobj*>(sym->object());
+ bool is_ordinary;
+ unsigned int shndx = sym->shndx(&is_ordinary);
+ if (is_ordinary)
+ {
+ gold_assert(this->gc_ != NULL);
+ this->gc_->worklist().push(Section_id(obj, shndx));
+ }
+ }
+ }
}
void
@@ -2163,14 +2184,15 @@ Symbol_table::get_copy_source(const Symbol* sym) const
// Add any undefined symbols named on the command line.
void
-Symbol_table::add_undefined_symbols_from_command_line()
+Symbol_table::add_undefined_symbols_from_command_line(Layout* layout)
{
- if (parameters->options().any_undefined())
+ if (parameters->options().any_undefined()
+ || layout->script_options()->any_unreferenced())
{
if (parameters->target().get_size() == 32)
{
#if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_32_BIG)
- this->do_add_undefined_symbols_from_command_line<32>();
+ this->do_add_undefined_symbols_from_command_line<32>(layout);
#else
gold_unreachable();
#endif
@@ -2178,7 +2200,7 @@ Symbol_table::add_undefined_symbols_from_command_line()
else if (parameters->target().get_size() == 64)
{
#if defined(HAVE_TARGET_64_LITTLE) || defined(HAVE_TARGET_64_BIG)
- this->do_add_undefined_symbols_from_command_line<64>();
+ this->do_add_undefined_symbols_from_command_line<64>(layout);
#else
gold_unreachable();
#endif
@@ -2190,50 +2212,59 @@ Symbol_table::add_undefined_symbols_from_command_line()
template<int size>
void
-Symbol_table::do_add_undefined_symbols_from_command_line()
+Symbol_table::do_add_undefined_symbols_from_command_line(Layout* layout)
{
for (options::String_set::const_iterator p =
parameters->options().undefined_begin();
p != parameters->options().undefined_end();
++p)
- {
- const char* name = p->c_str();
+ this->add_undefined_symbol_from_command_line<size>(p->c_str());
- if (this->lookup(name) != NULL)
- continue;
+ for (Script_options::referenced_const_iterator p =
+ layout->script_options()->referenced_begin();
+ p != layout->script_options()->referenced_end();
+ ++p)
+ this->add_undefined_symbol_from_command_line<size>(p->c_str());
+}
+
+template<int size>
+void
+Symbol_table::add_undefined_symbol_from_command_line(const char* name)
+{
+ if (this->lookup(name) != NULL)
+ return;
- const char* version = NULL;
+ const char* version = NULL;
- Sized_symbol<size>* sym;
- Sized_symbol<size>* oldsym;
- bool resolve_oldsym;
- if (parameters->target().is_big_endian())
- {
+ Sized_symbol<size>* sym;
+ Sized_symbol<size>* oldsym;
+ bool resolve_oldsym;
+ if (parameters->target().is_big_endian())
+ {
#if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
- sym = this->define_special_symbol<size, true>(&name, &version,
- false, &oldsym,
- &resolve_oldsym);
+ sym = this->define_special_symbol<size, true>(&name, &version,
+ false, &oldsym,
+ &resolve_oldsym);
#else
- gold_unreachable();
+ gold_unreachable();
#endif
- }
- else
- {
+ }
+ else
+ {
#if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
- sym = this->define_special_symbol<size, false>(&name, &version,
- false, &oldsym,
- &resolve_oldsym);
+ sym = this->define_special_symbol<size, false>(&name, &version,
+ false, &oldsym,
+ &resolve_oldsym);
#else
- gold_unreachable();
+ gold_unreachable();
#endif
- }
+ }
- gold_assert(oldsym == NULL);
+ gold_assert(oldsym == NULL);
- sym->init_undefined(name, version, elfcpp::STT_NOTYPE, elfcpp::STB_GLOBAL,
- elfcpp::STV_DEFAULT, 0);
- ++this->saw_undefined_;
- }
+ sym->init_undefined(name, version, elfcpp::STT_NOTYPE, elfcpp::STB_GLOBAL,
+ elfcpp::STV_DEFAULT, 0);
+ ++this->saw_undefined_;
}
// Set the dynamic symbol indexes. INDEX is the index of the first