diff options
author | Ian Lance Taylor <iant@google.com> | 2008-01-15 23:41:28 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2008-01-15 23:41:28 +0000 |
commit | 091244672e9cb571cb7272d491826f85de871ced (patch) | |
tree | 40be47b8e61a974e262595c7aa516f597970f285 /gold/testsuite | |
parent | 58da7b1b61de1ecfbcae3bf0050e8bb65d3ff547 (diff) | |
download | gdb-091244672e9cb571cb7272d491826f85de871ced.zip gdb-091244672e9cb571cb7272d491826f85de871ced.tar.gz gdb-091244672e9cb571cb7272d491826f85de871ced.tar.bz2 |
From Andrew Chatham and Craig Silverstein: Add support for version
scripts.
Diffstat (limited to 'gold/testsuite')
-rw-r--r-- | gold/testsuite/Makefile.am | 18 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 23 | ||||
-rw-r--r-- | gold/testsuite/ver_matching_def.cc | 69 | ||||
-rwxr-xr-x | gold/testsuite/ver_matching_test.sh | 80 | ||||
-rw-r--r-- | gold/testsuite/version_script.map | 28 |
5 files changed, 207 insertions, 11 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 46e949c..5820038 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -490,10 +490,10 @@ 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_2.so: ver_test_2.o $(srcdir)/ver_test_2.script ver_test_4.so gcctestdir/ld + $(CXXLINK) -Bgcctestdir/ -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 gcctestdir/ld + $(CXXLINK) -Bgcctestdir/ -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 @@ -508,5 +508,15 @@ script_test_1_SOURCES = script_test_1.cc script_test_1_DEPENDENCIES = gcctestdir/ld script_test_1.t script_test_1_LDFLAGS = -Bgcctestdir/ -Wl,-R,. -T $(srcdir)/script_test_1.t +if OBJDUMP_AND_CPPFILT +check_SCRIPTS += ver_matching_test.sh +check_DATA += ver_matching_test.stdout +MOSTLYCLEANFILES += ver_matching_test.stdout +ver_matching_def.so: ver_matching_def.cc gcctestdir/ld + $(CXXLINK) -O0 -Bgcctestdir/ -shared $(srcdir)/ver_matching_def.cc -Wl,--version-script=$(srcdir)/version_script.map +ver_matching_test.stdout: ver_matching_def.so + objdump -T ver_matching_def.so | c++filt > ver_matching_test.stdout +endif OBJDUMP_AND_CPPFILT + endif GCC endif NATIVE_LINKER diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index f61e4e5..8f51d28 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -179,6 +179,9 @@ check_PROGRAMS = object_unittest$(EXEEXT) $(am__EXEEXT_1) \ @NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \ @NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \ @NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) +@GCC_TRUE@@NATIVE_LINKER_TRUE@@OBJDUMP_AND_CPPFILT_TRUE@am__append_11 = ver_matching_test.sh +@GCC_TRUE@@NATIVE_LINKER_TRUE@@OBJDUMP_AND_CPPFILT_TRUE@am__append_12 = ver_matching_test.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@@OBJDUMP_AND_CPPFILT_TRUE@am__append_13 = ver_matching_test.stdout subdir = testsuite DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -633,6 +636,8 @@ MSGMERGE = @MSGMERGE@ NATIVE_LINKER_FALSE = @NATIVE_LINKER_FALSE@ NATIVE_LINKER_TRUE = @NATIVE_LINKER_TRUE@ NO_WERROR = @NO_WERROR@ +OBJDUMP_AND_CPPFILT_FALSE = @OBJDUMP_AND_CPPFILT_FALSE@ +OBJDUMP_AND_CPPFILT_TRUE = @OBJDUMP_AND_CPPFILT_TRUE@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -722,13 +727,13 @@ INCLUDES = \ # .o's), but not all of them (such as .so's and .err files). We # improve on that here. automake-1.9 info docs say "mostlyclean" is # the right choice for files 'make' builds that people rebuild. -MOSTLYCLEANFILES = *.so $(am__append_9) +MOSTLYCLEANFILES = *.so $(am__append_9) $(am__append_13) # We will add to these later, for each individual test. Note # that we add each test under check_SCRIPTS or check_PROGRAMS; # the TESTS variable is automatically populated from these. -check_SCRIPTS = $(am__append_7) -check_DATA = $(am__append_8) +check_SCRIPTS = $(am__append_7) $(am__append_11) +check_DATA = $(am__append_8) $(am__append_12) TESTS = $(check_SCRIPTS) $(check_PROGRAMS) # --------------------------------------------------------------------- @@ -1561,10 +1566,10 @@ uninstall-am: uninstall-info-am @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_2.so: ver_test_2.o $(srcdir)/ver_test_2.script ver_test_4.so gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -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 gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -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 @@ -1573,6 +1578,10 @@ uninstall-am: uninstall-info-am @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 $@ $< +@GCC_TRUE@@NATIVE_LINKER_TRUE@@OBJDUMP_AND_CPPFILT_TRUE@ver_matching_def.so: ver_matching_def.cc gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@@OBJDUMP_AND_CPPFILT_TRUE@ $(CXXLINK) -O0 -Bgcctestdir/ -shared $(srcdir)/ver_matching_def.cc -Wl,--version-script=$(srcdir)/version_script.map +@GCC_TRUE@@NATIVE_LINKER_TRUE@@OBJDUMP_AND_CPPFILT_TRUE@ver_matching_test.stdout: ver_matching_def.so +@GCC_TRUE@@NATIVE_LINKER_TRUE@@OBJDUMP_AND_CPPFILT_TRUE@ objdump -T ver_matching_def.so | c++filt > ver_matching_test.stdout # 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_matching_def.cc b/gold/testsuite/ver_matching_def.cc new file mode 100644 index 0000000..71d8d32 --- /dev/null +++ b/gold/testsuite/ver_matching_def.cc @@ -0,0 +1,69 @@ +// ver_matching_def.cc - test matching rules in version_script.map + +// Copyright 2007 Free Software Foundation, Inc. +// Written by Cary Coutant <ccoutant@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. + +extern "C" { +void foo() {} // V1 +void foo1() {} // local +}; + +void bar() {} // V1 +void bar1() {} // global + +extern "C" { +void bar2() {} // V1 +}; + +namespace myns { +void blah() {} // V1 +void bip() {} // V1 + +class Stuff { + public: + Stuff() {} // V1 +}; +} + +class Biz { + public: + Biz() {} // global +}; + +namespace otherns { +Biz biz; // global +myns::Stuff stuff; // V2 +}; + +extern "C" { +void blaza() {} // V1 +void blaza1() {} // V1 + +void original_blaza2() {} // V2 +__asm__(".symver original_blaza2,blaza2@@V2"); // overrides script + +void bla() {} // global +void blaz() {} // V2 +void blazb() {} // V2 + +int globaoeufxstuff = 0; // V1 +int globaoeufostuff = 0; // global +float sizeof_headers = 50.0; // V1 +}; diff --git a/gold/testsuite/ver_matching_test.sh b/gold/testsuite/ver_matching_test.sh new file mode 100755 index 0000000..48dd9a5 --- /dev/null +++ b/gold/testsuite/ver_matching_test.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +# ver_matching_test.sh -- a test case for version script matching + +# 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 file goes with ver_matching_def.cc, a C++ source file +# constructed with several symbols mapped via version_script.map. We +# run readelf on the resulting shared object and check that each +# symbol has the correct version. + +check() +{ + if ! grep -q "$2" "$1" + then + echo "Did not find expected symbol in $1:" + echo " $2" + echo "" + echo "Actual output below:" + cat "$1" + exit 1 + fi +} + +check_missing() +{ + if grep -q "$2" "$1" + then + echo "Found unexpected symbol in $1:" + echo " $2" + echo "" + echo "Actual output below:" + cat "$1" + exit 1 + fi +} + +check ver_matching_test.stdout "V1 *sizeof_headers$" +check ver_matching_test.stdout "Base *globaoeufostuff$" +check ver_matching_test.stdout "V1 *globaoeufxstuff$" +check ver_matching_test.stdout "V2 *otherns::stuff$" +check ver_matching_test.stdout "Base *otherns::biz$" +check ver_matching_test.stdout "V1 *foo$" +check ver_matching_test.stdout "V1 *bar()$" +check ver_matching_test.stdout "Base *bar1()$" +check ver_matching_test.stdout "V1 *bar2$" +check ver_matching_test.stdout "V1 *myns::blah()$" +check ver_matching_test.stdout "V1 *myns::bip()$" +check ver_matching_test.stdout "V1 *myns::Stuff::Stuff()$" +check ver_matching_test.stdout "Base *Biz::Biz()$" +check ver_matching_test.stdout "V1 *blaza1$" +check ver_matching_test.stdout "V2 *blaza2$" +check ver_matching_test.stdout "V1 *blaza$" +check ver_matching_test.stdout "Base *bla$" +check ver_matching_test.stdout "V2 *blaz$" +check ver_matching_test.stdout "V2 *blazb$" + +# TODO: foo1 should be a local symbol and not show up in the .dynsym +# dump, but we haven't figured out how to suppress it yet. +# check_missing ver_matching_test.stdout "foo1" + +exit 0 diff --git a/gold/testsuite/version_script.map b/gold/testsuite/version_script.map new file mode 100644 index 0000000..2a17523 --- /dev/null +++ b/gold/testsuite/version_script.map @@ -0,0 +1,28 @@ +V1 { + global: + extern "C++" + { + "bar()"; + myns::*; + }; + foo; + blaza*; + bar*; + # Would be a keyword in a linker script. + SECTIONS; + sizeof_headers; + # Crazy globbiness + glob*f[^A-Zo]stuff; + + local: + *foo*; +}; + +V2 { + global: + extern "C++" { + otherns::stuff; + }; + blaz*; + foo; +} V1; |