Fix --dynamic-list so that symbols not in the list are still exported.
authorCary Coutant <ccoutant@google.com>
Tue, 17 Feb 2015 06:15:12 +0000 (22:15 -0800)
committerCary Coutant <ccoutant@google.com>
Tue, 17 Feb 2015 06:15:12 +0000 (22:15 -0800)
In PR 13577, the complaint was that -Bsymbolic was overriding the binding
behavior for symbols listed in the --dynamic-list by setting the DT_SYMBOLIC
tag in the dynamic table. In reading the Gnu ld manual, I decided that
--dynamic-list should be mutually exclusive of -Bsymbolic, and modified
gold so that --dynamic-list would treat symbols listed as preemptible,
and all other symbols as internally bound. I was wrong.

PR 16992 shows that with --dynamic-list (and not -Bsymbolic), a symbol
not listed in the dynamic list is being internally bound within the
shared library, but because it's still in the dynamic symbol table, we
expose it to a COPY relocation, and things go really bad from there.

(I can reproduce the same failure, simply by turning on -Bsymbolic-functions
with the Gnu linker. Even though the symbol is bound internally, it's
still exported to the dynamic symbol table, and is exposed to a COPY
relocation.)

I've backed out part of the fix for PR 13577, and -Bsymbolic (or
-Bsymbolic-functions) can now be used with --dynamic-list, but if the
two are used together, we do not set DT_SYMBOLIC or DF_SYMBOLIC
(this matches Gnu ld behavior). We now treat symbols listed in the
dynamic list as premptible, but we do not automatically treat symbols
not listed there as non-premptible.

gold/
PR gold/13577
PR gold/16992
* layout.cc (Layout::finish_dynamic_section): Don't set DT_SYMBOLIC or
DF_SYMBOLIC if --dynamic-list option is used.
* options.cc (General_options::finalize): --dynamic-list is not
mutually exclusive with -Bsymbolic.
* symtab.h (Symbol::is_preemptible): Don't exclude dynamic symbols not
listed in --dynamic-list.
* testsuite/Makefile.am (dynamic_list_lib2.so): Add
-Bsymbolic-functions.
* testsuite/Makefile.in: Regenerate.

gold/ChangeLog
gold/layout.cc
gold/options.cc
gold/symtab.h
gold/testsuite/Makefile.am
gold/testsuite/Makefile.in

index 3c431e9b224e8fababff7a1b5ce4e22978f6fdfa..3eed17a176153676b6ed4a36b8b9873b439d5a1c 100644 (file)
@@ -1,3 +1,17 @@
+2015-02-16  Cary Coutant  <ccoutant@google.com>
+
+       PR gold/13577
+       PR gold/16992
+       * layout.cc (Layout::finish_dynamic_section): Don't set DT_SYMBOLIC or
+       DF_SYMBOLIC if --dynamic-list option is used.
+       * options.cc (General_options::finalize): --dynamic-list is not
+       mutually exclusive with -Bsymbolic.
+       * symtab.h (Symbol::is_preemptible): Don't exclude dynamic symbols not
+       listed in --dynamic-list.
+       * testsuite/Makefile.am (dynamic_list_lib2.so): Add
+       -Bsymbolic-functions.
+       * testsuite/Makefile.in: Regenerate.
+
 2015-02-16  Cary Coutant  <ccoutant@google.com>
 
        PR gold/17971
index bcdaac825dbc83c7c2526f439f7e0a6bcd270adb..7836640a57767f8ce4c67f5d3dee21e712ba2576 100644 (file)
@@ -4873,7 +4873,8 @@ Layout::finish_dynamic_section(const Input_objects* input_objects,
     flags |= elfcpp::DF_STATIC_TLS;
   if (parameters->options().origin())
     flags |= elfcpp::DF_ORIGIN;
-  if (parameters->options().Bsymbolic())
+  if (parameters->options().Bsymbolic()
+      && !parameters->options().have_dynamic_list())
     {
       flags |= elfcpp::DF_SYMBOLIC;
       // Add DT_SYMBOLIC for compatibility with older loaders.
index 7eb8f2771088fb21e875fe62c1e85f502ed9b5e1..7f1f69e0cecd43a93f53c9a6dd9a4ad142bf551a 100644 (file)
@@ -1200,13 +1200,6 @@ 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"));
index aa0cb68c1deb3c3e68699551a68e8fd043bf244d..9413360fc234a55049d57a898080454c2f4d6bb1 100644 (file)
@@ -604,10 +604,8 @@ class Symbol
     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())
+    // If the user used -Bsymbolic, then nothing (else) is preemptible.
+    if (parameters->options().Bsymbolic())
       return false;
 
     // If the user used -Bsymbolic-functions, then functions are not
index f767c21f3935fb5ee497e98c6c842eb398b59150..7b73f9d174acc09d615b89778b681cee48809a14 100644 (file)
@@ -1518,7 +1518,7 @@ 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
+       $(CXXLINK) -Bgcctestdir/ -shared -Wl,-Bsymbolic-functions -Wl,--dynamic-list,$(srcdir)/dynamic_list_2.t dynamic_list_lib2.o
 dynamic_list_lib2.o: dynamic_list_lib2.cc
        $(CXXCOMPILE) -c -fpic -o $@ $<
 
index 217e472db063ca7a95d8a24ea2e536fe8f286b47..b4ae3fdc74f4045f815419539ec1688742f70ae6 100644 (file)
@@ -5319,7 +5319,7 @@ uninstall-am:
 @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@ $(CXXLINK) -Bgcctestdir/ -shared -Wl,-Bsymbolic-functions -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 $@ $<
 
This page took 0.059655 seconds and 4 git commands to generate.