aboutsummaryrefslogtreecommitdiff
path: root/gold/symtab.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2011-06-28 05:39:45 +0000
committerIan Lance Taylor <ian@airs.com>2011-06-28 05:39:45 +0000
commit6d1c4efb9c89fcaca4c24f0ef0535a706136d544 (patch)
tree0500c7bbf28bf9151513779d517f6cab15e2e0c7 /gold/symtab.cc
parent0f4e53222c59f75a57ffa474f21de70b7d27c16f (diff)
downloadgdb-6d1c4efb9c89fcaca4c24f0ef0535a706136d544.zip
gdb-6d1c4efb9c89fcaca4c24f0ef0535a706136d544.tar.gz
gdb-6d1c4efb9c89fcaca4c24f0ef0535a706136d544.tar.bz2
* symtab.cc (Symbol::versioned_name): New function.
(Symbol_table::add_to_final_symtab): Use versioned_name when appropriate. (Symbol_table::sized_write_symbol): Likewise. * symtab.h (class Symbol): Declare versioned_name. * stringpool.h (class Stringpool_template): Add variant of add which takes a std::basic_string. * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_12. (ver_test_12_SOURCES, ver_test_12_DEPENDENCIES): New variables. (ver_test_12_LDFLAGS, ver_test_12_LDADD): New variables. (ver_test_12.o): New target. * testsuite/Makefile.in: Rebuild.
Diffstat (limited to 'gold/symtab.cc')
-rw-r--r--gold/symtab.cc25
1 files changed, 23 insertions, 2 deletions
diff --git a/gold/symtab.cc b/gold/symtab.cc
index 5d8c163..3df86b5 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -293,6 +293,21 @@ Sized_symbol<size>::init_undefined(const char* name, const char* version,
this->symsize_ = 0;
}
+// Return an allocated string holding the symbol's name as
+// name@version. This is used for relocatable links.
+
+std::string
+Symbol::versioned_name() const
+{
+ gold_assert(this->version_ != NULL);
+ std::string ret = this->name_;
+ ret.push_back('@');
+ if (this->is_def_)
+ ret.push_back('@');
+ ret += this->version_;
+ return ret;
+}
+
// Return true if SHNDX represents a common symbol.
bool
@@ -2416,7 +2431,10 @@ Symbol_table::add_to_final_symtab(Symbol* sym, Stringpool* pool,
unsigned int* pindex, off_t* poff)
{
sym->set_symtab_index(*pindex);
- pool->add(sym->name(), false, NULL);
+ if (sym->version() == NULL || !parameters->options().relocatable())
+ pool->add(sym->name(), false, NULL);
+ else
+ pool->add(sym->versioned_name(), true, NULL);
++*pindex;
*poff += elfcpp::Elf_sizes<size>::sym_size;
}
@@ -2925,7 +2943,10 @@ Symbol_table::sized_write_symbol(
unsigned char* p) const
{
elfcpp::Sym_write<size, big_endian> osym(p);
- osym.put_st_name(pool->get_offset(sym->name()));
+ if (sym->version() == NULL || !parameters->options().relocatable())
+ osym.put_st_name(pool->get_offset(sym->name()));
+ else
+ osym.put_st_name(pool->get_offset(sym->versioned_name()));
osym.put_st_value(value);
// Use a symbol size of zero for undefined symbols from shared libraries.
if (shndx == elfcpp::SHN_UNDEF && sym->is_from_dynobj())