92 lines · plain
1# REQUIRES: x862## Verify that we can correctly wrap symbols produced only during LTO codegen3## and unreferenced before then.4 5# RUN: rm -rf %t && split-file %s %t6# RUN: llvm-mc -triple x86_64-elf --filetype=obj -o %t/unwind.o %t/unwind.s7# RUN: ld.lld -shared -o %t/libunwind.so -soname libunwind.so %t/unwind.o8# RUN: llvm-as -o %t/resume.bc %t/resume.ll9# RUN: ld.lld -shared -o %t/libresume.so -soname libresume.so %t/resume.bc \10# RUN: %t/libunwind.so --wrap _Unwind_Resume11# RUN: llvm-objdump --no-print-imm-hex --dynamic-reloc --disassemble %t/libresume.so | \12# RUN: FileCheck --check-prefix=UNWIND-DISASM %s13# RUN: llvm-readelf --dyn-syms %t/libresume.so | \14# RUN: FileCheck --check-prefix=UNWIND-DYNSYM %s15 16# UNWIND-DISASM: [[#%x,RELOC:]] R_X86_64_JUMP_SLOT __wrap__Unwind_Resume17# 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]]21 22# UNWIND-DYNSYM: Symbol table '.dynsym' contains 4 entries:23# UNWIND-DYNSYM: NOTYPE LOCAL DEFAULT UND24# UNWIND-DYNSYM-NEXT: NOTYPE GLOBAL DEFAULT UND throw25# UNWIND-DYNSYM-NEXT: NOTYPE GLOBAL DEFAULT UND __wrap__Unwind_Resume26# UNWIND-DYNSYM-NEXT: FUNC GLOBAL DEFAULT 9 _Z1fv27 28# RUN: llvm-mc -triple x86_64-elf -filetype=obj -o %t/malloc.o %t/malloc.s29# RUN: ld.lld -shared -o %t/libmalloc.so -soname libmalloc.so %t/malloc.o30# RUN: llvm-mc -triple x86_64-elf -filetype=obj -o %t/emutls.o %t/emutls.s31# RUN: llvm-as -o %t/usetls.bc %t/usetls.ll32# 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 malloc35# RUN: llvm-objdump --no-print-imm-hex --dynamic-reloc --disassemble %t/libusetls.so | \36# RUN: FileCheck --check-prefix=USETLS-DISASM %s37# RUN: llvm-readelf --dyn-syms %t/libusetls.so | \38# RUN: FileCheck --check-prefix=USETLS-DYNSYM %s39 40# USETLS-DISASM: [[#%x,RELOC:]] R_X86_64_JUMP_SLOT __wrap_malloc41# 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]]45 46# USETLS-DYNSYM: Symbol table '.dynsym' contains 5 entries:47# USETLS-DYNSYM: NOTYPE LOCAL DEFAULT UND48# USETLS-DYNSYM-NEXT: NOTYPE GLOBAL DEFAULT UND __wrap_malloc49# USETLS-DYNSYM-NEXT: FUNC GLOBAL DEFAULT 6 f50# USETLS-DYNSYM-NEXT: NOTYPE GLOBAL DEFAULT 6 __emutls_get_address51 52#--- unwind.s53.globl _Unwind_Resume54.globl __wrap__Unwind_Resume55_Unwind_Resume:56__wrap__Unwind_Resume:57 retq58 59#--- resume.ll60target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"61target triple = "x86_64-unknown-linux-gnu"62define dso_local void @_Z1fv() optnone noinline personality ptr @throw {63 invoke void @throw()64 to label %unreachable unwind label %lpad65lpad:66 %1 = landingpad { ptr, i32 }67 cleanup68 resume { ptr, i32 } %169unreachable:70 unreachable71}72declare void @throw()73 74#--- malloc.s75.globl malloc76malloc:77 retq78 79#--- emutls.s80.globl __emutls_get_address81__emutls_get_address:82 jmp malloc@plt83 84#--- usetls.ll85target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"86target triple = "x86_64-unknown-linux-gnu"87@x = dso_local thread_local global i32 0, align 488define dso_local i32 @f() {89 %loaded = load i32, ptr @x, align 490 ret i32 %loaded91}92