* symtab.cc (Symbol_table::add_from_object): Handle saw_undefined_
authorIan Lance Taylor <ian@airs.com>
Thu, 27 Mar 2008 18:19:09 +0000 (18:19 +0000)
committerIan Lance Taylor <ian@airs.com>
Thu, 27 Mar 2008 18:19:09 +0000 (18:19 +0000)
and commons_ correctly when NAME/VERSION does not override
NAME/NULL.
* testsuite/ver_test_6.c: New file.
* testsuite/Makefile.am (check_PROGRAMS): Add ver_test_6
(ver_test_6_SOURCES, ver_test_6_DEPENDENCIES): New variables.
(ver_test_6_LDFLAGS, ver_test_6_LDADD): New variables.

gold/ChangeLog
gold/symtab.cc
gold/testsuite/Makefile.am
gold/testsuite/Makefile.in
gold/testsuite/ver_test_6.c [new file with mode: 0644]

index b2c076d..098b7e3 100644 (file)
@@ -1,3 +1,13 @@
+2008-03-27  Ian Lance Taylor  <iant@google.com>
+
+       * symtab.cc (Symbol_table::add_from_object): Handle saw_undefined_
+       and commons_ correctly when NAME/VERSION does not override
+       NAME/NULL.
+       * testsuite/ver_test_6.c: New file.
+       * testsuite/Makefile.am (check_PROGRAMS): Add ver_test_6
+       (ver_test_6_SOURCES, ver_test_6_DEPENDENCIES): New variables.
+       (ver_test_6_LDFLAGS, ver_test_6_LDADD): New variables.
+
 2008-03-26  Ian Lance Taylor  <iant@google.com>
 
        * symtab.cc (Symbol_table::add_from_relobj): Don't set the version
