Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Symbols re-defined with -wrap and -defsym need to be excluded from in…
…ter- procedural optimizations to prevent dropping symbols and allow the linker to process re-directs. PR33145: --wrap doesn't work with lto. Differential Revision: https://reviews.llvm.org/D33621 llvm-svn: 304719
- Loading branch information
Showing
14 changed files
with
222 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
declare void @this_is_bar1() | ||
declare void @this_is_bar2() | ||
declare void @this_is_bar3() | ||
|
||
define hidden void @bar1() { | ||
call void @this_is_bar1() | ||
ret void | ||
} | ||
|
||
define hidden void @bar2() { | ||
call void @this_is_bar2() | ||
ret void | ||
} | ||
|
||
define hidden void @bar3() { | ||
call void @this_is_bar3() | ||
ret void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
define hidden void @bar() { | ||
ret void | ||
} | ||
|
||
define hidden void @__real_bar() { | ||
ret void | ||
} | ||
|
||
define hidden void @__wrap_bar() { | ||
ret void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
; REQUIRES: x86 | ||
; RUN: llvm-as %s -o %t.o | ||
; RUN: llvm-as %S/Inputs/defsym-bar.ll -o %t1.o | ||
; RUN: ld.lld %t.o %t1.o -shared -o %t.so -defsym=bar2=bar3 | ||
; RUN: llvm-objdump -d %t.so | FileCheck %s | ||
|
||
; Call to bar2() should not be inlined and should be routed to bar3() | ||
; Symbol bar3 should not be eliminated | ||
|
||
; CHECK: foo: | ||
; CHECK-NEXT: pushq %rax | ||
; CHECK-NEXT: callq | ||
; CHECK-NEXT: callq{{.*}}<bar3> | ||
; CHECK-NEXT: callq | ||
|
||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
declare void @bar1() | ||
declare void @bar2() | ||
declare void @bar3() | ||
|
||
define void @foo() { | ||
call void @bar1() | ||
call void @bar2() | ||
call void @bar3() | ||
ret void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
; REQUIRES: x86 | ||
; RUN: llvm-as %s -o %t.o | ||
; RUN: ld.lld %t.o -o %t.out -wrap=bar -save-temps | ||
; RUN: llvm-readobj -t %t.out | FileCheck %s | ||
; RUN: cat %t.out.resolution.txt | FileCheck -check-prefix=RESOLS %s | ||
|
||
; CHECK: Name: __wrap_bar | ||
; CHECK-NEXT: Value: | ||
; CHECK-NEXT: Size: | ||
; CHECK-NEXT: Binding: Global | ||
; CHECK-NEXT: Type: Function | ||
|
||
; Make sure that the 'r' (linker redefined) bit is set for bar and __wrap_bar | ||
; in the resolutions file. | ||
; RESOLS: ,bar,r | ||
; RESOLS: ,__wrap_bar,px | ||
; RESOLS: ,__real_bar,pxr | ||
|
||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
declare void @bar() | ||
|
||
define void @_start() { | ||
call void @bar() | ||
ret void | ||
} | ||
|
||
define void @__wrap_bar() { | ||
ret void | ||
} | ||
|
||
define void @__real_bar() { | ||
ret void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
; REQUIRES: x86 | ||
; RUN: llvm-as %s -o %t.o | ||
; RUN: llvm-as %S/Inputs/wrap-bar.ll -o %t1.o | ||
; RUN: ld.lld %t.o %t1.o -shared -o %t.so -wrap=bar | ||
; RUN: llvm-objdump -d %t.so | FileCheck %s | ||
; RUN: llvm-readobj -t %t.so | FileCheck -check-prefix=BIND %s | ||
|
||
; Make sure that calls in foo() are not eliminated and that bar is | ||
; routed to __wrap_bar and __real_bar is routed to bar. | ||
|
||
; CHECK: foo: | ||
; CHECK-NEXT: pushq %rax | ||
; CHECK-NEXT: callq{{.*}}<__wrap_bar> | ||
; CHECK-NEXT: callq{{.*}}<bar> | ||
|
||
; Check that bar and __wrap_bar retain their original binding. | ||
; BIND: Name: bar | ||
; BIND-NEXT: Value: | ||
; BIND-NEXT: Size: | ||
; BIND-NEXT: Binding: Local | ||
; BIND: Name: __wrap_bar | ||
; BIND-NEXT: Value: | ||
; BIND-NEXT: Size: | ||
; BIND-NEXT: Binding: Local | ||
|
||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
declare void @bar() | ||
declare void @__real_bar() | ||
|
||
define void @foo() { | ||
call void @bar() | ||
call void @__real_bar() | ||
ret void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
; RUN: llvm-as %s -o %t.o | ||
; RUN: llvm-lto2 run -o %t1.o %t.o -r %t.o,bar,pr | ||
; RUN: llvm-readobj -t %t1.o.0 | FileCheck %s | ||
|
||
; CHECK: Name: bar | ||
; CHECK-NEXT: Value: | ||
; CHECK-NEXT: Size: | ||
; CHECK-NEXT: Binding: Weak | ||
; CHECK-NEXT: Type: Function | ||
|
||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
define void @bar() { | ||
ret void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters