diff options
author | Ian Lance Taylor <iant@google.com> | 2007-12-21 23:31:19 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2007-12-21 23:31:19 +0000 |
commit | 99f8facac923848a9496cc34235b608e05a7f160 (patch) | |
tree | d35f563ca6e357ff8ff87d3d3e45c2098b702f46 /gold/testsuite | |
parent | dc96b90a103d5363c3bb298178b6ae3c5124aa19 (diff) | |
download | fsf-binutils-gdb-99f8facac923848a9496cc34235b608e05a7f160.zip fsf-binutils-gdb-99f8facac923848a9496cc34235b608e05a7f160.tar.gz fsf-binutils-gdb-99f8facac923848a9496cc34235b608e05a7f160.tar.bz2 |
From Cary Coutant: Fix handling of versioned symbols, add some tests.
Diffstat (limited to 'gold/testsuite')
-rw-r--r-- | gold/testsuite/Makefile.am | 20 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 38 | ||||
-rw-r--r-- | gold/testsuite/ver_test.h | 40 | ||||
-rw-r--r-- | gold/testsuite/ver_test_1.cc | 33 | ||||
-rw-r--r-- | gold/testsuite/ver_test_2.cc | 40 | ||||
-rw-r--r-- | gold/testsuite/ver_test_2.script | 31 | ||||
-rw-r--r-- | gold/testsuite/ver_test_3.cc | 33 | ||||
-rw-r--r-- | gold/testsuite/ver_test_4.cc | 53 | ||||
-rw-r--r-- | gold/testsuite/ver_test_4.script | 35 | ||||
-rw-r--r-- | gold/testsuite/ver_test_main.cc | 54 |
10 files changed, 373 insertions, 4 deletions
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; +} |