index c7170a3..a2ae22f 100644 (file)
@@ -584,19 +584,23 @@ Symbol_table::add_from_object(Object* object,
       // This is the first time we have seen NAME/VERSION.
       gold_assert(ins.first->second == NULL);
 
-      was_undefined = false;
-      was_common = false;
-
       if (def && !insdef.second)
        {
          // We already have an entry for NAME/NULL.  If we override
          // it, then change it to NAME/VERSION.
          ret = this->get_sized_symbol<size>(insdef.first->second);
+
+         was_undefined = ret->is_undefined();
+         was_common = ret->is_common();
+
          this->resolve(ret, sym, orig_sym, object, version);
          ins.first->second = ret;
        }
       else
        {
+         was_undefined = false;
+         was_common = false;
+
          Sized_target<size, big_endian>* target =
            object->sized_target<size, big_endian>();
          if (!target->has_make_symbol())
index e529629..4d0f9dc 100644 (file)
@@ -562,6 +562,12 @@ ver_test_5.syms: ver_test_5.so
 
 endif
 
+check_PROGRAMS += ver_test_6
+ver_test_6_SOURCES = ver_test_6.c
+ver_test_6_DEPENDENCIES = gcctestdir/ld ver_test_2.so
+ver_test_6_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+ver_test_6_LDADD = ver_test_2.so
+
 check_PROGRAMS += script_test_1
 script_test_1_SOURCES = script_test_1.cc
 script_test_1_DEPENDENCIES = gcctestdir/ld script_test_1.t
index cd81bcd..f9c37f3 100644 (file)
@@ -175,7 +175,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_10 = flagstest_compress_debug_sections \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile_and_compress_debug_sections \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test ver_test_2 \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test ver_test_2 ver_test_6 \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_1 script_test_2 \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms binary_test
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@READELF_TRUE@am__append_11 =  \
@@ -285,6 +285,7 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile_and_compress_debug_sections$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_2$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_6$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_1$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_2$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms$(EXEEXT) \
@@ -589,6 +590,10 @@ 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)
 ver_test_2_OBJECTS = $(am_ver_test_2_OBJECTS)
+am__ver_test_6_SOURCES_DIST = ver_test_6.c
+@GCC_TRUE@@NATIVE_LINKER_TRUE@am_ver_test_6_OBJECTS =  \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_6.$(OBJEXT)
+ver_test_6_OBJECTS = $(am_ver_test_6_OBJECTS)
 am__weak_test_SOURCES_DIST = weak_test.cc
 @GCC_TRUE@@NATIVE_LINKER_TRUE@am_weak_test_OBJECTS =  \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_test.$(OBJEXT)
@@ -641,7 +646,8 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
        $(two_file_shared_2_pic_1_test_SOURCES) \
        $(two_file_shared_2_test_SOURCES) \
        $(two_file_static_test_SOURCES) $(two_file_test_SOURCES) \
-       $(ver_test_SOURCES) $(ver_test_2_SOURCES) $(weak_test_SOURCES)
+       $(ver_test_SOURCES) $(ver_test_2_SOURCES) \
+       $(ver_test_6_SOURCES) $(weak_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) \
@@ -684,7 +690,8 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
        $(am__two_file_shared_2_test_SOURCES_DIST) \
        $(am__two_file_static_test_SOURCES_DIST) \
        $(am__two_file_test_SOURCES_DIST) $(am__ver_test_SOURCES_DIST) \
-       $(am__ver_test_2_SOURCES_DIST) $(am__weak_test_SOURCES_DIST)
+       $(am__ver_test_2_SOURCES_DIST) $(am__ver_test_6_SOURCES_DIST) \
+       $(am__weak_test_SOURCES_DIST)
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -1056,6 +1063,10 @@ binary_unittest_SOURCES = binary_unittest.cc
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_2_DEPENDENCIES = gcctestdir/ld ver_test_4.so ver_test_2.so
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_2_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_2_LDADD = ver_test_4.so ver_test_2.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_6_SOURCES = ver_test_6.c
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_6_DEPENDENCIES = gcctestdir/ld ver_test_2.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_6_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_6_LDADD = ver_test_2.so
 @GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_1_SOURCES = script_test_1.cc
 @GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_1_DEPENDENCIES = gcctestdir/ld script_test_1.t
 @GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -T $(srcdir)/script_test_1.t
@@ -1288,6 +1299,9 @@ ver_test$(EXEEXT): $(ver_test_OBJECTS) $(ver_test_DEPENDENCIES)
 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)
+ver_test_6$(EXEEXT): $(ver_test_6_OBJECTS) $(ver_test_6_DEPENDENCIES) 
+       @rm -f ver_test_6$(EXEEXT)
+       $(LINK) $(ver_test_6_LDFLAGS) $(ver_test_6_OBJECTS) $(ver_test_6_LDADD) $(LIBS)
 weak_test$(EXEEXT): $(weak_test_OBJECTS) $(weak_test_DEPENDENCIES) 
        @rm -f weak_test$(EXEEXT)
        $(CXXLINK) $(weak_test_LDFLAGS) $(weak_test_OBJECTS) $(weak_test_LDADD) $(LIBS)
@@ -1328,6 +1342,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/two_file_test_1b.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/two_file_test_2.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/two_file_test_main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ver_test_6.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ver_test_main.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ver_test_main_2.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/weak_test.Po@am__quote@
diff --git a/gold/testsuite/ver_test_6.c b/gold/testsuite/ver_test_6.c
new file mode 100644 (file)
index 0000000..4206354
--- /dev/null
@@ -0,0 +1,33 @@
+/* ver_test_6.c -- test common symbol with shared library version
+
+   Copyright 2008 Free Software Foundation, Inc.
+   Written by Ian Lance Taylor <iant@google.com>
+
+   This file is part of gold.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.
+
+   This is a test of a common symbol in the main program and a
+   versioned symbol in a shared library.  The common symbol in the
+   main program should override the shared library symbol.  */
+
+int t3_2;
+
+int
+main()
+{
+  return t3_2;
+}