diff options
author | Cary Coutant <ccoutant@google.com> | 2009-05-19 22:14:17 +0000 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2009-05-19 22:14:17 +0000 |
commit | 6551490093fe8f141c073324b2c4387ce93fa712 (patch) | |
tree | c35b9675ce37ee8303e3c60cc04b57b78beed857 /gold/testsuite | |
parent | c1711530e652a14bc0df9b603c73e350b5dfe5ec (diff) | |
download | fsf-binutils-gdb-6551490093fe8f141c073324b2c4387ce93fa712.zip fsf-binutils-gdb-6551490093fe8f141c073324b2c4387ce93fa712.tar.gz fsf-binutils-gdb-6551490093fe8f141c073324b2c4387ce93fa712.tar.bz2 |
2009-05-19 Doug Kwan <dougkwan@google.com>
* archive.cc (Archive::Archive): Move constructor from archive.h
to here. Initialize no_export_.
(Archive::get_elf_object_for_member): Set no_export flag of object.
* archive.h (Archive::Archive): Move constructor body to
archive.cc.
(Archive::no_export): New method.
(Archive::no_export_): New field.
* object.h (Object::Object): Initialize no_export_ to false.
(Object::no_export, Object::set_no_export): New methods.
(Object::no_export_): New field.
* options.cc (General_options::parse_exclude_libs): New method.
(General_options::check_excluded_libs) Same.
* options.h (exclude_libs): New option.
(General_options::check_excluded_libs): New method declaration.
(General_options::excluded_libs_): New field.
* symtab.cc (Symbol_table::add_from_relobj): Hide symbols with
default or protected visibility if an object has no-export flag set.
testsuite/Makefile.am (check_PROGRAMS): Add exclude_libs_test.
(check_SCRIPTS): Add exclude_libs_test.sh.
(check_DATA): Add exclude_libs_test.syms.
(MOSTLYCLEANFILES): Add exclude_libs_test.syms,
libexclude_libs_test_1.a and libexclude_libs_test_2.a.
(exclude_libs_test_SOURCES, exclude_libs_test_DEPENDENCIES,
exclude_libs_test_LDFLAGS and exclude_libs_test_LDADD): Define.
(exclude_libs_test.syms, libexclude_libs_test_1.a,
libexclude_libs_test_2.a): New rules.
* testsuite/Makefile.in: Regenerate.
* testsuite/exclude_libs_test.c: New file.
* testsuite/exclude_libs_test.sh: Ditto.
* testsuite/exclude_libs_test_1.c: Ditto.
* testsuite/exclude_libs_test_2.c: Ditto.
Diffstat (limited to 'gold/testsuite')
-rw-r--r-- | gold/testsuite/Makefile.am | 18 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 47 | ||||
-rw-r--r-- | gold/testsuite/exclude_libs_test.c | 12 | ||||
-rwxr-xr-x | gold/testsuite/exclude_libs_test.sh | 59 | ||||
-rw-r--r-- | gold/testsuite/exclude_libs_test_1.c | 24 | ||||
-rw-r--r-- | gold/testsuite/exclude_libs_test_2.c | 24 |
6 files changed, 178 insertions, 6 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 1c699f7..80298ce 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -1038,5 +1038,23 @@ empty.syms: endif PLUGINS +check_PROGRAMS += exclude_libs_test +check_SCRIPTS += exclude_libs_test.sh +check_DATA += exclude_libs_test.syms +MOSTLYCLEANFILES += exclude_libs_test.syms libexclude_libs_test_1.a \ + libexclude_libs_test_2.a +exclude_libs_test_SOURCES = exclude_libs_test.c +exclude_libs_test_DEPENDENCIES = gcctestdir/ld libexclude_libs_test_1.a \ + libexclude_libs_test_2.a +exclude_libs_test_LDFLAGS = -Bgcctestdir/ -L. \ + -Wl,--exclude-libs,dummy:libexclude_libs_test_1 +exclude_libs_test_LDADD = -lexclude_libs_test_1 -lexclude_libs_test_2 +exclude_libs_test.syms: exclude_libs_test + $(TEST_READELF) -sW $< >$@ 2>/dev/null +libexclude_libs_test_1.a: exclude_libs_test_1.o + $(TEST_AR) rc $@ $^ +libexclude_libs_test_2.a: exclude_libs_test_2.o + $(TEST_AR) rc $@ $^ + endif GCC endif NATIVE_LINKER diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index 56fe7ac..40ee958 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -48,7 +48,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ $(am__EXEEXT_7) $(am__EXEEXT_8) $(am__EXEEXT_9) \ $(am__EXEEXT_10) $(am__EXEEXT_11) $(am__EXEEXT_12) \ $(am__EXEEXT_13) $(am__EXEEXT_14) $(am__EXEEXT_15) \ - $(am__EXEEXT_16) + $(am__EXEEXT_16) $(am__EXEEXT_17) @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_1 = basic_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ basic_static_test basic_pic_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ basic_static_pic_test \ @@ -317,6 +317,14 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_4.err +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_24 = exclude_libs_test +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_25 = exclude_libs_test.sh +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_26 = exclude_libs_test.syms +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_27 = exclude_libs_test.syms libexclude_libs_test_1.a \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_2.a + +@GCC_FALSE@exclude_libs_test_DEPENDENCIES = +@NATIVE_LINKER_FALSE@exclude_libs_test_DEPENDENCIES = subdir = testsuite DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -421,6 +429,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_4$(EXEEXT) +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_17 = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ exclude_libs_test$(EXEEXT) basic_pic_test_SOURCES = basic_pic_test.c basic_pic_test_OBJECTS = basic_pic_test.$(OBJEXT) basic_pic_test_LDADD = $(LDADD) @@ -528,6 +538,10 @@ am__exception_test_SOURCES_DIST = exception_test_main.cc \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_test_2.$(OBJEXT) exception_test_OBJECTS = $(am_exception_test_OBJECTS) exception_test_LDADD = $(LDADD) +am__exclude_libs_test_SOURCES_DIST = exclude_libs_test.c +@GCC_TRUE@@NATIVE_LINKER_TRUE@am_exclude_libs_test_OBJECTS = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ exclude_libs_test.$(OBJEXT) +exclude_libs_test_OBJECTS = $(am_exclude_libs_test_OBJECTS) flagstest_compress_debug_sections_SOURCES = \ flagstest_compress_debug_sections.c flagstest_compress_debug_sections_OBJECTS = \ @@ -884,6 +898,7 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \ $(exception_shared_1_test_SOURCES) \ $(exception_shared_2_test_SOURCES) \ $(exception_static_test_SOURCES) $(exception_test_SOURCES) \ + $(exclude_libs_test_SOURCES) \ flagstest_compress_debug_sections.c flagstest_o_specialfile.c \ flagstest_o_specialfile_and_compress_debug_sections.c \ $(initpri1_SOURCES) $(justsyms_SOURCES) many_sections_r_test.c \ @@ -937,6 +952,7 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \ $(am__exception_shared_2_test_SOURCES_DIST) \ $(am__exception_static_test_SOURCES_DIST) \ $(am__exception_test_SOURCES_DIST) \ + $(am__exclude_libs_test_SOURCES_DIST) \ flagstest_compress_debug_sections.c flagstest_o_specialfile.c \ flagstest_o_specialfile_and_compress_debug_sections.c \ $(am__initpri1_SOURCES_DIST) $(am__justsyms_SOURCES_DIST) \ @@ -1158,13 +1174,14 @@ TEST_AR = $(top_builddir)/../binutils/ar # .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_16) $(am__append_23) +MOSTLYCLEANFILES = *.so $(am__append_16) $(am__append_23) \ + $(am__append_27) # 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_2) $(am__append_21) -check_DATA = $(am__append_3) $(am__append_22) +check_SCRIPTS = $(am__append_2) $(am__append_21) $(am__append_25) +check_DATA = $(am__append_3) $(am__append_22) $(am__append_26) BUILT_SOURCES = $(am__append_14) TESTS = $(check_SCRIPTS) $(check_PROGRAMS) @@ -1491,6 +1508,14 @@ binary_unittest_SOURCES = binary_unittest.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_2_DEPENDENCIES = gcctestdir/ld libthinall.a @GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_2_LDFLAGS = -Bgcctestdir/ -L. @GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_2_LDADD = -lthinall +@GCC_TRUE@@NATIVE_LINKER_TRUE@exclude_libs_test_SOURCES = exclude_libs_test.c +@GCC_TRUE@@NATIVE_LINKER_TRUE@exclude_libs_test_DEPENDENCIES = gcctestdir/ld libexclude_libs_test_1.a \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_2.a + +@GCC_TRUE@@NATIVE_LINKER_TRUE@exclude_libs_test_LDFLAGS = -Bgcctestdir/ -L. \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ -Wl,--exclude-libs,dummy:libexclude_libs_test_1 + +@GCC_TRUE@@NATIVE_LINKER_TRUE@exclude_libs_test_LDADD = -lexclude_libs_test_1 -lexclude_libs_test_2 all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am @@ -1505,9 +1530,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign testsuite/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu testsuite/Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign testsuite/Makefile + $(AUTOMAKE) --gnu testsuite/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ @@ -1598,6 +1623,9 @@ exception_static_test$(EXEEXT): $(exception_static_test_OBJECTS) $(exception_sta exception_test$(EXEEXT): $(exception_test_OBJECTS) $(exception_test_DEPENDENCIES) @rm -f exception_test$(EXEEXT) $(CXXLINK) $(exception_test_LDFLAGS) $(exception_test_OBJECTS) $(exception_test_LDADD) $(LIBS) +exclude_libs_test$(EXEEXT): $(exclude_libs_test_OBJECTS) $(exclude_libs_test_DEPENDENCIES) + @rm -f exclude_libs_test$(EXEEXT) + $(LINK) $(exclude_libs_test_LDFLAGS) $(exclude_libs_test_OBJECTS) $(exclude_libs_test_LDADD) $(LIBS) @GCC_FALSE@flagstest_compress_debug_sections$(EXEEXT): $(flagstest_compress_debug_sections_OBJECTS) $(flagstest_compress_debug_sections_DEPENDENCIES) @GCC_FALSE@ @rm -f flagstest_compress_debug_sections$(EXEEXT) @GCC_FALSE@ $(LINK) $(flagstest_compress_debug_sections_LDFLAGS) $(flagstest_compress_debug_sections_OBJECTS) $(flagstest_compress_debug_sections_LDADD) $(LIBS) @@ -1854,6 +1882,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exception_test_1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exception_test_2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exception_test_main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exclude_libs_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_compress_debug_sections.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_o_specialfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_o_specialfile_and_compress_debug_sections.Po@am__quote@ @@ -2564,6 +2593,12 @@ uninstall-am: uninstall-info-am @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@empty.syms: @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ @echo "" >empty.syms @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ @echo "Symbol table" >>empty.syms +@GCC_TRUE@@NATIVE_LINKER_TRUE@exclude_libs_test.syms: exclude_libs_test +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -sW $< >$@ 2>/dev/null +@GCC_TRUE@@NATIVE_LINKER_TRUE@libexclude_libs_test_1.a: exclude_libs_test_1.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) rc $@ $^ +@GCC_TRUE@@NATIVE_LINKER_TRUE@libexclude_libs_test_2.a: exclude_libs_test_2.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) rc $@ $^ # 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/exclude_libs_test.c b/gold/testsuite/exclude_libs_test.c new file mode 100644 index 0000000..3cb5645 --- /dev/null +++ b/gold/testsuite/exclude_libs_test.c @@ -0,0 +1,12 @@ +extern void lib1_default (void); +extern void lib2_default (void); + +int +main (int argc __attribute__ ((unused)), + char** argv __attribute__ ((unused))) +{ + lib1_default (); + lib2_default (); + return 0; +} + diff --git a/gold/testsuite/exclude_libs_test.sh b/gold/testsuite/exclude_libs_test.sh new file mode 100755 index 0000000..a82be89 --- /dev/null +++ b/gold/testsuite/exclude_libs_test.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +# exclude_libs_test.sh -- test that library symbols are not exported. + +# Copyright 2009 Free Software Foundation, Inc. +# Written by Doug Kwan <dougkwan@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 exclude_libs_test.c, a C source file +# linked with option -Wl,--exclude-libs. We run readelf on +# the resulting executable and check that symbols from two test library +# archives are correctly hidden or left unmodified. + +check() +{ + file=$1 + sym=$2 + vis=$3 + + found=`grep " $sym\$" $file` + if test -z "$found"; then + echo "Symbol $sym not found." + exit 1 + fi + + match_vis=`grep " $sym\$" $file | grep " $vis "` + if test -z "$match_vis"; then + echo "Expected symbol $sym to have visibility $vis but found" + echo "$found" + exit 1 + fi +} + +check "exclude_libs_test.syms" "lib1_default" "HIDDEN" +check "exclude_libs_test.syms" "lib1_protected" "HIDDEN" +check "exclude_libs_test.syms" "lib1_internal" "INTERNAL" +check "exclude_libs_test.syms" "lib1_hidden" "HIDDEN" +check "exclude_libs_test.syms" "lib2_default" "DEFAULT" +check "exclude_libs_test.syms" "lib2_protected" "PROTECTED" +check "exclude_libs_test.syms" "lib2_internal" "INTERNAL" +check "exclude_libs_test.syms" "lib2_hidden" "HIDDEN" + +exit 0 diff --git a/gold/testsuite/exclude_libs_test_1.c b/gold/testsuite/exclude_libs_test_1.c new file mode 100644 index 0000000..ced1aad --- /dev/null +++ b/gold/testsuite/exclude_libs_test_1.c @@ -0,0 +1,24 @@ +void lib1_default (void); +void lib1_hidden (void); +void lib1_internal (void); +void lib1_protected (void); + +void __attribute__((visibility ("default"))) +lib1_default (void) +{ +} + +void __attribute__((visibility ("hidden"))) +lib1_hidden (void) +{ +} + +void __attribute__((visibility ("internal"))) +lib1_internal (void) +{ +} + +void __attribute__((visibility ("protected"))) +lib1_protected (void) +{ +} diff --git a/gold/testsuite/exclude_libs_test_2.c b/gold/testsuite/exclude_libs_test_2.c new file mode 100644 index 0000000..a8952e7 --- /dev/null +++ b/gold/testsuite/exclude_libs_test_2.c @@ -0,0 +1,24 @@ +void lib2_default (void); +void lib2_hidden (void); +void lib2_internal (void); +void lib2_protected (void); + +void __attribute__((visibility ("default"))) +lib2_default (void) +{ +} + +void __attribute__((visibility ("hidden"))) +lib2_hidden (void) +{ +} + +void __attribute__((visibility ("internal"))) +lib2_internal (void) +{ +} + +void __attribute__((visibility ("protected"))) +lib2_protected (void) +{ +} |