* 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.
This commit is contained in:
parent
8a2492ee53
commit
9c5b8369ab
@ -1,5 +1,13 @@
|
||||
2009-03-17 Ian Lance Taylor <iant@google.com>
|
||||
|
||||
* 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.
|
||||
|
||||
* configure.ac: Check for chsize and posix_fallocate. Replace
|
||||
ftruncate.
|
||||
* ftruncate.c: New file, from gnulib.
|
||||
|
@ -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;
|
||||
|
@ -819,6 +819,14 @@ ver_test_10.syms: ver_test_10.so
|
||||
ver_test_10.so: gcctestdir/ld ver_test_2.o ver_test_10.script
|
||||
$(CXXLINK) -Bgcctestdir/ -shared -Wl,--version-script,$(srcdir)/ver_test_10.script ver_test_2.o
|
||||
|
||||
check_PROGRAMS += ver_test_11
|
||||
ver_test_11_SOURCES = ver_test_main_2.cc
|
||||
ver_test_11_DEPENDENCIES = gcctestdir/ld ver_test_11.a
|
||||
ver_test_11_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
|
||||
ver_test_11_LDADD = ver_test_11.a
|
||||
ver_test_11.a: ver_test_1.o ver_test_2.o ver_test_4.o
|
||||
$(TEST_AR) rc $@ $^
|
||||
|
||||
check_PROGRAMS += protected_1
|
||||
protected_1_SOURCES = \
|
||||
protected_main_1.cc protected_main_2.cc protected_main_3.cc
|
||||
|
@ -256,11 +256,11 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
|
||||
# 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 \
|
||||
@ -405,6 +405,7 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
|
||||
@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) \
|
||||
@ -818,6 +819,10 @@ am__ver_test_SOURCES_DIST = ver_test_main.cc
|
||||
@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)
|
||||
@ -913,10 +918,11 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
|
||||
$(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) \
|
||||
@ -974,8 +980,9 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
|
||||
$(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) \
|
||||
@ -1442,6 +1449,10 @@ binary_unittest_SOURCES = binary_unittest.cc
|
||||
@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
|
||||
|
||||
@ -1791,6 +1802,9 @@ two_file_test$(EXEEXT): $(two_file_test_OBJECTS) $(two_file_test_DEPENDENCIES)
|
||||
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)
|
||||
@ -2442,6 +2456,8 @@ uninstall-am: uninstall-info-am
|
||||
@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
|
||||
|
Loading…
Reference in New Issue
Block a user