From ee6a352a8ddfd3bf7b7dea95bc2d7d7df0b9aa5f Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 8 Sep 2017 18:41:49 +0000 Subject: [PATCH] Handle lazy symbols is computeIsPreemptible. llvm-svn: 312812 --- lld/ELF/Writer.cpp | 2 +- .../ELF/Inputs/dynamic-list-weak-archive.s | 2 ++ lld/test/ELF/dynamic-list-weak-archive.s | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 lld/test/ELF/Inputs/dynamic-list-weak-archive.s create mode 100644 lld/test/ELF/dynamic-list-weak-archive.s diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index e12b675f3828..0e2504ee9896 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1240,7 +1240,7 @@ static bool computeIsPreemptible(const SymbolBody &B) { // executables are automatically exported so that the runtime linker // can try to resolve them. In that case, they are preemptible. So, we // return true for an undefined symbols in all cases. - if (B.isUndefined() || B.isShared()) + if (!B.isInCurrentDSO()) return true; // If we have a dynamic list it specifies which local symbols are preemptible. diff --git a/lld/test/ELF/Inputs/dynamic-list-weak-archive.s b/lld/test/ELF/Inputs/dynamic-list-weak-archive.s new file mode 100644 index 000000000000..dd28fcbd5255 --- /dev/null +++ b/lld/test/ELF/Inputs/dynamic-list-weak-archive.s @@ -0,0 +1,2 @@ +.globl foo +foo: diff --git a/lld/test/ELF/dynamic-list-weak-archive.s b/lld/test/ELF/dynamic-list-weak-archive.s new file mode 100644 index 000000000000..f7f72afd0c3b --- /dev/null +++ b/lld/test/ELF/dynamic-list-weak-archive.s @@ -0,0 +1,18 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/dynamic-list-weak-archive.s -o %t2.o +# RUN: rm -f %t.a +# RUN: llvm-ar rcs %t.a %t2.o +# RUN: echo "{ zed; };" > %t.list +# RUN: ld.lld -shared --dynamic-list %t.list %t1.o %t.a -o %t.so +# RUN: llvm-readobj -r %t.so | FileCheck %s + +# CHECK: Relocations [ +# CHECK-NEXT: Section ({{.*}}) .rela.plt { +# CHECK-NEXT: 0x2018 R_X86_64_JUMP_SLOT foo +# CHECK-NEXT: } +# CHECK-NEXT: ] + +callq foo@PLT +.weak foo