summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/LTO/LTO.cpp5
-rw-r--r--test/LTO/X86/symver-asm.ll2
-rw-r--r--test/ThinLTO/X86/module_asm2.ll4
-rw-r--r--tools/gold/gold-plugin.cpp10
4 files changed, 14 insertions, 7 deletions
diff --git a/lib/LTO/LTO.cpp b/lib/LTO/LTO.cpp
index 9c737795b5a..d6b50f551d9 100644
--- a/lib/LTO/LTO.cpp
+++ b/lib/LTO/LTO.cpp
@@ -416,8 +416,11 @@ void LTO::addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
auto &GlobalRes = GlobalResolutions[Sym.getName()];
GlobalRes.UnnamedAddr &= Sym.isUnnamedAddr();
- if (Res.Prevailing)
+ if (Res.Prevailing) {
+ assert((GlobalRes.IRName.empty() || !Sym.getIRName().empty()) &&
+ "Overriding existing resolution with undefined asm symbol");
GlobalRes.IRName = Sym.getIRName();
+ }
// Set the partition to external if we know it is re-defined by the linker
// with -defsym or -wrap options, used elsewhere, e.g. it is visible to a
diff --git a/test/LTO/X86/symver-asm.ll b/test/LTO/X86/symver-asm.ll
index 4841892724a..85d032ba1ab 100644
--- a/test/LTO/X86/symver-asm.ll
+++ b/test/LTO/X86/symver-asm.ll
@@ -1,7 +1,7 @@
; RUN: llvm-as < %s >%t1
; RUN: llvm-lto -exported-symbol=io_cancel_0_4 -exported-symbol=io_cancel_weak_0_4 -exported-symbol=foo -o %t2 %t1
; RUN: llvm-nm %t2 | FileCheck %s
-; RUN: llvm-lto2 run -r %t1,io_cancel_0_4,plx -r %t1,io_cancel_0_4,plx -r %t1,io_cancel_local_0_4,plx -r %t1,io_cancel_weak_0_4,plx -r %t1,io_cancel_weak_0_4,plx -r %t1,io_cancel@@LIBAIO_0.4,plx -r %t1,io_cancel_weak@@LIBAIO_0.4,plx -r %t1,io_cancel_weak@@LIBAIO_0.4.1,plx -r %t1,foo,plx -r %t1,foo,plx -r %t1,foo@@VER1,plx -o %t3 %t1 -save-temps
+; RUN: llvm-lto2 run -r %t1,io_cancel_0_4,plx -r %t1,io_cancel_0_4,lx -r %t1,io_cancel_local_0_4,plx -r %t1,io_cancel_weak_0_4,plx -r %t1,io_cancel_weak_0_4,lx -r %t1,io_cancel@@LIBAIO_0.4,plx -r %t1,io_cancel_weak@@LIBAIO_0.4,plx -r %t1,io_cancel_weak@@LIBAIO_0.4.1,plx -r %t1,foo,plx -r %t1,foo,lx -r %t1,foo@@VER1,plx -o %t3 %t1 -save-temps
; RUN: llvm-nm %t3.0 | FileCheck %s
; RUN: llvm-dis %t3.0.2.internalize.bc -o - | FileCheck %s --check-prefix=INTERN
diff --git a/test/ThinLTO/X86/module_asm2.ll b/test/ThinLTO/X86/module_asm2.ll
index b46f4019653..b79d7ad4c97 100644
--- a/test/ThinLTO/X86/module_asm2.ll
+++ b/test/ThinLTO/X86/module_asm2.ll
@@ -11,9 +11,9 @@
; RUN: llvm-lto2 run %t1.bc %t2.bc -o %t.o -save-temps \
; RUN: -r=%t1.bc,foo,plx \
; RUN: -r=%t1.bc,globalfunc,plx \
-; RUN: -r=%t1.bc,globalfunc,plx \
-; RUN: -r=%t1.bc,weakfunc,plx \
+; RUN: -r=%t1.bc,globalfunc,lx \
; RUN: -r=%t1.bc,weakfunc,plx \
+; RUN: -r=%t1.bc,weakfunc,lx \
; RUN: -r=%t1.bc,b,pl \
; RUN: -r=%t1.bc,x,pl \
; RUN: -r=%t1.bc,func1,pl \
diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp
index 883999b2731..856d8172fc9 100644
--- a/tools/gold/gold-plugin.cpp
+++ b/tools/gold/gold-plugin.cpp
@@ -619,6 +619,10 @@ static bool isValidCIdentifier(StringRef S) {
[](char C) { return C == '_' || isAlnum(C); });
}
+static bool isUndefined(ld_plugin_symbol &Sym) {
+ return Sym.def == LDPK_UNDEF || Sym.def == LDPK_WEAKUNDEF;
+}
+
static void addModule(LTO &Lto, claimed_file &F, const void *View,
StringRef Filename) {
MemoryBufferRef BufferRef(StringRef((const char *)View, F.filesize),
@@ -656,16 +660,16 @@ static void addModule(LTO &Lto, claimed_file &F, const void *View,
break;
case LDPR_PREVAILING_DEF_IRONLY:
- R.Prevailing = true;
+ R.Prevailing = !isUndefined(Sym);
break;
case LDPR_PREVAILING_DEF:
- R.Prevailing = true;
+ R.Prevailing = !isUndefined(Sym);
R.VisibleToRegularObj = true;
break;
case LDPR_PREVAILING_DEF_IRONLY_EXP:
- R.Prevailing = true;
+ R.Prevailing = !isUndefined(Sym);
if (!Res.CanOmitFromDynSym)
R.VisibleToRegularObj = true;
break;