2 ## --wrap=xxx should trigger archive extraction for symbol xxx for references to __real_xxx.
4 # RUN: rm -rf %t && split-file %s %t && cd %t
5 # RUN: llvm-as _start.ll -o _start.o
6 # RUN: llvm-as _start_ref__real_foo.ll -o _start_ref__real_foo.o
7 # RUN: llvm-as wrap.ll -o wrap.o
8 # RUN: llvm-as foo.ll -o foo.o
10 ## Test when the reference to __real_foo is not in __wrap_foo.
11 # RUN: ld.lld _start_ref__real_foo.o --start-lib foo.o --end-lib --wrap foo -o %t_real.elf
12 # RUN: llvm-readelf --symbols %t_real.elf | FileCheck %s --check-prefix=REAL
14 # REAL: Symbol table '.symtab' contains 5 entries:
15 # REAL-NEXT: Value Size Type Bind Vis Ndx Name
16 # REAL-NEXT: {{.*}} {{.*}} NOTYPE LOCAL DEFAULT UND
17 # REAL-NEXT: {{.*}} {{.*}} FILE LOCAL DEFAULT ABS ld-temp.o
18 # REAL-NEXT: {{.*}} {{.*}} FUNC GLOBAL DEFAULT [[#]] _start
19 # REAL-NEXT: {{.*}} {{.*}} FUNC WEAK DEFAULT [[#]] foo
20 # REAL-NEXT: {{.*}} {{.*}} NOTYPE GLOBAL DEFAULT UND __wrap_foo
22 ## Test when the reference to __real_foo is in __wrap_foo.
23 # RUN: ld.lld _start.o --start-lib wrap.o --end-lib --start-lib foo.o --end-lib --wrap foo -o %t_wrap_real.elf
24 # RUN: llvm-readelf --symbols %t_wrap_real.elf | FileCheck %s --check-prefix=WRAP_REAL
26 # WRAP_REAL: Symbol table '.symtab' contains 5 entries:
27 # WRAP_REAL-NEXT: Value Size Type Bind Vis Ndx Name
28 # WRAP_REAL-NEXT: {{.*}} {{.*}} NOTYPE LOCAL DEFAULT UND
29 # WRAP_REAL-NEXT: {{.*}} {{.*}} FILE LOCAL DEFAULT ABS ld-temp.o
30 # WRAP_REAL-NEXT: {{.*}} {{.*}} FUNC GLOBAL DEFAULT [[#]] _start
31 # WRAP_REAL-NEXT: {{.*}} {{.*}} FUNC GLOBAL DEFAULT [[#]] __wrap_foo
32 # WRAP_REAL-NEXT: {{.*}} {{.*}} FUNC WEAK DEFAULT [[#]] foo
35 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
36 target triple = "x86_64-elf"
37 define void @_start() {
41 #--- _start_ref__real_foo.ll
42 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
43 target triple = "x86_64-elf"
44 define void @_start() {
45 call void @__real_foo()
49 declare void @__real_foo()
52 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
53 target triple = "x86_64-elf"
54 define void @__wrap_foo() {
55 call void @__real_foo()
59 declare void @__real_foo()
62 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
63 target triple = "x86_64-elf"