diff options
author | Reid Kleckner <rnk@google.com> | 2018-04-16 22:45:23 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2018-04-16 22:45:23 +0000 |
commit | 9c86a313076351134cd1e4f2a604466d7c0974b4 (patch) | |
tree | 00069135e40104c016b1e674ce8ef58d2e122727 | |
parent | 9b294d1e905ab49c941333c81840afac9f6fe238 (diff) | |
download | bcm5719-llvm-9c86a313076351134cd1e4f2a604466d7c0974b4.tar.gz bcm5719-llvm-9c86a313076351134cd1e4f2a604466d7c0974b4.zip |
Revert r329960 "Do not keep shared symbols created from garbage-collected eliminated DSOs."
This is causing large numbers of Chromium test executables to crash on
shutdown. The relevant symbol seems to be __cxa_finalize, which gets
removed from the dynamic symbol table for some of the support libraries.
llvm-svn: 330164
-rw-r--r-- | lld/ELF/Driver.cpp | 13 | ||||
-rw-r--r-- | lld/test/ELF/as-needed-weak.s | 22 | ||||
-rw-r--r-- | lld/test/ELF/gc-sections-shared.s | 23 |
3 files changed, 23 insertions, 35 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index c380ee56b23..539ef97a739 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -1059,18 +1059,6 @@ template <class ELFT> static void handleUndefined(StringRef Name) { Symtab->fetchLazy<ELFT>(Sym); } -// If all references to a DSO happen to be weak, the DSO is not added -// to DT_NEEDED. If that happens, we need to eliminate shared symbols -// created from the DSO. Otherwise, they become dangling references -// that point to a non-existent DSO. -template <class ELFT> static void demoteSharedSymbols() { - for (Symbol *Sym : Symtab->getSymbols()) - if (auto *S = dyn_cast<SharedSymbol>(Sym)) - if (!S->getFile<ELFT>().IsNeeded) - replaceSymbol<Undefined>(S, nullptr, S->getName(), STB_WEAK, S->StOther, - S->Type); -} - // Do actual linking. Note that when this function is called, // all linker scripts have already been parsed. template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) { @@ -1231,7 +1219,6 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) { // Do size optimizations: garbage collection, merging of SHF_MERGE sections // and identical code folding. markLive<ELFT>(); - demoteSharedSymbols<ELFT>(); decompressSections(); mergeSections(); if (Config->ICF) diff --git a/lld/test/ELF/as-needed-weak.s b/lld/test/ELF/as-needed-weak.s deleted file mode 100644 index f009c72d6f4..00000000000 --- a/lld/test/ELF/as-needed-weak.s +++ /dev/null @@ -1,22 +0,0 @@ -# REQUIRES: x86 - -# RUN: echo '.globl foo; .type foo, @function; foo:' | \ -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t1.o -# RUN: ld.lld -shared -o %t1.so -soname libfoo %t1.o - -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t2.o -# RUN: ld.lld -o %t.exe %t2.o --as-needed %t1.so -# RUN: llvm-readelf -dynamic-table -dyn-symbols %t.exe | FileCheck %s - -# CHECK-NOT: libfoo - -# CHECK: Symbol table of .hash for image: -# CHECK-NEXT: Num Buc: Value Size Type Bind Vis Ndx Name -# CHECK-NEXT: 1 1: 0000000000000000 0 FUNC WEAK DEFAULT UND foo@ - -.globl _start -.weak foo - -_start: - mov $foo, %eax - callq foo diff --git a/lld/test/ELF/gc-sections-shared.s b/lld/test/ELF/gc-sections-shared.s index 408f5141bf2..55b3ef556ce 100644 --- a/lld/test/ELF/gc-sections-shared.s +++ b/lld/test/ELF/gc-sections-shared.s @@ -9,6 +9,11 @@ # RUN: ld.lld --gc-sections --export-dynamic-symbol foo -o %t %t.o --as-needed %t2.so %t3.so %t4.so # RUN: llvm-readobj --dynamic-table --dyn-symbols %t | FileCheck %s +# This test the property that we have a needed line for every undefined. +# It would also be OK to keep bar2 and the need for %t2.so +# At the same time, weak symbols should not cause adding DT_NEEDED; +# this case is checked with symbol qux and %t4.so. + # CHECK: DynamicSymbols [ # CHECK-NEXT: Symbol { # CHECK-NEXT: Name: @@ -46,6 +51,15 @@ # CHECK-NEXT: Other: # CHECK-NEXT: Section: .text # CHECK-NEXT: } +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: qux +# CHECK-NEXT: Value: +# CHECK-NEXT: Size: +# CHECK-NEXT: Binding: Weak +# CHECK-NEXT: Type: +# CHECK-NEXT: Other: +# CHECK-NEXT: Section: Undefined +# CHECK-NEXT: } # CHECK-NEXT: ] # CHECK-NOT: NEEDED @@ -85,6 +99,15 @@ # CHECK2-NEXT: Section: Undefined # CHECK2-NEXT: } # CHECK2-NEXT: Symbol { +# CHECK2-NEXT: Name: qux +# CHECK2-NEXT: Value: +# CHECK2-NEXT: Size: +# CHECK2-NEXT: Binding: Weak +# CHECK2-NEXT: Type: +# CHECK2-NEXT: Other: +# CHECK2-NEXT: Section: Undefined +# CHECK2-NEXT: } +# CHECK2-NEXT: Symbol { # CHECK2-NEXT: Name: foo # CHECK2-NEXT: Value: # CHECK2-NEXT: Size: |