[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

classic Classic list List threaded Threaded
33 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

            Bug ID: 236141
           Summary: LLD (unlike BFD) ignores unresolved references in
                    libraries for indirect linking
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: [hidden email]
          Reporter: [hidden email]

ports/ assume if build succeeded then binaries usually work, sans crashes. Only
shared libraries with no immediate consumers need -z defs. Turns out this is no
longer true after bug 214864 e.g., ports r494319.

$ cat a.c
void foo(void);
void bar() { foo(); }

$ cat b.c
int main() {}

$ cc -fPIC -shared a.c -o a.so
$ cc b.c a.so
$ cc -fuse-ld=bfd b.c a.so
/usr/local/bin/ld.bfd: a.so: undefined reference to `foo'
cc: error: linker command failed with exit code 1 (use -v to see invocation)

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #1 from Jan Beich <[hidden email]> ---
Oops, I forgot to insert a unresolved reference into the binary. Notice LLD
accepts what rtld won't.

$ cat b.c
void bar();
int main() { bar();}

$ cc b.c a.so
$ LD_LIBRARY_PATH=. ./a.out
ld-elf.so.1: ./a.so: Undefined symbol "foo"

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

Alex Richardson <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[hidden email]

--- Comment #2 from Alex Richardson <[hidden email]> ---
Support for this recently landed in upstream LLD:
https://github.com/llvm/llvm-project/commit/b4744d306c0a21933d4339fa4fb497866a36ee49#diff-050be97050a41e1b5f83c19795b5e33d
(and is on by default since
https://github.com/llvm/llvm-project/commit/ae0294375f3c405aab99f7c75acb0001ecfb2297#diff-050be97050a41e1b5f83c19795b5e33d).

This should be part of ld.lld 9.0 (but it might be possible to backport those
patches).

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #3 from [hidden email] ---
A commit references this bug:

Author: dim
Date: Wed Mar 20 20:57:13 UTC 2019
New revision: 345349
URL: https://svnweb.freebsd.org/changeset/base/345349

Log:
  Pull in r352826 from upstream lld trunk (by Fangrui Song):

    [ELF] Support --{,no-}allow-shlib-undefined

    Summary:
    In ld.bfd/gold, --no-allow-shlib-undefined is the default when
    linking an executable. This patch implements a check to error on
    undefined symbols in a shared object, if all of its DT_NEEDED entries
    are seen.

    Our approach resembles the one used in gold, achieves a good balance
    to be useful but not too smart (ld.bfd traces all DSOs and emulates
    the behavior of a dynamic linker to catch more cases).

    The error is issued based on the symbol table, different from
    undefined reference errors issued for relocations. It is most
    effective when there are DSOs that were not linked with -z defs (e.g.
    when static sanitizers runtime is used).

    gold has a comment that some system libraries on GNU/Linux may have
    spurious undefined references and thus system libraries should be
    excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
    story may have changed now but we make --allow-shlib-undefined the
    default for now. Its interaction with -shared can be discussed in the
    future.

    Reviewers: ruiu, grimar, pcc, espindola

    Reviewed By: ruiu

    Subscribers: joerg, emaste, arichardson, llvm-commits

    Differential Revision: https://reviews.llvm.org/D57385

  Pull in r352943 from upstream lld trunk (by Fangrui Song):

    [ELF] Default to --no-allow-shlib-undefined for executables

    Summary:
    This follows the ld.bfd/gold behavior.

    The error check is useful as it captures a common type of ld.so
    undefined symbol errors as link-time errors:

        // a.cc => a.so (not linked with -z defs)
        void f(); // f is undefined
        void g() { f(); }

        // b.cc => executable with a DT_NEEDED entry on a.so
        void g();
        int main() { g(); }

        // ld.so errors when g() is executed (lazy binding) or when the program
is started (-z now)
        // symbol lookup error: ... undefined symbol: f

    Reviewers: ruiu, grimar, pcc, espindola

    Reviewed By: ruiu

    Subscribers: llvm-commits, emaste, arichardson

    Tags: #llvm

    Differential Revision: https://reviews.llvm.org/D57569

  Together, these add support for --no-allow-shlib-undefined, and make it
  the default for executables, so they will fail to link if any symbols
  from needed shared libraries are undefined.

  Reported by:  jbeich
  PR:           236062, 236141
  MFC after:    1 month
  X-MFC-With:   r344779

Changes:
  head/contrib/llvm/tools/lld/ELF/Config.h
  head/contrib/llvm/tools/lld/ELF/Driver.cpp
  head/contrib/llvm/tools/lld/ELF/InputFiles.cpp
  head/contrib/llvm/tools/lld/ELF/InputFiles.h
  head/contrib/llvm/tools/lld/ELF/Options.td
  head/contrib/llvm/tools/lld/ELF/SymbolTable.cpp
  head/contrib/llvm/tools/lld/ELF/SymbolTable.h
  head/contrib/llvm/tools/lld/ELF/Writer.cpp
  head/contrib/llvm/tools/lld/docs/ld.lld.1
  head/lib/clang/include/lld/Common/Version.inc

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

Dimitry Andric <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |236062


Referenced Bugs:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236062
[Bug 236062] [exp-run] Against projects/clang800-import branch
--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #4 from Dimitry Andric <[hidden email]> ---
So unfortunately this causes a bunch of gnome ports (and maybe more) to fail to
link, due to undefined symbols: see bug 236062 comment 30.

Obviously the new default of --no-allow-shlib-undefined seems to work, in the
sense that it does find a bunch of undefined symbols, but now the question is
if it is too trigger-happy, or if the ports in question are having
under-specified link libraries...

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #5 from Jan Beich <[hidden email]> ---
Both. --no-allow-shlib-undefined in BFD is more lenient and linking in the wild
is too sloppy. Unfortunately, it's hard to measure the impact due to many ports
skipped.

As Gold also defaults to --no-allow-shlib-undefined DPorts may have fixes e.g.,
https://github.com/DragonFlyBSD/DeltaPorts/blob/dd4e3973258f/ports/devel/libglade2/Makefile.DragonFly

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #6 from Antoine Brodin <[hidden email]> ---
Can the default be flipped until issues in ports are resolved?

I will post here the list of new failures when the build is finished.

There are patches floating around,  like:

https://github.com/libharu/libharu/pull/109/commits/5cc80928121bea38a16794e2cc24191d86e900cd
https://patchwork.openembedded.org/patch/158994/
https://sources.debian.org/src/libpuzzle/0.11-3/debian/patches/02_link_against_libm_jump_regress_1_test/

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #7 from Jan Beich <[hidden email]> ---
I agree with antoine@. As long as /stable/11 is supported only aarch64, armv7
and ports limited to FreeBSD 12+ may accidentally underlink libraries. Bustage
from --no-allow-shlib-undefined default currently interferes with Clang 8 and
LLVM openmp dogfooding which is supposed to facilitate MFC to /stable/11 before
11.3 freeze.

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #8 from [hidden email] ---
A commit references this bug:

Author: antoine
Date: Fri Mar 22 16:19:42 UTC 2019
New revision: 496577
URL: https://svnweb.freebsd.org/changeset/ports/496577

Log:
  Fix build after base r345349

  PR:           236141

Changes:
  head/www/faup/Makefile
  head/www/faup/files/
  head/www/faup/files/patch-CMakeLists.txt

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #9 from [hidden email] ---
A commit references this bug:

Author: kwm
Date: Fri Mar 22 23:57:12 UTC 2019
New revision: 496605
URL: https://svnweb.freebsd.org/changeset/ports/496605

Log:
  Fix build after base r345349

  While do some cleanup of the port.

  PR:           236141

Changes:
  head/devel/libglade2/Makefile
  head/devel/libglade2/pkg-plist

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #10 from [hidden email] ---
A commit references this bug:

Author: kwm
Date: Sat Mar 23 00:01:05 UTC 2019
New revision: 496606
URL: https://svnweb.freebsd.org/changeset/ports/496606

Log:
  Update gtk30 to 3.24.7.

  This release contains a fix for the build failure after base r345349.

  PR:           236141
  Obtained from:  gnome devel repo

Changes:
  head/x11-toolkits/gtk30/Makefile
  head/x11-toolkits/gtk30/distinfo

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

Jan Beich <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |236719


Referenced Bugs:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236719
[Bug 236719] x11-toolkits/plib: consumers fail --no-allow-shlib-undefined with
Gold or LLD 9 (or on 13-CURRENT)
--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141
Bug 236141 depends on bug 236719, which changed state.

Bug 236719 Summary: [PATCH] games/torcs: add libusbhid link to try fix in 13-CURRENT
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236719

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|New                         |Closed
         Resolution|---                         |FIXED

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #11 from Antoine Brodin <[hidden email]> ---
On i386,  graphics/cairo no longer builds,  more than 5000 ports skipped

http://beefy11.nyi.freebsd.org/data/head-i386-default/p496612_s345426/logs/errors/cairo-1.15.12,2.log

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #12 from Jan Beich <[hidden email]> ---
antoine@, are you sure it's not one of elftoolchain affecting string(1)?
ax_cv_c_float_words_bigendian check in cairo doesn't use shared libraries.

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #13 from Antoine Brodin <[hidden email]> ---
(In reply to Jan Beich from comment #12)
it's possible..

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #14 from Antoine Brodin <[hidden email]> ---
(In reply to Jan Beich from comment #12)
right it was fixed by base r345431

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #15 from [hidden email] ---
A commit references this bug:

Author: kwm
Date: Sat Mar 23 10:58:50 UTC 2019
New revision: 496635
URL: https://svnweb.freebsd.org/changeset/ports/496635

Log:
  Fix build after base r345349

  While here, do some cleanup of the port.
  Release maintainer

  PR:           236141

Changes:
  head/x11-toolkits/gtkglarea2/Makefile
  head/x11-toolkits/gtkglarea2/files/
  head/x11-toolkits/gtkglarea2/files/patch-Makefile.in

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 236141] LLD (unlike BFD) ignores unresolved references in libraries for indirect linking

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236141

--- Comment #16 from [hidden email] ---
A commit references this bug:

Author: kwm
Date: Sat Mar 23 11:02:35 UTC 2019
New revision: 496636
URL: https://svnweb.freebsd.org/changeset/ports/496636

Log:
  Fix build after base r345349

  PR:           236141

Changes:
  head/x11-toolkits/gtkimageview/Makefile

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
To unsubscribe, send any mail to "[hidden email]"
12