// 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
{
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.
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;
# Test symbol versioning.
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_19 = ver_test ver_test_2 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_6 ver_test_8 ver_test_9 \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_1 protected_2 \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_test relro_script_test \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_1 script_test_2 \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms binary_test \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3 \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_11 protected_1 \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_2 relro_test \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_script_test script_test_1 \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_2 justsyms \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ binary_test script_test_3 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_1 \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_2
@GCC_FALSE@script_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_6$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_8$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_9$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_11$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_1$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_2$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ relro_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_ver_test_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_main.$(OBJEXT)
ver_test_OBJECTS = $(am_ver_test_OBJECTS)
+am__ver_test_11_SOURCES_DIST = ver_test_main_2.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@am_ver_test_11_OBJECTS = \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_main_2.$(OBJEXT)
+ver_test_11_OBJECTS = $(am_ver_test_11_OBJECTS)
am__ver_test_2_SOURCES_DIST = ver_test_main_2.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_ver_test_2_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_main_2.$(OBJEXT)
$(two_file_shared_2_test_SOURCES) \
$(two_file_static_test_SOURCES) two_file_strip_test.c \
$(two_file_test_SOURCES) $(ver_test_SOURCES) \
- $(ver_test_2_SOURCES) $(ver_test_6_SOURCES) \
- $(ver_test_8_SOURCES) $(ver_test_9_SOURCES) \
- $(weak_alias_test_SOURCES) weak_plt.c $(weak_test_SOURCES) \
- $(weak_undef_nonpic_test_SOURCES) $(weak_undef_test_SOURCES)
+ $(ver_test_11_SOURCES) $(ver_test_2_SOURCES) \
+ $(ver_test_6_SOURCES) $(ver_test_8_SOURCES) \
+ $(ver_test_9_SOURCES) $(weak_alias_test_SOURCES) weak_plt.c \
+ $(weak_test_SOURCES) $(weak_undef_nonpic_test_SOURCES) \
+ $(weak_undef_test_SOURCES)
DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
basic_static_pic_test.c basic_static_test.c basic_test.c \
$(am__binary_test_SOURCES_DIST) $(binary_unittest_SOURCES) \
$(am__two_file_shared_2_test_SOURCES_DIST) \
$(am__two_file_static_test_SOURCES_DIST) two_file_strip_test.c \
$(am__two_file_test_SOURCES_DIST) $(am__ver_test_SOURCES_DIST) \
- $(am__ver_test_2_SOURCES_DIST) $(am__ver_test_6_SOURCES_DIST) \
- $(am__ver_test_8_SOURCES_DIST) $(am__ver_test_9_SOURCES_DIST) \
+ $(am__ver_test_11_SOURCES_DIST) $(am__ver_test_2_SOURCES_DIST) \
+ $(am__ver_test_6_SOURCES_DIST) $(am__ver_test_8_SOURCES_DIST) \
+ $(am__ver_test_9_SOURCES_DIST) \
$(am__weak_alias_test_SOURCES_DIST) weak_plt.c \
$(am__weak_test_SOURCES_DIST) \
$(am__weak_undef_nonpic_test_SOURCES_DIST) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_9_DEPENDENCIES = gcctestdir/ld ver_test_9.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_9_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_9_LDADD = ver_test_9.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_11_SOURCES = ver_test_main_2.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_11_DEPENDENCIES = gcctestdir/ld ver_test_11.a
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_11_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_11_LDADD = ver_test_11.a
@GCC_TRUE@@NATIVE_LINKER_TRUE@protected_1_SOURCES = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_main_1.cc protected_main_2.cc protected_main_3.cc
ver_test$(EXEEXT): $(ver_test_OBJECTS) $(ver_test_DEPENDENCIES)
@rm -f ver_test$(EXEEXT)
$(CXXLINK) $(ver_test_LDFLAGS) $(ver_test_OBJECTS) $(ver_test_LDADD) $(LIBS)
+ver_test_11$(EXEEXT): $(ver_test_11_OBJECTS) $(ver_test_11_DEPENDENCIES)
+ @rm -f ver_test_11$(EXEEXT)
+ $(CXXLINK) $(ver_test_11_LDFLAGS) $(ver_test_11_OBJECTS) $(ver_test_11_LDADD) $(LIBS)
ver_test_2$(EXEEXT): $(ver_test_2_OBJECTS) $(ver_test_2_DEPENDENCIES)
@rm -f ver_test_2$(EXEEXT)
$(CXXLINK) $(ver_test_2_LDFLAGS) $(ver_test_2_OBJECTS) $(ver_test_2_LDADD) $(LIBS)
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -s $< >$@ 2>/dev/null
@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_10.so: gcctestdir/ld ver_test_2.o ver_test_10.script
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_10.script ver_test_2.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_11.a: ver_test_1.o ver_test_2.o ver_test_4.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) rc $@ $^
@GCC_TRUE@@NATIVE_LINKER_TRUE@protected_1.so: gcctestdir/ld protected_1_pic.o protected_2_pic.o protected_3_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared protected_1_pic.o protected_2_pic.o protected_3_pic.o