summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2017-07-27 09:25:16 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2017-07-27 09:25:16 +0000
commit13f7dcdbc30dfb34fc5592609cb44ccc879c992c (patch)
treee792c43daedfad15f9653c5083142eebf63a3a9a
parent8459922df7bfdf34b9b58252a6ffa0205bbe44c7 (diff)
downloadbcm5719-llvm-13f7dcdbc30dfb34fc5592609cb44ccc879c992c.tar.gz
bcm5719-llvm-13f7dcdbc30dfb34fc5592609cb44ccc879c992c.zip
Revert r309252 "[ELF] - Fix missing relocation when linking executable with --unresolved-symbols=ignore-all"
It broke bot: http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/4231 llvm-svn: 309258
-rw-r--r--lld/ELF/Symbols.cpp20
-rw-r--r--lld/test/ELF/executable-undefined-ignoreall.s13
-rw-r--r--lld/test/ELF/executable-undefined-protected-ignoreall.s8
-rw-r--r--lld/test/ELF/no-inhibit-exec.s6
4 files changed, 7 insertions, 40 deletions
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index bf1d3d7a13a..cf2d6d0d25d 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -141,6 +141,10 @@ bool SymbolBody::isPreemptible() const {
if (isShared())
return !NeedsCopy && !NeedsPltAddr;
+ // That's all that can be preempted in a non-DSO.
+ if (!Config->Shared)
+ return false;
+
// Only symbols that appear in dynsym can be preempted.
if (!symbol()->includeInDynsym())
return false;
@@ -149,15 +153,6 @@ bool SymbolBody::isPreemptible() const {
if (symbol()->Visibility != STV_DEFAULT)
return false;
- // Undefined symbols in non-DSOs are usually just an error, so it
- // doesn't matter whether we return true or false here. However, if
- // -unresolved-symbols=ignore-all is specified, undefined symbols in
- // executables are automatically exported so that the runtime linker
- // can try to resolve them. In that case, they is preemptible. So, we
- // return true for an undefined symbol in case the option is specified.
- if (!Config->Shared)
- return isUndefined();
-
// -Bsymbolic means that definitions are not preempted.
if (Config->Bsymbolic || (Config->BsymbolicFunctions && isFunc()))
return !isDefined();
@@ -362,11 +357,8 @@ uint8_t Symbol::computeBinding() const {
bool Symbol::includeInDynsym() const {
if (computeBinding() == STB_LOCAL)
return false;
- if (ExportDynamic || body()->isShared())
- return true;
- if (!body()->isUndefined())
- return false;
- return Config->Shared || !body()->symbol()->isWeak();
+ return ExportDynamic || body()->isShared() ||
+ (body()->isUndefined() && Config->Shared);
}
// Print out a log message for --trace-symbol.
diff --git a/lld/test/ELF/executable-undefined-ignoreall.s b/lld/test/ELF/executable-undefined-ignoreall.s
deleted file mode 100644
index 44f83a687ee..00000000000
--- a/lld/test/ELF/executable-undefined-ignoreall.s
+++ /dev/null
@@ -1,13 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: ld.lld %t -o %tout --unresolved-symbols=ignore-all -pie
-# RUN: llvm-readobj -r %tout | FileCheck %s
-
-# CHECK: Relocations [
-# CHECK-NEXT: Section ({{.*}}) .rela.plt {
-# CHECK-NEXT: 0x2018 R_X86_64_JUMP_SLOT foo 0x0
-# CHECK-NEXT: }
-# CHECK-NEXT: ]
-
-_start:
-callq foo@PLT
diff --git a/lld/test/ELF/executable-undefined-protected-ignoreall.s b/lld/test/ELF/executable-undefined-protected-ignoreall.s
deleted file mode 100644
index 37911791e12..00000000000
--- a/lld/test/ELF/executable-undefined-protected-ignoreall.s
+++ /dev/null
@@ -1,8 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: not ld.lld %t -o %tout --unresolved-symbols=ignore-all -pie 2>&1 | FileCheck %s
-# CHECK: error: undefined symbol: foo
-
-.protected foo
-_start:
-callq foo@PLT
diff --git a/lld/test/ELF/no-inhibit-exec.s b/lld/test/ELF/no-inhibit-exec.s
index 793d0258b7d..d0970d93f21 100644
--- a/lld/test/ELF/no-inhibit-exec.s
+++ b/lld/test/ELF/no-inhibit-exec.s
@@ -2,15 +2,11 @@
# RUN: not ld.lld %t -o %t2
# RUN: ld.lld %t --noinhibit-exec -o %t2
# RUN: llvm-objdump -d %t2 | FileCheck %s
-# RUN: llvm-readobj -r %t2 | FileCheck %s --check-prefix=RELOC
# REQUIRES: x86
# CHECK: Disassembly of section .text:
# CHECK-NEXT: _start
-# CHECK-NEXT: 201000: {{.*}} callq 0
-
-# RELOC: Relocations [
-# RELOC: ]
+# CHECK-NEXT: 201000: {{.*}} callq -2101253
# next code will not link without noinhibit-exec flag
# because of undefined symbol _bar
OpenPOWER on IntegriCloud