Skip to content

Commit

Permalink
Fix linking of shared libraries.
Browse files Browse the repository at this point in the history
In shared libraries the plugin can see non-weak declarations that are still
undefined.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226031 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
espindola committed Jan 14, 2015
1 parent 4ade012 commit 0a2caa1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions test/tools/gold/emit-llvm.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ target triple = "x86_64-unknown-linux-gnu"
@g7 = extern_weak global i32
; CHECK-DAG: @g7 = extern_weak global i32

@g8 = external global i32

; CHECK: define internal void @f1()
; OPT-NOT: @f1
define hidden void @f1() {
Expand Down Expand Up @@ -69,13 +71,19 @@ define i32* @f7() {
ret i32* @g7
}

define i32* @f8() {
ret i32* @g8
}

; API: f1 PREVAILING_DEF_IRONLY
; API: f2 PREVAILING_DEF_IRONLY
; API: f3 PREVAILING_DEF_IRONLY_EXP
; API: f4 PREVAILING_DEF_IRONLY_EXP
; API: f5 PREVAILING_DEF_IRONLY_EXP
; API: f6 PREVAILING_DEF_IRONLY_EXP
; API: f7 PREVAILING_DEF_IRONLY_EXP
; API: f8 PREVAILING_DEF_IRONLY_EXP
; API: g7 UNDEF
; API: g8 UNDEF
; API: g5 PREVAILING_DEF_IRONLY_EXP
; API: g6 PREVAILING_DEF_IRONLY_EXP
2 changes: 1 addition & 1 deletion tools/gold/gold-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ getModuleForFile(LLVMContext &Context, claimed_file &F, raw_fd_ostream *ApiFile,
break;

case LDPR_UNDEF:
if (!GV->hasExternalWeakLinkage()) {
if (!GV->isDeclarationForLinker()) {
assert(GV->hasComdat());
Drop.insert(GV);
}
Expand Down

0 comments on commit 0a2caa1

Please sign in to comment.