[ELF] Default to --no-allow-shlib-undefined for executables
authorFangrui Song <maskray@google.com>
Sat, 2 Feb 2019 00:34:28 +0000 (00:34 +0000)
committerFangrui Song <maskray@google.com>
Sat, 2 Feb 2019 00:34:28 +0000 (00:34 +0000)
commitae0294375f3c405aab99f7c75acb0001ecfb2297
treec4a3bf1284654fe66bbdc10a52222a61c29cb418
parent1bccafe4f6f2b8e6496641e55cccb2dab2da58e2
[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

llvm-svn: 352943
lld/ELF/Driver.cpp
lld/ELF/Options.td
lld/docs/ld.lld.1
lld/test/ELF/allow-shlib-undefined.s
lld/test/ELF/pr34872.s
lld/test/ELF/unresolved-symbols.s