linker plugin api limitation

Rafael Espíndola rafael.espindola@gmail.com
Wed Mar 2 19:23:00 GMT 2016


On 1 March 2016 at 21:27, Evgenii Stepanov <eugeni.stepanov@gmail.com> wrote:
> I've sent the fix (get_symbols() returning LDPS_NO_SYMS) to the ML
> recently, but it looks like this is only part of the problem.
>
> I've filed https://llvm.org/bugs/show_bug.cgi?id=26807 with a test
> case for a similar problem where gold incorrectly decides to include
> an input file in the link (and fails even before the first
> get_symbols() call). I'm not sure what's going on at this point.
>

The bug is in gold. It is handling every symbol provided by the plugin
as defined when handling --start-lib/--end-lib members.

Something like the attached patch should fix it.

Cheers,
Rafael
-------------- next part --------------
diff --git a/gold/plugin.cc b/gold/plugin.cc
index c01e4cd..8831cb0e 100644
--- a/gold/plugin.cc
+++ b/gold/plugin.cc
@@ -1155,6 +1155,9 @@ Sized_pluginobj<size, big_endian>::do_should_include_member(
   for (int i = 0; i < this->nsyms_; ++i)
     {
       const struct ld_plugin_symbol& sym = this->syms_[i];
+      if (sym.def != LDPK_DEF && sym.def != LDPK_WEAKDEF &&
+          sym.def != LDPK_COMMON)
+        continue;
       const char* name = sym.name;
       Symbol* symbol;
       Archive::Should_include t = Archive::should_include_member(symtab,


More information about the Binutils mailing list