aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gold/dynobj.cc1
-rw-r--r--gold/i386.cc5
-rw-r--r--gold/po/gold.pot208
-rw-r--r--gold/symtab.cc12
-rw-r--r--gold/testsuite/Makefile.am20
-rw-r--r--gold/testsuite/Makefile.in38
-rw-r--r--gold/testsuite/ver_test.h40
-rw-r--r--gold/testsuite/ver_test_1.cc33
-rw-r--r--gold/testsuite/ver_test_2.cc40
-rw-r--r--gold/testsuite/ver_test_2.script31
-rw-r--r--gold/testsuite/ver_test_3.cc33
-rw-r--r--gold/testsuite/ver_test_4.cc53
-rw-r--r--gold/testsuite/ver_test_4.script35
-rw-r--r--gold/testsuite/ver_test_main.cc54
-rw-r--r--gold/x86_64.cc5
15 files changed, 501 insertions, 107 deletions
diff --git a/gold/dynobj.cc b/gold/dynobj.cc
index 18ae92c..7e61007 100644
--- a/gold/dynobj.cc
+++ b/gold/dynobj.cc
@@ -1296,6 +1296,7 @@ Versions::add_def(const Symbol* sym, const char* version,
// We have now seen a symbol in this version, so it is not
// weak.
+ gold_assert(vb != NULL);
vb->clear_weak();
// FIXME: When we support version scripts, we will need to
diff --git a/gold/i386.cc b/gold/i386.cc
index 0858e6d..6c35940 100644
--- a/gold/i386.cc
+++ b/gold/i386.cc
@@ -1583,7 +1583,10 @@ Target_i386::Relocate::relocate(const Relocate_info<32, false>* relinfo,
case elfcpp::R_386_PLT32:
gold_assert(gsym == NULL
|| gsym->has_plt_offset()
- || gsym->final_value_is_known());
+ || gsym->final_value_is_known()
+ || (gsym->is_defined()
+ && !gsym->is_from_dynobj()
+ && !gsym->is_preemptible()));
Relocate_functions<32, false>::pcrel32(view, object, psymval, address);
break;
diff --git a/gold/po/gold.pot b/gold/po/gold.pot
index 4b786be..ff4e2c8 100644
--- a/gold/po/gold.pot
+++ b/gold/po/gold.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-12-14 09:45-0800\n"
+"POT-Creation-Date: 2007-12-21 15:26-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -16,47 +16,47 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: archive.cc:95
+#: archive.cc:96
#, c-format
msgid "%s: no archive symbol table (run ranlib)"
msgstr ""
-#: archive.cc:145
+#: archive.cc:147
#, c-format
msgid "%s: bad archive symbol table names"
msgstr ""
-#: archive.cc:175
+#: archive.cc:177
#, c-format
msgid "%s: malformed archive header at %zu"
msgstr ""
-#: archive.cc:195
+#: archive.cc:197
#, c-format
msgid "%s: malformed archive header size at %zu"
msgstr ""
-#: archive.cc:206
+#: archive.cc:208
#, c-format
msgid "%s: malformed archive header name at %zu"
msgstr ""
-#: archive.cc:231
+#: archive.cc:233
#, c-format
msgid "%s: bad extended name index at %zu"
msgstr ""
-#: archive.cc:241
+#: archive.cc:243
#, c-format
msgid "%s: bad extended name entry at header %zu"
msgstr ""
-#: archive.cc:334
+#: archive.cc:336
#, c-format
msgid "%s: short archive header at %zu"
msgstr ""
-#: archive.cc:385 archive.cc:399
+#: archive.cc:387 archive.cc:401
#, c-format
msgid "%s: member at %zu is not an ELF object"
msgstr ""
@@ -104,81 +104,81 @@ msgstr ""
msgid "missing DT_NULL in dynamic segment"
msgstr ""
-#: dynobj.cc:322
+#: dynobj.cc:323
#, c-format
msgid "invalid dynamic symbol table name index: %u"
msgstr ""
-#: dynobj.cc:329
+#: dynobj.cc:330
#, c-format
msgid "dynamic symbol table name section has wrong type: %u"
msgstr ""
-#: dynobj.cc:402 object.cc:238 object.cc:574
+#: dynobj.cc:404 object.cc:241 object.cc:579
#, c-format
msgid "bad section name offset for section %u: %lu"
msgstr ""
-#: dynobj.cc:431
+#: dynobj.cc:433
#, c-format
msgid "duplicate definition for version %u"
msgstr ""
-#: dynobj.cc:460
+#: dynobj.cc:462
#, c-format
msgid "unexpected verdef version %u"
msgstr ""
-#: dynobj.cc:476
+#: dynobj.cc:478
#, c-format
msgid "verdef vd_cnt field too small: %u"
msgstr ""
-#: dynobj.cc:483
+#: dynobj.cc:486
#, c-format
msgid "verdef vd_aux field out of range: %u"
msgstr ""
-#: dynobj.cc:493
+#: dynobj.cc:497
#, c-format
msgid "verdaux vda_name field out of range: %u"
msgstr ""
-#: dynobj.cc:502
+#: dynobj.cc:507
#, c-format
msgid "verdef vd_next field out of range: %u"
msgstr ""
-#: dynobj.cc:535
+#: dynobj.cc:541
#, c-format
msgid "unexpected verneed version %u"
msgstr ""
-#: dynobj.cc:544
+#: dynobj.cc:550
#, c-format
msgid "verneed vn_aux field out of range: %u"
msgstr ""
-#: dynobj.cc:557
+#: dynobj.cc:564
#, c-format
msgid "vernaux vna_name field out of range: %u"
msgstr ""
-#: dynobj.cc:568
+#: dynobj.cc:575
#, c-format
msgid "verneed vna_next field out of range: %u"
msgstr ""
-#: dynobj.cc:579
+#: dynobj.cc:586
#, c-format
msgid "verneed vn_next field out of range: %u"
msgstr ""
-#: dynobj.cc:626
+#: dynobj.cc:634
msgid "size of dynamic symbols is not multiple of symbol size"
msgstr ""
-#: dynobj.cc:1303
+#: dynobj.cc:1312
#, c-format
msgid "symbol %s has undefined version %s"
msgstr ""
@@ -218,42 +218,42 @@ msgstr ""
msgid "%s: fstat failed: %s"
msgstr ""
-#: fileread.cc:231
+#: fileread.cc:229
#, c-format
msgid "%s: pread failed: %s"
msgstr ""
-#: fileread.cc:237
+#: fileread.cc:235
#, c-format
msgid "%s: file too short: read only %lld of %lld bytes at %lld"
msgstr ""
-#: fileread.cc:312
+#: fileread.cc:310
#, c-format
msgid "%s: mmap offset %lld size %lld failed: %s"
msgstr ""
-#: fileread.cc:393
+#: fileread.cc:391
#, c-format
msgid "%s: total bytes mapped for read: %llu\n"
msgstr ""
-#: fileread.cc:395
+#: fileread.cc:393
#, c-format
msgid "%s: maximum bytes mapped for read at one time: %llu\n"
msgstr ""
-#: fileread.cc:465
+#: fileread.cc:463
#, c-format
msgid "cannot find -l%s"
msgstr ""
-#: fileread.cc:492
+#: fileread.cc:490
#, c-format
msgid "cannot find %s"
msgstr ""
-#: fileread.cc:503
+#: fileread.cc:501
#, c-format
msgid "cannot open %s: %s"
msgstr ""
@@ -336,45 +336,50 @@ msgid "pthread_cond_broadcast failed: %s"
msgstr ""
#. FIXME: This needs to specify the location somehow.
-#: i386.cc:160 i386.cc:1480 x86_64.cc:172 x86_64.cc:1370
+#: i386.cc:160 i386.cc:1484 x86_64.cc:172 x86_64.cc:1373
msgid "missing expected TLS relocation"
msgstr ""
-#: i386.cc:806 x86_64.cc:761 x86_64.cc:975
+#: i386.cc:810 x86_64.cc:764 x86_64.cc:978
#, c-format
msgid "%s: unsupported reloc %u against local symbol"
msgstr ""
-#: i386.cc:913 i386.cc:1209 x86_64.cc:886 x86_64.cc:1157
+#: i386.cc:917 i386.cc:1213 x86_64.cc:889 x86_64.cc:1160
#, c-format
msgid "%s: unexpected reloc %u in object file"
msgstr ""
-#: i386.cc:1052 x86_64.cc:989 x86_64.cc:1253
+#: i386.cc:1056 x86_64.cc:992 x86_64.cc:1256
#, c-format
msgid "%s: unsupported reloc %u against global symbol %s"
msgstr ""
-#: i386.cc:1363
+#: i386.cc:1367
#, c-format
msgid "%s: unsupported RELA reloc section"
msgstr ""
-#: i386.cc:1620 x86_64.cc:1569
+#: i386.cc:1627 x86_64.cc:1575
#, c-format
msgid "unexpected reloc %u in object file"
msgstr ""
-#: i386.cc:1652 i386.cc:1727 i386.cc:1734 i386.cc:1765 i386.cc:1818
-#: x86_64.cc:1590 x86_64.cc:1670 x86_64.cc:1694
+#: i386.cc:1659 i386.cc:1734 i386.cc:1741 i386.cc:1772 i386.cc:1825
+#: x86_64.cc:1596 x86_64.cc:1676 x86_64.cc:1700
#, c-format
msgid "unsupported reloc %u"
msgstr ""
-#: i386.cc:1742
+#: i386.cc:1749
msgid "both SUN and GNU model TLS relocations"
msgstr ""
+#: merge.cc:449
+#, c-format
+msgid "%s: %s merged constants size: %lu; input: %zu; output: %zu\n"
+msgstr ""
+
#: merge.cc:472
msgid "mergeable string section length not multiple of character size"
msgstr ""
@@ -383,6 +388,11 @@ msgstr ""
msgid "entry in mergeable string section not null terminated"
msgstr ""
+#: merge.cc:603
+#, c-format
+msgid "%s: %s input: %zu\n"
+msgstr ""
+
#: object.cc:53
#, c-format
msgid "%s: unsupported ELF machine number %d"
@@ -393,122 +403,122 @@ msgstr ""
msgid "%s: %s"
msgstr ""
-#: object.cc:106
+#: object.cc:107
#, c-format
msgid "section name section has wrong type: %u"
msgstr ""
-#: object.cc:311
+#: object.cc:315
#, c-format
msgid "invalid symbol table name index: %u"
msgstr ""
-#: object.cc:317
+#: object.cc:321
#, c-format
msgid "symbol table name section has wrong type: %u"
msgstr ""
-#: object.cc:397
+#: object.cc:402
#, c-format
msgid "section group %u info %u out of range"
msgstr ""
-#: object.cc:415
+#: object.cc:420
#, c-format
msgid "symbol %u name offset %u out of range"
msgstr ""
-#: object.cc:447
+#: object.cc:452
#, c-format
msgid "section %u in section group %u out of range"
msgstr ""
-#: object.cc:537 reloc.cc:205 reloc.cc:520
+#: object.cc:542 reloc.cc:206 reloc.cc:530
#, c-format
msgid "relocation section %u has bad info %u"
msgstr ""
-#: object.cc:709
+#: object.cc:713
msgid "size of symbols is not multiple of symbol size"
msgstr ""
-#: object.cc:808
+#: object.cc:812
#, c-format
msgid "local symbol %u section name out of range: %u >= %u"
msgstr ""
#. FIXME: Handle SHN_XINDEX.
-#: object.cc:865
+#: object.cc:869
#, c-format
msgid "unknown section index %u for local symbol %u"
msgstr ""
-#: object.cc:874
+#: object.cc:878
#, c-format
msgid "local symbol %u section index %u out of range"
msgstr ""
-#: object.cc:1194
+#: object.cc:1181
#, c-format
msgid "%s: incompatible target"
msgstr ""
-#: object.cc:1349
+#: object.cc:1336
#, c-format
msgid "%s: unsupported ELF file type %d"
msgstr ""
-#: object.cc:1368 object.cc:1414 object.cc:1448
+#: object.cc:1355 object.cc:1401 object.cc:1435
#, c-format
msgid "%s: ELF file too short"
msgstr ""
-#: object.cc:1376
+#: object.cc:1363
#, c-format
msgid "%s: invalid ELF version 0"
msgstr ""
-#: object.cc:1378
+#: object.cc:1365
#, c-format
msgid "%s: unsupported ELF version %d"
msgstr ""
-#: object.cc:1385
+#: object.cc:1372
#, c-format
msgid "%s: invalid ELF class 0"
msgstr ""
-#: object.cc:1391
+#: object.cc:1378
#, c-format
msgid "%s: unsupported ELF class %d"
msgstr ""
-#: object.cc:1398
+#: object.cc:1385
#, c-format
msgid "%s: invalid ELF data encoding"
msgstr ""
-#: object.cc:1404
+#: object.cc:1391
#, c-format
msgid "%s: unsupported ELF data encoding %d"
msgstr ""
-#: object.cc:1424
+#: object.cc:1411
#, c-format
msgid "%s: not configured to support 32-bit big-endian object"
msgstr ""
-#: object.cc:1437
+#: object.cc:1424
#, c-format
msgid "%s: not configured to support 32-bit little-endian object"
msgstr ""
-#: object.cc:1458
+#: object.cc:1445
#, c-format
msgid "%s: not configured to support 64-bit big-endian object"
msgstr ""
-#: object.cc:1471
+#: object.cc:1458
#, c-format
msgid "%s: not configured to support 64-bit little-endian object"
msgstr ""
@@ -856,47 +866,47 @@ msgstr ""
msgid "--threads not supported"
msgstr ""
-#: output.cc:1467
+#: output.cc:1478
#, c-format
msgid "invalid alignment %lu for section \"%s\""
msgstr ""
-#: output.cc:2334
+#: output.cc:2383
#, c-format
msgid "%s: open: %s"
msgstr ""
-#: output.cc:2354
+#: output.cc:2403
#, c-format
msgid "%s: mremap: %s"
msgstr ""
-#: output.cc:2390
+#: output.cc:2439
#, c-format
msgid "%s: lseek: %s"
msgstr ""
-#: output.cc:2393 output.cc:2430
+#: output.cc:2442 output.cc:2479
#, c-format
msgid "%s: write: %s"
msgstr ""
-#: output.cc:2401
+#: output.cc:2450
#, c-format
msgid "%s: mmap: %s"
msgstr ""
-#: output.cc:2411
+#: output.cc:2460
#, c-format
msgid "%s: munmap: %s"
msgstr ""
-#: output.cc:2428
+#: output.cc:2477
#, c-format
msgid "%s: write: unexpected 0 return-value"
msgstr ""
-#: output.cc:2440
+#: output.cc:2489
#, c-format
msgid "%s: close: %s"
msgstr ""
@@ -912,27 +922,27 @@ msgid "%s: ordinary object found in input group"
msgstr ""
#. Here we have to handle any other input file types we need.
-#: readsyms.cc:244
+#: readsyms.cc:242
#, c-format
msgid "%s: not an object or archive"
msgstr ""
-#: reloc.cc:224 reloc.cc:538
+#: reloc.cc:225 reloc.cc:548
#, c-format
msgid "relocation section %u uses unexpected symbol table %u"
msgstr ""
-#: reloc.cc:239 reloc.cc:556
+#: reloc.cc:240 reloc.cc:566
#, c-format
msgid "unexpected entsize for reloc section %u: %lu != %u"
msgstr ""
-#: reloc.cc:248 reloc.cc:565
+#: reloc.cc:249 reloc.cc:575
#, c-format
msgid "reloc section %u size %lu uneven"
msgstr ""
-#: reloc.cc:759
+#: reloc.cc:839
#, c-format
msgid "reloc section size %zu is not a multiple of reloc size %d\n"
msgstr ""
@@ -974,82 +984,82 @@ msgid ""
"T"
msgstr ""
-#: stringpool.cc:535
+#: stringpool.cc:537
#, c-format
msgid "%s: %s entries: %zu; buckets: %zu\n"
msgstr ""
-#: stringpool.cc:539
+#: stringpool.cc:541
#, c-format
msgid "%s: %s entries: %zu\n"
msgstr ""
-#: stringpool.cc:542
+#: stringpool.cc:544
#, c-format
msgid "%s: %s Stringdata structures: %zu\n"
msgstr ""
-#: symtab.cc:595
+#: symtab.cc:603
#, c-format
msgid "bad global symbol name offset %u at %zu"
msgstr ""
-#: symtab.cc:673
+#: symtab.cc:682
msgid "too few symbol versions"
msgstr ""
-#: symtab.cc:702
+#: symtab.cc:711
#, c-format
msgid "bad symbol name offset %u at %zu"
msgstr ""
-#: symtab.cc:756
+#: symtab.cc:765
#, c-format
msgid "versym for symbol %zu out of range: %u"
msgstr ""
-#: symtab.cc:764
+#: symtab.cc:773
#, c-format
msgid "versym for symbol %zu has no name: %u"
msgstr ""
-#: symtab.cc:1482 symtab.cc:1698
+#: symtab.cc:1493 symtab.cc:1709
#, c-format
msgid "%s: unsupported symbol section 0x%x"
msgstr ""
-#: symtab.cc:1822
+#: symtab.cc:1833
#, c-format
msgid "%s: undefined reference to '%s'"
msgstr ""
-#: symtab.cc:1907
+#: symtab.cc:1918
#, c-format
msgid "%s: symbol table entries: %zu; buckets: %zu\n"
msgstr ""
-#: symtab.cc:1910
+#: symtab.cc:1921
#, c-format
msgid "%s: symbol table entries: %zu\n"
msgstr ""
-#: symtab.cc:1979
+#: symtab.cc:1990
#, c-format
msgid ""
"while linking %s: symbol '%s' defined in multiple places (possible ODR "
"violation):"
msgstr ""
-#: target-reloc.h:211
+#: target-reloc.h:212
#, c-format
msgid "reloc has bad offset %zu"
msgstr ""
-#: tls.h:58
+#: tls.h:59
msgid "TLS relocation out of range"
msgstr ""
-#: tls.h:72
+#: tls.h:73
msgid "TLS relocation against invalid instruction"
msgstr ""
@@ -1073,12 +1083,12 @@ msgstr ""
msgid "%s failed: %s"
msgstr ""
-#: x86_64.cc:1278
+#: x86_64.cc:1281
#, c-format
msgid "%s: unsupported REL reloc section"
msgstr ""
-#: x86_64.cc:1742
+#: x86_64.cc:1748
#, c-format
msgid "unsupported reloc type %u"
msgstr ""
diff --git a/gold/symtab.cc b/gold/symtab.cc
index d39d739..4a1c5ee 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -480,10 +480,18 @@ Symbol_table::add_from_object(Object* object,
// NAME/NULL point to NAME/VERSION.
insdef.first->second = ret;
}
- else if (insdef.first->second != ret)
+ else if (insdef.first->second != ret
+ && insdef.first->second->is_undefined())
{
// This is the unfortunate case where we already have
- // entries for both NAME/VERSION and NAME/NULL.
+ // entries for both NAME/VERSION and NAME/NULL. Note
+ // that we don't want to combine them if the existing
+ // symbol is going to override the new one. FIXME: We
+ // currently just test is_undefined, but this may not do
+ // the right thing if the existing symbol is from a
+ // shared library and the new one is from a regular
+ // object.
+
const Sized_symbol<size>* sym2;
sym2 = this->get_sized_symbol SELECT_SIZE_NAME(size) (
insdef.first->second
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index 6156527..8083ff0 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -482,6 +482,26 @@ flagstest_o_specialfile_and_compress_debug_sections: flagstest_debug.o \
chmod a+x $@
test -s $@
+# Test symbol versioning.
+check_PROGRAMS += ver_test
+ver_test_SOURCES = ver_test_main.cc
+ver_test_DEPENDENCIES = gcctestdir/ld ver_test_1.so ver_test_2.so ver_test_4.so
+ver_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+ver_test_LDADD = ver_test_1.so ver_test_2.so ver_test_4.so
+ver_test_1.so: ver_test_1.o ver_test_2.so ver_test_3.o ver_test_4.so gcctestdir/ld
+ $(CXXLINK) -Bgcctestdir/ -shared ver_test_1.o ver_test_2.so ver_test_3.o ver_test_4.so
+ver_test_2.so: ver_test_2.o $(srcdir)/ver_test_2.script ver_test_4.so
+ $(CXXLINK) -shared -Wl,--version-script,$(srcdir)/ver_test_2.script ver_test_2.o ver_test_4.so
+ver_test_4.so: ver_test_4.o $(srcdir)/ver_test_4.script
+ $(CXXLINK) -shared -Wl,--version-script,$(srcdir)/ver_test_4.script ver_test_4.o
+ver_test_1.o: ver_test_1.cc
+ $(CXXCOMPILE) -c -fpic -o $@ $<
+ver_test_2.o: ver_test_2.cc
+ $(CXXCOMPILE) -c -fpic -o $@ $<
+ver_test_3.o: ver_test_3.cc
+ $(CXXCOMPILE) -c -fpic -o $@ $<
+ver_test_4.o: ver_test_4.cc
+ $(CXXCOMPILE) -c -fpic -o $@ $<
endif GCC
endif NATIVE_LINKER
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 8af1934..316cf00 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -166,9 +166,12 @@ check_PROGRAMS = object_unittest$(EXEEXT) $(am__EXEEXT_1) \
# The specialfile output has a tricky case when we also compress debug
# sections, because it requires output-file resizing.
+
+# Test symbol versioning.
@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@ flagstest_o_specialfile_and_compress_debug_sections \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test
subdir = testsuite
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -229,7 +232,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am__EXEEXT_6 = tls_shared_nonpic_test$(EXEEXT)
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_7 = flagstest_compress_debug_sections$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile$(EXEEXT) \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile_and_compress_debug_sections$(EXEEXT)
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile_and_compress_debug_sections$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test$(EXEEXT)
basic_pic_test_SOURCES = basic_pic_test.c
basic_pic_test_OBJECTS = basic_pic_test.$(OBJEXT)
basic_pic_test_LDADD = $(LDADD)
@@ -467,6 +471,10 @@ am__two_file_test_SOURCES_DIST = two_file_test_1.cc two_file_test_2.cc \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test_main.$(OBJEXT)
two_file_test_OBJECTS = $(am_two_file_test_OBJECTS)
two_file_test_LDADD = $(LDADD)
+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__weak_test_SOURCES_DIST = weak_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_weak_test_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_test.$(OBJEXT)
@@ -513,7 +521,7 @@ 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) \
- $(weak_test_SOURCES)
+ $(ver_test_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__constructor_static_test_SOURCES_DIST) \
@@ -548,7 +556,7 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
$(am__two_file_shared_2_pic_1_test_SOURCES_DIST) \
$(am__two_file_shared_2_test_SOURCES_DIST) \
$(am__two_file_static_test_SOURCES_DIST) \
- $(am__two_file_test_SOURCES_DIST) \
+ $(am__two_file_test_SOURCES_DIST) $(am__ver_test_SOURCES_DIST) \
$(am__weak_test_SOURCES_DIST)
ETAGS = etags
CTAGS = ctags
@@ -893,6 +901,10 @@ object_unittest_SOURCES = object_unittest.cc
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_shared_nonpic_test_DEPENDENCIES = gcctestdir/ld tls_test_shared_nonpic.so
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_shared_nonpic_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_shared_nonpic_test_LDADD = tls_test_shared_nonpic.so -lpthread
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_SOURCES = ver_test_main.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_DEPENDENCIES = gcctestdir/ld ver_test_1.so ver_test_2.so ver_test_4.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_LDADD = ver_test_1.so ver_test_2.so ver_test_4.so
all: all-am
.SUFFIXES:
@@ -1074,6 +1086,9 @@ two_file_static_test$(EXEEXT): $(two_file_static_test_OBJECTS) $(two_file_static
two_file_test$(EXEEXT): $(two_file_test_OBJECTS) $(two_file_test_DEPENDENCIES)
@rm -f two_file_test$(EXEEXT)
$(CXXLINK) $(two_file_test_LDFLAGS) $(two_file_test_OBJECTS) $(two_file_test_LDADD) $(LIBS)
+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)
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)
@@ -1105,6 +1120,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/two_file_test_1.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_main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/weak_test.Po@am__quote@
.c.o:
@@ -1522,6 +1538,20 @@ uninstall-am: uninstall-info-am
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -o /dev/stdout $< --compress-debug-sections=zlib 2>&1 | cat > $@
@GCC_TRUE@@NATIVE_LINKER_TRUE@ chmod a+x $@
@GCC_TRUE@@NATIVE_LINKER_TRUE@ test -s $@
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_1.so: ver_test_1.o ver_test_2.so ver_test_3.o ver_test_4.so gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared ver_test_1.o ver_test_2.so ver_test_3.o ver_test_4.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_2.so: ver_test_2.o $(srcdir)/ver_test_2.script ver_test_4.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -shared -Wl,--version-script,$(srcdir)/ver_test_2.script ver_test_2.o ver_test_4.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_4.so: ver_test_4.o $(srcdir)/ver_test_4.script
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -shared -Wl,--version-script,$(srcdir)/ver_test_4.script ver_test_4.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_1.o: ver_test_1.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_2.o: ver_test_2.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_3.o: ver_test_3.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_4.o: ver_test_4.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/gold/testsuite/ver_test.h b/gold/testsuite/ver_test.h
new file mode 100644
index 0000000..a75731e
--- /dev/null
+++ b/gold/testsuite/ver_test.h
@@ -0,0 +1,40 @@
+// basic_test.cc -- a test case for gold
+
+// Copyright 2007 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.
+
+#ifdef USE_TRACE
+#include <cstdio>
+#define TRACE printf("In %s, %s()\n", __FILE__, __FUNCTION__);
+#else
+#define TRACE
+#endif
+
+extern bool t1();
+extern bool t2();
+extern bool t3();
+
+extern "C" {
+
+extern int t1_2();
+extern int t2_2();
+extern int t3_2();
+
+}
diff --git a/gold/testsuite/ver_test_1.cc b/gold/testsuite/ver_test_1.cc
new file mode 100644
index 0000000..23421c4
--- /dev/null
+++ b/gold/testsuite/ver_test_1.cc
@@ -0,0 +1,33 @@
+// basic_test.cc -- a test case for gold
+
+// Copyright 2007 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.
+
+#include "ver_test.h"
+
+// Calls an unversioned function in file1 that overrides
+// a versioned function in file2.
+
+bool
+t1()
+{
+ TRACE
+ return t1_2() == 11;
+}
diff --git a/gold/testsuite/ver_test_2.cc b/gold/testsuite/ver_test_2.cc
new file mode 100644
index 0000000..39fa04e
--- /dev/null
+++ b/gold/testsuite/ver_test_2.cc
@@ -0,0 +1,40 @@
+// basic_test.cc -- a test case for gold
+
+// Copyright 2007 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.
+
+#include "ver_test.h"
+
+#if 0
+__asm__(".symver t1_2_a,t1_2@VER2");
+
+extern "C"
+int
+t1_2_a();
+
+#define t1_2 t1_2_a
+#endif
+
+int
+t3_2()
+{
+ TRACE
+ return t1_2();
+}
diff --git a/gold/testsuite/ver_test_2.script b/gold/testsuite/ver_test_2.script
new file mode 100644
index 0000000..3756d6d
--- /dev/null
+++ b/gold/testsuite/ver_test_2.script
@@ -0,0 +1,31 @@
+## basic_test.cc -- a test case for gold
+
+## Copyright 2007 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.
+
+VER1 {
+};
+
+VER2 {
+ global:
+ t1_2;
+ t3_2;
+} VER1;
+
diff --git a/gold/testsuite/ver_test_3.cc b/gold/testsuite/ver_test_3.cc
new file mode 100644
index 0000000..ad1d558
--- /dev/null
+++ b/gold/testsuite/ver_test_3.cc
@@ -0,0 +1,33 @@
+// basic_test.cc -- a test case for gold
+
+// Copyright 2007 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.
+
+#include "ver_test.h"
+
+int
+t1_2() __attribute((visibility("hidden")));
+
+int
+t1_2()
+{
+ TRACE
+ return 11;
+}
diff --git a/gold/testsuite/ver_test_4.cc b/gold/testsuite/ver_test_4.cc
new file mode 100644
index 0000000..372b91f
--- /dev/null
+++ b/gold/testsuite/ver_test_4.cc
@@ -0,0 +1,53 @@
+// basic_test.cc -- a test case for gold
+
+// Copyright 2007 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.
+
+#include "ver_test.h"
+
+__asm__(".symver t1_2_a,t1_2@@VER2");
+
+extern "C"
+int
+t1_2_a()
+{
+ TRACE
+ return 12;
+}
+
+__asm__(".symver t2_2_a,t2_2@VER1");
+
+extern "C"
+int
+t2_2_a()
+{
+ TRACE
+ return 21;
+}
+
+__asm__(".symver t2_2_b,t2_2@@VER2");
+
+extern "C"
+int
+t2_2_b()
+{
+ TRACE
+ return 22;
+}
diff --git a/gold/testsuite/ver_test_4.script b/gold/testsuite/ver_test_4.script
new file mode 100644
index 0000000..97cf72f
--- /dev/null
+++ b/gold/testsuite/ver_test_4.script
@@ -0,0 +1,35 @@
+## basic_test.cc -- a test case for gold
+
+## Copyright 2007 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.
+
+VER1 {
+ global:
+ t2_2;
+ local:
+ *;
+};
+
+VER2 {
+ global:
+ t1_2;
+ t2_2;
+} VER1;
+
diff --git a/gold/testsuite/ver_test_main.cc b/gold/testsuite/ver_test_main.cc
new file mode 100644
index 0000000..9eb6ccd
--- /dev/null
+++ b/gold/testsuite/ver_test_main.cc
@@ -0,0 +1,54 @@
+// basic_test.cc -- a test case for gold
+
+// Copyright 2007 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.
+
+#include <cassert>
+
+#include "ver_test.h"
+
+int
+main()
+{
+ assert(t1());
+ assert(t2());
+ assert(t3());
+ return 0;
+}
+
+// Calls a function in file2 that has two versions and verifies
+// that the default version is called.
+
+bool
+t2()
+{
+ TRACE
+ return t2_2() == 22;
+}
+
+// Call a function in a shared library that calls explicitly
+// the version of t1_2() defined in another shared library.
+
+bool
+t3()
+{
+ TRACE
+ return t3_2() == 12;
+}
diff --git a/gold/x86_64.cc b/gold/x86_64.cc
index ddd125d..afa8070 100644
--- a/gold/x86_64.cc
+++ b/gold/x86_64.cc
@@ -1483,7 +1483,10 @@ Target_x86_64::Relocate::relocate(const Relocate_info<64, false>* relinfo,
case elfcpp::R_X86_64_PLT32:
gold_assert(gsym == NULL
|| gsym->has_plt_offset()
- || gsym->final_value_is_known());
+ || gsym->final_value_is_known()
+ || (gsym->is_defined()
+ && !gsym->is_from_dynobj()
+ && !gsym->is_preemptible()));
// Note: while this code looks the same as for R_X86_64_PC32, it
// behaves differently because psymval was set to point to
// the PLT entry, rather than the symbol, in Scan::global().