diff options
author | Cary Coutant <ccoutant@google.com> | 2014-02-05 14:01:52 -0800 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2014-02-05 18:01:47 -0800 |
commit | fd834e57ffce2f5dbe3443f034e68cebd63ee89a (patch) | |
tree | 6a5324243f95c8d47ee76b928cb3ca02076e184e /gold | |
parent | ee1e2d4fb692736c754b42b69eb88c1f436c5f15 (diff) | |
download | gdb-fd834e57ffce2f5dbe3443f034e68cebd63ee89a.zip gdb-fd834e57ffce2f5dbe3443f034e68cebd63ee89a.tar.gz gdb-fd834e57ffce2f5dbe3443f034e68cebd63ee89a.tar.bz2 |
Fix problems with the --dynamic-list option.
PR gold/13577 complains that even though symbols listed in
the --dynamic-list script are exported, they are still bound symbolically
if -Bsymbolic is also used. There are two underlying problems here.
First, -Bsymbolic should be overridden by --dynamic-list, since the
dynamic list provides an explicit list of symbols that are not bound
within the library, and if we go ahead and set DT_SYMBOLIC, then the
dynamic loader will bind it within the library anyway. Second, gold
did not properly identify the symbols listed in the file as preemptible.
PR gold/16530 complains that symbols listed in the --dynamic-list script
can still be garbage collected. I've fixed this by checking the symbols
as they're added to the symbol table. (Unlike the --export-dynamic-symbol
option, we can't iterate over the list, because the --dynamic-list script
can have wildcards in it.)
gold/
2014-02-05 Cary Coutant <ccoutant@google.com>
PR gold/13577
* options.cc (General_options::parse_dynamic_list):
Set have_dynamic_list_.
(General_options::General_options): Initialize have_dynamic_list_.
(General_options::finalize): Turn off -Bsymbolic and
-Bsymbolic-functions if --dynamic-list provided.
* options.h (General_options::have_dynamic_list): New function.
(General_options::have_dynamic_list_): New data member.
* symtab.h (Symbol::is_preemptible): Handle --dynamic-list
correctly.
PR gold/16530
* symtab.cc (Symbol_table::add_from_relobj): If symbol is named
in --dynamic-list, mark it.
* testsuite/Makefile.am (gc_dynamic_list_test.sh): New test case.
(dynamic_list_2): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/dynamic_list_2.cc: New file.
* testsuite/dynamic_list_2.t: New file.
* testsuite/dynamic_list_lib1.cc: New file.
* testsuite/dynamic_list_lib2.cc: New file.
* testsuite/gc_dynamic_list_test.c: New file.
* testsuite/gc_dynamic_list_test.sh: New file.
* testsuite/gc_dynamic_list_test.t: New file.
Diffstat (limited to 'gold')
-rw-r--r-- | gold/options.cc | 9 | ||||
-rw-r--r-- | gold/options.h | 7 | ||||
-rw-r--r-- | gold/symtab.cc | 3 | ||||
-rw-r--r-- | gold/symtab.h | 10 | ||||
-rw-r--r-- | gold/testsuite/Makefile.am | 26 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 47 | ||||
-rw-r--r-- | gold/testsuite/dynamic_list_2.cc | 40 | ||||
-rw-r--r-- | gold/testsuite/dynamic_list_2.t | 27 | ||||
-rw-r--r-- | gold/testsuite/dynamic_list_lib1.cc | 37 | ||||
-rw-r--r-- | gold/testsuite/dynamic_list_lib2.cc | 49 | ||||
-rw-r--r-- | gold/testsuite/gc_dynamic_list_test.c | 34 | ||||
-rwxr-xr-x | gold/testsuite/gc_dynamic_list_test.sh | 39 | ||||
-rw-r--r-- | gold/testsuite/gc_dynamic_list_test.t | 25 |
13 files changed, 347 insertions, 6 deletions
diff --git a/gold/options.cc b/gold/options.cc index 000e6d0..6b49459 100644 --- a/gold/options.cc +++ b/gold/options.cc @@ -549,6 +549,7 @@ General_options::parse_dynamic_list(const char*, const char* arg, { if (!read_dynamic_list(arg, cmdline, &this->dynamic_list_)) gold::gold_fatal(_("unable to parse dynamic-list script file %s"), arg); + this->have_dynamic_list_ = true; } void @@ -918,6 +919,7 @@ General_options::General_options() do_demangle_(false), plugins_(NULL), dynamic_list_(), + have_dynamic_list_(false), incremental_mode_(INCREMENTAL_OFF), incremental_disposition_(INCREMENTAL_STARTUP), incremental_startup_disposition_(INCREMENTAL_CHECK), @@ -1199,6 +1201,13 @@ General_options::finalize() // in the path, as appropriate. this->add_sysroot(); + // --dynamic-list overrides -Bsymbolic and -Bsymbolic-functions. + if (this->have_dynamic_list()) + { + this->set_Bsymbolic(false); + this->set_Bsymbolic_functions(false); + } + // Now that we've normalized the options, check for contradictory ones. if (this->shared() && this->is_static()) gold_fatal(_("-shared and -static are incompatible")); diff --git a/gold/options.h b/gold/options.h index a2f5a88..da1ade9 100644 --- a/gold/options.h +++ b/gold/options.h @@ -1438,6 +1438,11 @@ class General_options in_dynamic_list(const char* symbol) const { return this->dynamic_list_.version_script_info()->symbol_is_local(symbol); } + // True if a --dynamic-list script was provided. + bool + have_dynamic_list() const + { return this->have_dynamic_list_; } + // Finalize the dynamic list. void finalize_dynamic_list() @@ -1591,6 +1596,8 @@ class General_options // script.cc, we store this as a Script_options object, even though // we only use a single Version_tree from it. Script_options dynamic_list_; + // Whether a --dynamic-list file was provided. + bool have_dynamic_list_; // The incremental linking mode. Incremental_mode incremental_mode_; // The disposition given by the --incremental-changed, diff --git a/gold/symtab.cc b/gold/symtab.cc index 2e17529..225856a 100644 --- a/gold/symtab.cc +++ b/gold/symtab.cc @@ -1258,7 +1258,8 @@ Symbol_table::add_from_relobj( && res->is_externally_visible() && !res->is_from_dynobj() && (parameters->options().shared() - || parameters->options().export_dynamic())) + || parameters->options().export_dynamic() + || parameters->options().in_dynamic_list(res->name()))) this->gc_mark_symbol(res); if (is_defined_in_discarded_section) diff --git a/gold/symtab.h b/gold/symtab.h index 1232c97..9aff274c 100644 --- a/gold/symtab.h +++ b/gold/symtab.h @@ -576,8 +576,14 @@ class Symbol if (!parameters->options().shared()) return false; - // If the user used -Bsymbolic, then nothing is preemptible. - if (parameters->options().Bsymbolic()) + // If the symbol was named in a --dynamic-list script, it is preemptible. + if (parameters->options().in_dynamic_list(this->name())) + return true; + + // If the user used -Bsymbolic or provided a --dynamic-list script, + // then nothing (else) is preemptible. + if (parameters->options().Bsymbolic() + || parameters->options().have_dynamic_list()) return false; // If the user used -Bsymbolic-functions, then functions are not diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index aca9df8..0b22c13 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -203,6 +203,16 @@ pr14265: pr14265.o pr14265.stdout: pr14265 $(TEST_NM) --format=bsd --numeric-sort $< > $@ +check_SCRIPTS += gc_dynamic_list_test.sh +check_DATA += gc_dynamic_list_test.stdout +MOSTLYCLEANFILES += gc_dynamic_list_test +gc_dynamic_list_test.o: gc_dynamic_list_test.c + $(COMPILE) -c -ffunction-sections -o $@ $< +gc_dynamic_list_test: gc_dynamic_list_test.o gcctestdir/ld $(srcdir)/gc_dynamic_list_test.t + $(LINK) -Bgcctestdir/ -Wl,--gc-sections -Wl,--dynamic-list,$(srcdir)/gc_dynamic_list_test.t gc_dynamic_list_test.o +gc_dynamic_list_test.stdout: gc_dynamic_list_test + $(TEST_NM) gc_dynamic_list_test > $@ + check_SCRIPTS += icf_test.sh check_DATA += icf_test.map MOSTLYCLEANFILES += icf_test icf_test.map @@ -1465,6 +1475,22 @@ dynamic_list: basic_test.o gcctestdir/ld $(srcdir)/dynamic_list.t dynamic_list.stdout: dynamic_list $(TEST_READELF) -W --dyn-syms dynamic_list > dynamic_list.stdout +check_PROGRAMS += dynamic_list_2 +dynamic_list_2_SOURCES = dynamic_list_2.cc +dynamic_list_2_DEPENDENCIES = gcctestdir/ld dynamic_list_lib1.so dynamic_list_lib2.so +dynamic_list_2_LDFLAGS = -Bgcctestdir/ -L. -Wl,-R,. -Wl,--no-as-needed +dynamic_list_2_LDADD = dynamic_list_lib1.so dynamic_list_lib2.so + +dynamic_list_lib1.so: gcctestdir/ld dynamic_list_lib1.o + $(CXXLINK) -Bgcctestdir/ -shared dynamic_list_lib1.o +dynamic_list_lib1.o: dynamic_list_lib1.cc + $(CXXCOMPILE) -c -fpic -o $@ $< + +dynamic_list_lib2.so: gcctestdir/ld dynamic_list_lib2.o $(srcdir)/dynamic_list_2.t + $(CXXLINK) -Bgcctestdir/ -shared -Wl,--dynamic-list,$(srcdir)/dynamic_list_2.t dynamic_list_lib2.o +dynamic_list_lib2.o: dynamic_list_lib2.cc + $(CXXCOMPILE) -c -fpic -o $@ $< + check_PROGRAMS += thin_archive_test_1 MOSTLYCLEANFILES += libthin1.a libthin3.a libthinall.a \ alt/thin_archive_test_2.o alt/thin_archive_test_4.o \ diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index b86bea9..6a9228f 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -78,7 +78,9 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_2 = incremental_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test.sh gc_tls_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test.sh \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr14265.sh icf_test.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr14265.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_dynamic_list_test.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_so_test.sh \ @@ -109,7 +111,9 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_tls_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test.stdout \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr14265.stdout icf_test.map \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr14265.stdout \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_dynamic_list_test.stdout \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.map \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test_1.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test_2.stdout \ @@ -132,7 +136,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test.cmdline \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test gc_tls_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test pr14265 \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test icf_test.map \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_dynamic_list_test icf_test \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.map \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test icf_safe_test.map \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_so_test \ @@ -318,6 +323,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ tls_phdrs_script_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ tls_script_test script_test_11 \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ dynamic_list_2 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_1 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_2 @GCC_FALSE@script_test_1_DEPENDENCIES = @@ -823,6 +829,7 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@NATIVE_LINKER_TRUE@ tls_phdrs_script_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ tls_script_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_11$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ dynamic_list_2$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_1$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_2$(EXEEXT) @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__EXEEXT_23 = plugin_test_1$(EXEEXT) \ @@ -967,6 +974,11 @@ discard_locals_test_DEPENDENCIES = libgoldtest.a ../libgold.a \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) discard_locals_test_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(discard_locals_test_LDFLAGS) $(LDFLAGS) -o $@ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am_dynamic_list_2_OBJECTS = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ dynamic_list_2.$(OBJEXT) +dynamic_list_2_OBJECTS = $(am_dynamic_list_2_OBJECTS) +dynamic_list_2_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ + $(dynamic_list_2_LDFLAGS) $(LDFLAGS) -o $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@am_exception_same_shared_test_OBJECTS = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_test_main.$(OBJEXT) exception_same_shared_test_OBJECTS = \ @@ -1773,6 +1785,7 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \ $(common_test_1_SOURCES) $(common_test_2_SOURCES) \ $(constructor_static_test_SOURCES) $(constructor_test_SOURCES) \ $(copy_test_SOURCES) $(discard_locals_test_SOURCES) \ + $(dynamic_list_2_SOURCES) \ $(exception_same_shared_test_SOURCES) \ $(exception_separate_shared_12_test_SOURCES) \ $(exception_separate_shared_21_test_SOURCES) \ @@ -2516,6 +2529,10 @@ LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@tls_script_test_DEPENDENCIES = $(tls_test_DEPENDENCIES) $(srcdir)/script_test_4.t @GCC_TRUE@@NATIVE_LINKER_TRUE@tls_script_test_LDFLAGS = $(tls_test_LDFLAGS) -Wl,-T,$(srcdir)/script_test_4.t @GCC_TRUE@@NATIVE_LINKER_TRUE@tls_script_test_LDADD = $(tls_test_LDADD) +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_2_SOURCES = dynamic_list_2.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_2_DEPENDENCIES = gcctestdir/ld dynamic_list_lib1.so dynamic_list_lib2.so +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_2_LDFLAGS = -Bgcctestdir/ -L. -Wl,-R,. -Wl,--no-as-needed +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_2_LDADD = dynamic_list_lib1.so dynamic_list_lib2.so @GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_1_SOURCES = thin_archive_main.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_1_DEPENDENCIES = gcctestdir/ld libthin1.a alt/libthin2.a @GCC_TRUE@@NATIVE_LINKER_TRUE@thin_archive_test_1_LDFLAGS = -Bgcctestdir/ -Lalt @@ -2711,6 +2728,9 @@ copy_test$(EXEEXT): $(copy_test_OBJECTS) $(copy_test_DEPENDENCIES) discard_locals_test$(EXEEXT): $(discard_locals_test_OBJECTS) $(discard_locals_test_DEPENDENCIES) @rm -f discard_locals_test$(EXEEXT) $(discard_locals_test_LINK) $(discard_locals_test_OBJECTS) $(discard_locals_test_LDADD) $(LIBS) +dynamic_list_2$(EXEEXT): $(dynamic_list_2_OBJECTS) $(dynamic_list_2_DEPENDENCIES) + @rm -f dynamic_list_2$(EXEEXT) + $(dynamic_list_2_LINK) $(dynamic_list_2_OBJECTS) $(dynamic_list_2_LDADD) $(LIBS) exception_same_shared_test$(EXEEXT): $(exception_same_shared_test_OBJECTS) $(exception_same_shared_test_DEPENDENCIES) @rm -f exception_same_shared_test$(EXEEXT) $(exception_same_shared_test_LINK) $(exception_same_shared_test_OBJECTS) $(exception_same_shared_test_LDADD) $(LIBS) @@ -3449,6 +3469,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/constructor_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copy_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/discard_locals_test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynamic_list_2.Po@am__quote@ @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@ @@ -3808,6 +3829,8 @@ gc_orphan_section_test.sh.log: gc_orphan_section_test.sh @p='gc_orphan_section_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) pr14265.sh.log: pr14265.sh @p='pr14265.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +gc_dynamic_list_test.sh.log: gc_dynamic_list_test.sh + @p='gc_dynamic_list_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) icf_test.sh.log: icf_test.sh @p='icf_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) icf_keep_unique_test.sh.log: icf_keep_unique_test.sh @@ -4134,6 +4157,8 @@ tls_script_test.log: tls_script_test$(EXEEXT) @p='tls_script_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) script_test_11.log: script_test_11$(EXEEXT) @p='script_test_11$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +dynamic_list_2.log: dynamic_list_2$(EXEEXT) + @p='dynamic_list_2$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) thin_archive_test_1.log: thin_archive_test_1$(EXEEXT) @p='thin_archive_test_1$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) thin_archive_test_2.log: thin_archive_test_2$(EXEEXT) @@ -4451,6 +4476,12 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -Wl,--gc-sections -Wl,-T,$(srcdir)/pr14265.t -o $@ $< @GCC_TRUE@@NATIVE_LINKER_TRUE@pr14265.stdout: pr14265 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) --format=bsd --numeric-sort $< > $@ +@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_dynamic_list_test.o: gc_dynamic_list_test.c +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -c -ffunction-sections -o $@ $< +@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_dynamic_list_test: gc_dynamic_list_test.o gcctestdir/ld $(srcdir)/gc_dynamic_list_test.t +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ -Wl,--gc-sections -Wl,--dynamic-list,$(srcdir)/gc_dynamic_list_test.t gc_dynamic_list_test.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_dynamic_list_test.stdout: gc_dynamic_list_test +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) gc_dynamic_list_test > $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test.o: icf_test.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $< @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test: icf_test.o gcctestdir/ld @@ -4980,6 +5011,16 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list.stdout: dynamic_list @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -W --dyn-syms dynamic_list > dynamic_list.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_lib1.so: gcctestdir/ld dynamic_list_lib1.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared dynamic_list_lib1.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_lib1.o: dynamic_list_lib1.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $< + +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_lib2.so: gcctestdir/ld dynamic_list_lib2.o $(srcdir)/dynamic_list_2.t +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared -Wl,--dynamic-list,$(srcdir)/dynamic_list_2.t dynamic_list_lib2.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@dynamic_list_lib2.o: dynamic_list_lib2.cc +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $< + @GCC_TRUE@@NATIVE_LINKER_TRUE@libthin1.a: thin_archive_test_1.o alt/thin_archive_test_2.o @GCC_TRUE@@NATIVE_LINKER_TRUE@ rm -f $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) crT $@ $^ diff --git a/gold/testsuite/dynamic_list_2.cc b/gold/testsuite/dynamic_list_2.cc new file mode 100644 index 0000000..34194b8 --- /dev/null +++ b/gold/testsuite/dynamic_list_2.cc @@ -0,0 +1,40 @@ +// dynamic_list_test_2.cc -- Test --dynamic-list with shared libraries. + +// Copyright 2014 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. + +// The goal of this program is to verify that the --dynamic-list option +// allows overrides for symbols listed in the file, and does symbolic +// binding for symbols not listed. + +#include <cstring> + +extern const char* test_foo(); +extern const char* test_bar(); + +int +main(void) +{ + if (strcmp(test_foo(), "override") != 0) + return 1; + if (strcmp(test_bar(), "original") != 0) + return 2; + return 0; +} diff --git a/gold/testsuite/dynamic_list_2.t b/gold/testsuite/dynamic_list_2.t new file mode 100644 index 0000000..a4e4381 --- /dev/null +++ b/gold/testsuite/dynamic_list_2.t @@ -0,0 +1,27 @@ +/* dynamic_list_2.t -- script file for building dynamic_list_lib2.so. + + Copyright 2014 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" { + "foo"; + }; +}; diff --git a/gold/testsuite/dynamic_list_lib1.cc b/gold/testsuite/dynamic_list_lib1.cc new file mode 100644 index 0000000..9bc0717 --- /dev/null +++ b/gold/testsuite/dynamic_list_lib1.cc @@ -0,0 +1,37 @@ +// dynamic_list_test_lib1.cc -- Test --dynamic-list with shared libraries. + +// Copyright 2014 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. + +// The goal of this program is to verify that the --dynamic-list option +// allows overrides for symbols listed in the file, and does symbolic +// binding for symbols not listed. + +extern "C" const char* +foo() +{ + return "override"; +} + +extern "C" const char* +bar() +{ + return "override"; +} diff --git a/gold/testsuite/dynamic_list_lib2.cc b/gold/testsuite/dynamic_list_lib2.cc new file mode 100644 index 0000000..2532a42 --- /dev/null +++ b/gold/testsuite/dynamic_list_lib2.cc @@ -0,0 +1,49 @@ +// dynamic_list_test_lib2.cc -- Test --dynamic-list with shared libraries. + +// Copyright 2014 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. + +// The goal of this program is to verify that the --dynamic-list option +// allows overrides for symbols listed in the file, and does symbolic +// binding for symbols not listed. + +extern "C" const char* +foo() +{ + return "original"; +} + +const char* +test_foo() +{ + return foo(); +} + +extern "C" const char* +bar() +{ + return "original"; +} + +const char* +test_bar() +{ + return bar(); +} diff --git a/gold/testsuite/gc_dynamic_list_test.c b/gold/testsuite/gc_dynamic_list_test.c new file mode 100644 index 0000000..3b84e98 --- /dev/null +++ b/gold/testsuite/gc_dynamic_list_test.c @@ -0,0 +1,34 @@ +// gc_dynamic_list_test.cc -- Check that --gc-sections honors --dynamic-list. + +// Copyright 2014 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. + +// The goal of this program is to verify that the symbol "keep" is not +// garbage-collected when it is named in a --dynamic-list script. + +extern void keep(void); + +void +keep(void) +{} + +int +main(void) +{ return 0; } diff --git a/gold/testsuite/gc_dynamic_list_test.sh b/gold/testsuite/gc_dynamic_list_test.sh new file mode 100755 index 0000000..b1723dd --- /dev/null +++ b/gold/testsuite/gc_dynamic_list_test.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# gc_comdat_test.sh -- test --gc-sections + +# Copyright 2014 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. + +# The goal of this program is to verify if comdat's and garbage +# collection work together. Files gc_comdat_test_1.cc and +# gc_comdat_test_2.cc are used in this test. This program checks +# if the kept comdat section is garbage collected. + +check() +{ + if ! grep -q "$2" "$1" + then + echo "Garbage collection should not have collected '$2'" + exit 1 + fi +} + +check gc_dynamic_list_test.stdout "keep" diff --git a/gold/testsuite/gc_dynamic_list_test.t b/gold/testsuite/gc_dynamic_list_test.t new file mode 100644 index 0000000..8905541 --- /dev/null +++ b/gold/testsuite/gc_dynamic_list_test.t @@ -0,0 +1,25 @@ +/* gc_dynamic_list_test.t -- script file for gc_dynamic_list_test.cc + + Copyright 2014 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. */ + +{ + keep; +}; |