diff options
author | Ian Lance Taylor <ian@airs.com> | 2009-03-18 05:09:52 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2009-03-18 05:09:52 +0000 |
commit | 9c5b8369abae21b86c0c80f3336f2eb2a52adee0 (patch) | |
tree | e0f800f456a1a8b2465a69db1b32adc53e8a9407 /gold/archive.cc | |
parent | 8a2492ee53079de2710f5c0970760e179efee4bd (diff) | |
download | gdb-9c5b8369abae21b86c0c80f3336f2eb2a52adee0.zip gdb-9c5b8369abae21b86c0c80f3336f2eb2a52adee0.tar.gz gdb-9c5b8369abae21b86c0c80f3336f2eb2a52adee0.tar.bz2 |
* archive.cc (Archive::add_symbols): Check for a version attached
to the symbol name in the archive map.
* testsuite/Makefile.am (check_PROGRAMS): Add ver_test_11.
(ver_test_11_SOURCES, ver_test_11_DEPENDENCIES): Define.
(ver_test_11_LDFLAGS, ver_test_11_LDADD): Define.
(ver_test_11.a): New target.
* testsuite/Makefile.in: Rebuild.
Diffstat (limited to 'gold/archive.cc')
-rw-r--r-- | gold/archive.cc | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/gold/archive.cc b/gold/archive.cc index 73fa676..1d83d6a 100644 --- a/gold/archive.cc +++ b/gold/archive.cc @@ -635,6 +635,8 @@ Archive::add_symbols(Symbol_table* symtab, Layout* layout, // Track which symbols in the symbol table we've already found to be // defined. + char* tmpbuf = NULL; + size_t tmpbuflen = 0; bool added_new_object; do { @@ -658,7 +660,40 @@ Archive::add_symbols(Symbol_table* symtab, Layout* layout, const char* sym_name = (this->armap_names_.data() + this->armap_[i].name_offset); - Symbol* sym = symtab->lookup(sym_name); + + // In an object file, and therefore in an archive map, an + // '@' in the name separates the symbol name from the + // version name. If there are two '@' characters, this is + // the default version. + const char* ver = strchr(sym_name, '@'); + bool def = false; + if (ver != NULL) + { + size_t symlen = ver - sym_name; + if (symlen + 1 > tmpbuflen) + { + tmpbuf = static_cast<char*>(realloc(tmpbuf, symlen + 1)); + tmpbuflen = symlen + 1; + } + memcpy(tmpbuf, sym_name, symlen); + tmpbuf[symlen] = '\0'; + sym_name = tmpbuf; + + ++ver; + if (*ver == '@') + { + ++ver; + def = true; + } + } + + Symbol* sym = symtab->lookup(sym_name, ver); + if (def + && (sym == NULL + || !sym->is_undefined() + || sym->binding() == elfcpp::STB_WEAK)) + sym = symtab->lookup(sym_name, NULL); + if (sym == NULL) { // Check whether the symbol was named in a -u option. @@ -687,13 +722,20 @@ Archive::add_symbols(Symbol_table* symtab, Layout* layout, if (!this->include_member(symtab, layout, input_objects, last_seen_offset, mapfile, sym, why.c_str())) - return false; + { + if (tmpbuf != NULL) + free(tmpbuf); + return false; + } added_new_object = true; } } while (added_new_object); + if (tmpbuf != NULL) + free(tmpbuf); + input_objects->archive_stop(this); return true; |