aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-09-22 04:40:13 +0000
committerIan Lance Taylor <iant@google.com>2007-09-22 04:40:13 +0000
commit306d9ef0484f1928594ce309c1239252fd4915c8 (patch)
tree23ed56da78445866e545f0a6c0c1cc049fc3c2de /gold
parentcddcc9d6b0533693e0971bad3d409c22c69056fa (diff)
downloadgdb-306d9ef0484f1928594ce309c1239252fd4915c8.zip
gdb-306d9ef0484f1928594ce309c1239252fd4915c8.tar.gz
gdb-306d9ef0484f1928594ce309c1239252fd4915c8.tar.bz2
Canonicalize name and version when working with special symbols.
Diffstat (limited to 'gold')
-rw-r--r--gold/symtab.cc32
-rw-r--r--gold/symtab.h4
2 files changed, 21 insertions, 15 deletions
diff --git a/gold/symtab.cc b/gold/symtab.cc
index d29f751..a6e7958 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -667,12 +667,12 @@ Symbol_table::add_from_dynobj(
// Create and return a specially defined symbol. If ONLY_IF_REF is
// true, then only create the symbol if there is a reference to it.
// If this does not return NULL, it sets *POLDSYM to the existing
-// symbol if there is one.
+// symbol if there is one. This canonicalizes *PNAME and *PVERSION.
template<int size, bool big_endian>
Sized_symbol<size>*
-Symbol_table::define_special_symbol(const Target* target, const char* name,
- const char* version, bool only_if_ref,
+Symbol_table::define_special_symbol(const Target* target, const char** pname,
+ const char** pversion, bool only_if_ref,
Sized_symbol<size>** poldsym
ACCEPT_SIZE_ENDIAN)
{
@@ -685,19 +685,22 @@ Symbol_table::define_special_symbol(const Target* target, const char* name,
if (only_if_ref)
{
- oldsym = this->lookup(name, version);
+ oldsym = this->lookup(*pname, *pversion);
if (oldsym == NULL || !oldsym->is_undefined())
return NULL;
+
+ *pname = oldsym->name();
+ *pversion = oldsym->version();
}
else
{
// Canonicalize NAME and VERSION.
Stringpool::Key name_key;
- name = this->namepool_.add(name, &name_key);
+ *pname = this->namepool_.add(*pname, &name_key);
Stringpool::Key version_key = 0;
- if (version != NULL)
- version = this->namepool_.add(version, &version_key);
+ if (*pversion != NULL)
+ *pversion = this->namepool_.add(*pversion, &version_key);
Symbol* const snull = NULL;
std::pair<typename Symbol_table_type::iterator, bool> ins =
@@ -812,7 +815,7 @@ Symbol_table::do_define_in_output_data(
{
#if defined(HAVE_TARGET_32_BIG) || defined(HAVE_TARGET_64_BIG)
sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, true) (
- target, name, version, only_if_ref, &oldsym
+ target, &name, &version, only_if_ref, &oldsym
SELECT_SIZE_ENDIAN(size, true));
#else
gold_unreachable();
@@ -822,7 +825,7 @@ Symbol_table::do_define_in_output_data(
{
#if defined(HAVE_TARGET_32_LITTLE) || defined(HAVE_TARGET_64_LITTLE)
sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, false) (
- target, name, version, only_if_ref, &oldsym
+ target, &name, &version, only_if_ref, &oldsym
SELECT_SIZE_ENDIAN(size, false));
#else
gold_unreachable();
@@ -832,6 +835,7 @@ Symbol_table::do_define_in_output_data(
if (sym == NULL)
return NULL;
+ gold_assert(version == NULL);
sym->init(name, od, value, symsize, type, binding, visibility, nonvis,
offset_is_from_end);
@@ -904,16 +908,17 @@ Symbol_table::do_define_in_output_segment(
if (target->is_big_endian())
sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, true) (
- target, name, version, only_if_ref, &oldsym
+ target, &name, &version, only_if_ref, &oldsym
SELECT_SIZE_ENDIAN(size, true));
else
sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, false) (
- target, name, version, only_if_ref, &oldsym
+ target, &name, &version, only_if_ref, &oldsym
SELECT_SIZE_ENDIAN(size, false));
if (sym == NULL)
return NULL;
+ gold_assert(version == NULL);
sym->init(name, os, value, symsize, type, binding, visibility, nonvis,
offset_base);
@@ -980,16 +985,17 @@ Symbol_table::do_define_as_constant(
if (target->is_big_endian())
sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, true) (
- target, name, version, only_if_ref, &oldsym
+ target, &name, &version, only_if_ref, &oldsym
SELECT_SIZE_ENDIAN(size, true));
else
sym = this->define_special_symbol SELECT_SIZE_ENDIAN_NAME(size, false) (
- target, name, version, only_if_ref, &oldsym
+ target, &name, &version, only_if_ref, &oldsym
SELECT_SIZE_ENDIAN(size, false));
if (sym == NULL)
return NULL;
+ gold_assert(version == NULL);
sym->init(name, value, symsize, type, binding, visibility, nonvis);
if (oldsym != NULL
diff --git a/gold/symtab.h b/gold/symtab.h
index 31a656e..6d9a609 100644
--- a/gold/symtab.h
+++ b/gold/symtab.h
@@ -927,8 +927,8 @@ class Symbol_table
// Define a special symbol.
template<int size, bool big_endian>
Sized_symbol<size>*
- define_special_symbol(const Target* target, const char* name,
- const char* version, bool only_if_ref,
+ define_special_symbol(const Target* target, const char** pname,
+ const char** pversion, bool only_if_ref,
Sized_symbol<size>** poldsym ACCEPT_SIZE_ENDIAN);
// Define a symbol in an Output_data, sized version.