1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o 3# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/shared.s -o %t2.o 4# RUN: ld.lld -shared -soname=t2 %t2.o -o %t2.so 5 6# RUN: ld.lld %t.o %t2.so -o %t 7# RUN: ld.lld -shared %t.o %t2.so -o %t.so 8# RUN: llvm-readelf -S -r %t | FileCheck %s --check-prefix=CHECK1 9# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck %s --check-prefixes=DISASM,DISASM1 10# RUN: llvm-readelf -S -r %t.so | FileCheck %s --check-prefix=CHECK2 11# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t.so | FileCheck %s --check-prefixes=DISASM,DISASM2 12 13# CHECK1: Name Type Address Off Size ES Flg Lk Inf Al 14# CHECK1: .plt PROGBITS 00000000002012e0 0002e0 000030 00 AX 0 0 16 15# CHECK1: .got.plt PROGBITS 00000000002033e0 0003e0 000028 00 WA 0 0 8 16# CHECK1: Relocation section '.rela.plt' at offset {{.*}} contains 2 entries: 17# CHECK1: 00000000002033f8 {{.*}} R_X86_64_JUMP_SLOT 0000000000000000 weak + 0 18# CHECK1-NEXT: 0000000000203400 {{.*}} R_X86_64_JUMP_SLOT 0000000000000000 bar + 0 19 20# CHECK2: Name Type Address Off Size ES Flg Lk Inf Al 21# CHECK2: .plt PROGBITS 0000000000001310 000310 000030 00 AX 0 0 16 22# CHECK2: .got.plt PROGBITS 0000000000003400 000400 000028 00 WA 0 0 8 23# CHECK2: Relocation section '.rela.plt' at offset {{.*}} contains 2 entries: 24# CHECK2: 0000000000003418 {{.*}} R_X86_64_JUMP_SLOT 0000000000000000 weak + 0 25# CHECK2-NEXT: 0000000000003420 {{.*}} R_X86_64_JUMP_SLOT 0000000000000000 bar + 0 26 27# DISASM: <_start>: 28# DISASM-NEXT: callq {{.*}} <local> 29# DISASM-NEXT: callq {{.*}} <bar@plt> 30# DISASM-NEXT: jmp {{.*}} <bar@plt> 31# DISASM-NEXT: jmp {{.*}} <weak@plt> 32 33# DISASM1: Disassembly of section .plt: 34# DISASM1-EMPTY: 35# DISASM1-NEXT: <.plt>: 36# DISASM1-NEXT: 2012e0: pushq 8450(%rip) # 0x2033e8 37# DISASM1-NEXT: jmpq *8452(%rip) # 0x2033f0 38# DISASM1-NEXT: nopl (%rax) 39# DISASM1-EMPTY: 40# DISASM1-NEXT: <weak@plt>: 41# DISASM1-NEXT: 2012f0: jmpq *8450(%rip) # 0x2033f8 42# DISASM1-NEXT: pushq $0 43# DISASM1-NEXT: jmp 0x2012e0 <.plt> 44# DISASM1-EMPTY: 45# DISASM1-NEXT: <bar@plt>: 46# DISASM1-NEXT: 201300: jmpq *8442(%rip) # 0x203400 47# DISASM1-NEXT: pushq $1 48# DISASM1-NEXT: jmp 0x2012e0 <.plt> 49# DISASM1-NOT: {{.}} 50 51# DISASM2: Disassembly of section .plt: 52# DISASM2-EMPTY: 53# DISASM2-NEXT: <.plt>: 54# DISASM2-NEXT: 1310: pushq 8434(%rip) # 0x3408 55# DISASM2-NEXT: jmpq *8436(%rip) # 0x3410 56# DISASM2-NEXT: nopl (%rax) 57# DISASM2-EMPTY: 58# DISASM2-NEXT: <weak@plt>: 59# DISASM2-NEXT: 1320: jmpq *8434(%rip) # 0x3418 60# DISASM2-NEXT: pushq $0 61# DISASM2-NEXT: jmp 0x1310 <.plt> 62# DISASM2-EMPTY: 63# DISASM2-NEXT: <bar@plt>: 64# DISASM2-NEXT: 1330: jmpq *8426(%rip) # 0x3420 65# DISASM2-NEXT: pushq $1 66# DISASM2-NEXT: jmp 0x1310 <.plt> 67# DISASM2-NOT: {{.}} 68 69.global _start 70.weak weak 71 72_start: 73 call local 74 call bar 75 jmp bar@plt 76 jmp weak 77 78## foo is local and non-preemptale, no PLT is generated. 79local: 80 ret 81