2 ## Verify that we can correctly wrap symbols produced only during LTO codegen
3 ## and unreferenced before then.
5 # RUN: rm -rf %t && split-file %s %t
6 # RUN: llvm-mc -triple x86_64-elf --filetype=obj -o %t/unwind.o %t/unwind.s
7 # RUN: ld.lld -shared -o %t/libunwind.so -soname libunwind.so %t/unwind.o
8 # RUN: llvm-as -o %t/resume.bc %t/resume.ll
9 # RUN: ld.lld -shared -o %t/libresume.so -soname libresume.so %t/resume.bc \
10 # RUN: %t/libunwind.so --wrap _Unwind_Resume
11 # RUN: llvm-objdump --no-print-imm-hex --dynamic-reloc --disassemble %t/libresume.so | \
12 # RUN: FileCheck --check-prefix=UNWIND-DISASM %s
13 # RUN: llvm-readelf --dyn-syms %t/libresume.so | \
14 # RUN: FileCheck --check-prefix=UNWIND-DYNSYM %s
16 # UNWIND-DISASM: [[#%x,RELOC:]] R_X86_64_JUMP_SLOT __wrap__Unwind_Resume
17 # UNWIND-DISASM-LABEL: <_Z1fv>:
18 # UNWIND-DISASM: callq {{.*}}<__wrap__Unwind_Resume@plt>
19 # UNWIND-DISASM-LABEL: <__wrap__Unwind_Resume@plt>:
20 # UNWIND-DISASM-NEXT: jmpq *[[#]](%rip) # [[#%#x,RELOC]]
22 # UNWIND-DYNSYM: Symbol table '.dynsym' contains 4 entries:
23 # UNWIND-DYNSYM: NOTYPE LOCAL DEFAULT UND
24 # UNWIND-DYNSYM-NEXT: NOTYPE GLOBAL DEFAULT UND throw
25 # UNWIND-DYNSYM-NEXT: NOTYPE GLOBAL DEFAULT UND __wrap__Unwind_Resume
26 # UNWIND-DYNSYM-NEXT: FUNC GLOBAL DEFAULT 9 _Z1fv
28 # RUN: llvm-mc -triple x86_64-elf -filetype=obj -o %t/malloc.o %t/malloc.s
29 # RUN: ld.lld -shared -o %t/libmalloc.so -soname libmalloc.so %t/malloc.o
30 # RUN: llvm-mc -triple x86_64-elf -filetype=obj -o %t/emutls.o %t/emutls.s
31 # RUN: llvm-as -o %t/usetls.bc %t/usetls.ll
32 # RUN: ld.lld -shared -o %t/libusetls.so \
33 # RUN: %t/usetls.bc %t/libmalloc.so \
34 # RUN: --start-lib %t/emutls.o -mllvm -emulated-tls --wrap malloc
35 # RUN: llvm-objdump --no-print-imm-hex --dynamic-reloc --disassemble %t/libusetls.so | \
36 # RUN: FileCheck --check-prefix=USETLS-DISASM %s
37 # RUN: llvm-readelf --dyn-syms %t/libusetls.so | \
38 # RUN: FileCheck --check-prefix=USETLS-DYNSYM %s
40 # USETLS-DISASM: [[#%x,RELOC:]] R_X86_64_JUMP_SLOT __wrap_malloc
41 # USETLS-DISASM-LABEL: <__emutls_get_address>:
42 # USETLS-DISASM-NEXT: jmp{{.*}}<__wrap_malloc@plt>
43 # USETLS-DISASM-LABEL: <__wrap_malloc@plt>:
44 # USETLS-DISASM-NEXT: jmpq *[[#]](%rip) # [[#%#x,RELOC]]
46 # USETLS-DYNSYM: Symbol table '.dynsym' contains 5 entries:
47 # USETLS-DYNSYM: NOTYPE LOCAL DEFAULT UND
48 # USETLS-DYNSYM-NEXT: NOTYPE GLOBAL DEFAULT UND __wrap_malloc
49 # USETLS-DYNSYM-NEXT: FUNC GLOBAL DEFAULT 6 f
50 # USETLS-DYNSYM-NEXT: NOTYPE GLOBAL DEFAULT 6 __emutls_get_address
54 .globl __wrap__Unwind_Resume
56 __wrap__Unwind_Resume:
60 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
61 target triple = "x86_64-unknown-linux-gnu"
62 define dso_local void @_Z1fv() optnone noinline personality ptr @throw {
64 to label %unreachable unwind label %lpad
66 %1 = landingpad { ptr, i32 }
68 resume { ptr, i32 } %1
80 .globl __emutls_get_address
85 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
86 target triple = "x86_64-unknown-linux-gnu"
87 @x = dso_local thread_local global i32 0, align 4
88 define dso_local i32 @f() {
89 %loaded = load i32, ptr @x, align 4