xref: /llvm-project/lld/test/ELF/lto/wrap-script-referenced.ll (revision 7cc328600e250ef44f86da34e93fcdd0635339e0)
1;; Verify that the target of a wrap is kept by LTO's summary-based global dead
2;; stripping if the original symbol is referenced by a linker script or --defsym
3
4; REQUIRES: x86
5; RUN: rm -rf %t && split-file %s %t
6
7;; We need a module summary to trigger summary-based global stripping
8; RUN: opt -module-summary -o %t/foo.bc %t/foo.ll
9; RUN: echo 'alias = __real_foo;' > %t/alias.script
10; RUN: ld.lld -shared -o %t/libalias_foo.so %t/foo.bc %t/alias.script --wrap foo
11; RUN: llvm-readelf --syms %t/libalias_foo.so | FileCheck --check-prefix=FOO %s
12
13; FOO:     Symbol table '.symtab' contains
14; FOO-DAG: [[#]]: [[#%.16x,FOO_VAL:]] 1 FUNC    LOCAL  HIDDEN      [[#]] foo
15; FOO-DAG: [[#]]: [[#FOO_VAL]]        0 FUNC    GLOBAL DEFAULT     [[#]] alias
16
17; RUN: opt -module-summary -o %t/wrap_foo.bc %t/wrap_foo.ll
18; RUN: ld.lld -shared -o %t/libalias_wrap_foo.so %t/wrap_foo.bc --wrap foo --defsym=alias=foo
19; RUN: llvm-readelf --syms %t/libalias_wrap_foo.so | FileCheck --check-prefix=WRAP-FOO %s
20
21; WRAP-FOO:     Symbol table '.symtab' contains
22; WRAP-FOO-DAG: [[#]]: [[#%.16x,WRAP_FOO_VAL:]] 1 FUNC    LOCAL  HIDDEN      [[#]] __wrap_foo
23; WRAP-FOO-DAG: [[#]]: [[#WRAP_FOO_VAL]]        0 FUNC    GLOBAL DEFAULT     [[#]] alias
24
25;--- foo.ll
26target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
27target triple = "x86_64-unknown-linux-gnu"
28define hidden void @foo() {
29  ret void
30}
31
32;; We need a live root to trigger summary-based global stripping
33define dso_local void @bar() {
34  ret void
35}
36
37;--- wrap_foo.ll
38target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
39target triple = "x86_64-unknown-linux-gnu"
40define hidden void @__wrap_foo() {
41  ret void
42}
43
44define dso_local void @bar() {
45  ret void
46}
47