[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-04 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

Alan Modra  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #20 from Alan Modra  ---
.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-04 Thread mliska at suse dot cz
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #19 from Martin Liska  ---
(In reply to Alan Modra from comment #16)
> Huh, this time it's the scan over dependent libraries after LTO
> recompilation.

Thank you for the quick fix. The package rtkit builds fine now.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-04 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #18 from cvs-commit at gcc dot gnu.org  ---
The binutils-2_36-branch branch has been updated by Alan Modra
:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b71c7a5814298708d9574c9e0a56455f3a860e14

commit b71c7a5814298708d9574c9e0a56455f3a860e14
Author: Alan Modra 
Date:   Thu Feb 4 13:56:34 2021 +1030

PR27311, (symbol from plugin): undefined reference, hidden sym

bfd/
PR 27311
* elflink.c (elf_link_add_object_symbols): Don't pull in as-needed
libraries for IR references on pass over libraries after LTO
recompilation.
ld/
* testsuite/ld-plugin/pr27311d.c: New test.
* testsuite/ld-plugin/lto.exp: Rename pr27311 to pr27311-1, compile
and link new test as pr27311-2.

(cherry picked from commit 7d409ac001cce916661d345bff01ed589991e762)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-03 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #17 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Alan Modra :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7d409ac001cce916661d345bff01ed589991e762

commit 7d409ac001cce916661d345bff01ed589991e762
Author: Alan Modra 
Date:   Thu Feb 4 13:56:34 2021 +1030

PR27311, (symbol from plugin): undefined reference, hidden sym

bfd/
PR 27311
* elflink.c (elf_link_add_object_symbols): Don't pull in as-needed
libraries for IR references on pass over libraries after LTO
recompilation.
ld/
* testsuite/ld-plugin/pr27311d.c: New test.
* testsuite/ld-plugin/lto.exp: Rename pr27311 to pr27311-1, compile
and link new test as pr27311-2.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-03 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #16 from Alan Modra  ---
Huh, this time it's the scan over dependent libraries after LTO recompilation.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-03 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

Alan Modra  changed:

   What|Removed |Added

 Status|REOPENED|ASSIGNED

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-03 Thread mliska at suse dot cz
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

Martin Liska  changed:

   What|Removed |Added

 Resolution|FIXED   |---
 Status|RESOLVED|REOPENED

--- Comment #15 from Martin Liska  ---
I'm sorry, but the problem is still present. I reduced that from rtkit package.
Please use the very same example as mentioned in Comment 3, but use app.c:

$ cat app.c
__attribute__((visibility("hidden"))) void inlib1(void) {}
int main()
{
  return 0;
}

$ gcc app.o -L. -Wl,-rpath-link,. -l2 
/usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: app.o
(symbol from plugin): undefined reference to symbol 'inlib1@@LIBFOO'
/usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld:
./lib1.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-03 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

Alan Modra  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #14 from Alan Modra  ---
Fixed

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-03 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #13 from cvs-commit at gcc dot gnu.org  ---
The binutils-2_36-branch branch has been updated by Alan Modra
:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d2ea9f3a70a2d44cae20ab43609a71f1e616b43a

commit d2ea9f3a70a2d44cae20ab43609a71f1e616b43a
Author: Alan Modra 
Date:   Tue Feb 2 15:05:14 2021 +1030

PR27311, ld.bfd (symbol from plugin): undefined reference

A default versioned symbol definition in a shared library is
overridden by an unversioned definition in a regular object file, and
thus should not be reason to make an as-needed library needed.

bfd/
PR 27311
* elflink.c (elf_link_add_object_symbols): Don't pull in as-needed
libraries when H is an indirect symbol after calling
_bfd_elf_add_default_symbol.
ld/
* testsuite/ld-ifunc/ifunc.exp (libpr16467b.so, libpr16467bn.so):
Link with --as-needed.

* testsuite/ld-plugin/pr27311.d,
* testsuite/ld-plugin/pr27311.ver,
* testsuite/ld-plugin/pr27311a.c,
* testsuite/ld-plugin/pr27311b.c,
* testsuite/ld-plugin/pr27311c.c: New testcase.
* testsuite/ld-plugin/lto.exp: Run it.  Correct PR14918 and
PR12982 entries.

(cherry picked from commit 9918bff7cf2a566aaa2036d2242a61c140652dc7)
(cherry picked from commit 6955136728a68365bbb5e6e1327dff1654b2a0ca)
(cherry picked from commit f01fb44c0621b064996493bb5acd5077646ea84e)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-03 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #12 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Alan Modra :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f01fb44c0621b064996493bb5acd5077646ea84e

commit f01fb44c0621b064996493bb5acd5077646ea84e
Author: Alan Modra 
Date:   Wed Feb 3 15:57:35 2021 +1030

Re: PR27311, ld.bfd (symbol from plugin): undefined reference

This does exactly the same as making decisions based on an override
in _bfd_elf_add_default_symbol, and is simpler.

PR 27311
* elflink.c (_bfd_elf_add_default_symbol): Revert last two changes.
(elf_link_add_object_symbols): Here too.  Don't pull in as-needed
libraries when H is an indirect symbol after calling
_bfd_elf_add_default_symbol.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-02 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #11 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Alan Modra :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6955136728a68365bbb5e6e1327dff1654b2a0ca

commit 6955136728a68365bbb5e6e1327dff1654b2a0ca
Author: Alan Modra 
Date:   Wed Feb 3 10:57:12 2021 +1030

PR27311 again, ld.bfd (symbol from plugin): undefined reference

bfd/
PR 27311
* elflink.c (_bfd_elf_add_default_symbol): Clear override when
undecorated symbol will have a different version.
ld/
* testsuite/ld-ifunc/ifunc.exp (libpr16467b.so, libpr16467bn.so):
Link with --as-needed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-02 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #10 from Alan Modra  ---
Further testing found a regression of the pr16467 testcase when using a
compiler defaulting to --as-needed.  The patch needs more work.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-02 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #9 from Alan Modra  ---
Ignore the gcc-7 and gcc-8 comment.  I wasn't picking up the ld I thought I
was.  I'll apply the patch to the 2.36 branch too after some more testing.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-02 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #8 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Alan Modra :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9918bff7cf2a566aaa2036d2242a61c140652dc7

commit 9918bff7cf2a566aaa2036d2242a61c140652dc7
Author: Alan Modra 
Date:   Tue Feb 2 15:05:14 2021 +1030

PR27311, ld.bfd (symbol from plugin): undefined reference

A default versioned symbol definition in a shared library is
overridden by an unversioned definition in a regular object file, and
thus should not be reason to make an as-needed library needed.

bfd/
PR 27311
* elflink.c (_bfd_elf_add_default_symbol): Add override parameter.
Use when handling default versioned symbol.  Rename existing
override variable to nondef_override and use for non-default
versioned symbol.
(elf_link_add_object_symbols): Adjust call to suit.  Don't
pull in as-needed libraries when override is set.
ld/
* testsuite/ld-plugin/pr27311.d,
* testsuite/ld-plugin/pr27311.ver,
* testsuite/ld-plugin/pr27311a.c,
* testsuite/ld-plugin/pr27311b.c,
* testsuite/ld-plugin/pr27311c.c: New testcase.
* testsuite/ld-plugin/lto.exp: Run it.  Correct PR14918 and
PR12982 entries.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-01 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #7 from Alan Modra  ---
Created attachment 13192
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13192=edit
fix

This passes a sniff-test and cures both testcases.  I'll do a little more
testing before committing along with Michael's testcase.  Interestingly, gcc-8
and gcc-7 don't trigger this problem.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-01 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

Alan Modra  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at sourceware dot org   |amodra at gmail dot com

--- Comment #6 from Alan Modra  ---
What's happening here (using Michael's testcase, thanks!) is that
inlib1@@LIBFOO is seen as being a definition, triggering

  if (!add_needed
  && matched
  && definition
  && ((dynsym
   && h->ref_regular_nonweak)
  || (old_bfd != NULL
  && (old_bfd->flags & BFD_PLUGIN) != 0
  && bind != STB_WEAK)
  || (h->ref_dynamic_nonweak
  && (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0
  && !on_needed_list (elf_dt_name (abfd),
  htab->needed, NULL

to pull in lib1.so.  However, inlib1@@LIBFOO is actually overridden by inlib1
from the object file.  Without symbol versioning we see inlib1 from lib1.so
setting override during the first _bfd_elf_merge_symbol call in
add_object_symbols and then this
  if (override && matched)
definition = FALSE;
stops the non-versioned inlib1 from being considered a reason to pull in
lib1.so.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-01 Thread matz at suse dot de
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #5 from Michael Matz  ---
(In reply to Michael Matz from comment #4)
> (In reply to H.J. Lu from comment #2)
> > Please try users/hjl/pr26530/master branch:
> > 
> > https://gitlab.com/x86-binutils/binutils-gdb/-/commits/users/hjl/pr26530/
> > master
> 
> Yes, that patch series works, but I think we don't want to revert Alans
> patch but
> rather fix it :)

In particular, because it's crucial that the shared-lib symbol has a version
(with unversioned it links fine) I would expect the fix to be somehow involving
removing a difference between versioned and unversion symbols, not 
dealing with the as-needed behaviour of pulling or not pulling in members of
static archives.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-01 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

H.J. Lu  changed:

   What|Removed |Added

 Status|WAITING |NEW

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-01 Thread matz at suse dot de
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #4 from Michael Matz  ---
(In reply to H.J. Lu from comment #2)
> Please try users/hjl/pr26530/master branch:
> 
> https://gitlab.com/x86-binutils/binutils-gdb/-/commits/users/hjl/pr26530/
> master

Yes, that patch series works, but I think we don't want to revert Alans patch
but
rather fix it :)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-01 Thread matz at suse dot de
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #3 from Michael Matz  ---
FWIW, it's important that the symbol in question is defined in an indirect
shared lib with a symversion, and defined in an input object file itself.  I.e.
this is more self-contained:

% cat lib1.c
void inlib1(void) {}
% cat lib2.c
void inlib2(void) {}
% cat app.c
void inlib1(void) {}
int main()
{
  return 0;
}
% cat version.txt
LIBFOO {
  *;
};

% gcc -shared -fPIC -o lib1.so lib1.c -Wl,-version-script,version.txt
% gcc -shared -fPIC -o lib2.so lib2.c -Wl,--no-as-needed lib1.so
% gcc -c -flto app.c
% gcc app.o -L. -Wl,-rpath-link,. -l2
/usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: app.o
(symbol from plugin): undefined reference to symbol 'inlib1@@LIBFOO'
/usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld:
./lib1.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-01 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

H.J. Lu  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Last reconfirmed||2021-02-01
 CC||hjl.tools at gmail dot com
 Status|UNCONFIRMED |WAITING

--- Comment #2 from H.J. Lu  ---
Please try users/hjl/pr26530/master branch:

https://gitlab.com/x86-binutils/binutils-gdb/-/commits/users/hjl/pr26530/master

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-01 Thread mliska at suse dot cz
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

Martin Liska  changed:

   What|Removed |Added

 CC||amodra at gmail dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/27311] ld.bfd (symbol from plugin): undefined reference to symbol since b1a92c635c1ec10fd703302ce1fc4ab3a8515a04

2021-02-01 Thread mliska at suse dot cz
https://sourceware.org/bugzilla/show_bug.cgi?id=27311

--- Comment #1 from Martin Liska  ---
Important to notice, the symbol /usr/lib64/libsystemd.so.0 defines:

readelf -sW /usr/lib64/libsystemd.so.0 | grep sd_booted
   296: 00059c8068 FUNCGLOBAL DEFAULT   14
sd_booted@@LIBSYSTEMD_209

-- 
You are receiving this mail because:
You are on the CC list for the bug.