xref: /llvm-project/lld/test/ELF/x86-x32-plt.s (revision 75cdab6dc2453a508157a9c383b93373a93078d6)
1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-gnux32 %s -o %t.o
3# RUN: llvm-mc -filetype=obj -triple=x86_64-gnux32 %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: llvm-readelf -S -r %t | FileCheck %s
8# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck %s --check-prefixes=DISASM
9
10# CHECK:      Name      Type     Address          Off    Size   ES Flg Lk Inf Al
11# CHECK:      .plt      PROGBITS 002011e0 0001e0 000030 00 AX   0   0 16
12# CHECK:      .got.plt  PROGBITS 00203278 000278 000028 00 WA   0   0  8
13# CHECK:      Relocation section '.rela.plt' at offset {{.*}} contains 2 entries:
14# CHECK:      00203290 {{.*}} R_X86_64_JUMP_SLOT 00000000 weak + 0
15# CHECK-NEXT: 00203298 {{.*}} R_X86_64_JUMP_SLOT 00000000 bar + 0
16
17# DISASM:       <_start>:
18# DISASM-NEXT:    callq {{.*}} <local>
19# DISASM-NEXT:    callq {{.*}} <bar@plt>
20# DISASM-NEXT:    jmp   {{.*}} <bar@plt>
21# DISASM-NEXT:    jmp   {{.*}} <weak@plt>
22
23# DISASM:      Disassembly of section .plt:
24# DISASM-EMPTY:
25# DISASM-NEXT: <.plt>:
26# DISASM-NEXT: 2011e0:     pushq 8346(%rip)  # 0x203280
27# DISASM-NEXT:             jmpq *8348(%rip)  # 0x203288
28# DISASM-NEXT:             nopl (%rax)
29# DISASM-EMPTY:
30# DISASM-NEXT: <weak@plt>:
31# DISASM-NEXT: 2011f0:     jmpq *8346(%rip)  # 0x203290
32# DISASM-NEXT:             pushq $0
33# DISASM-NEXT:             jmp 0x2011e0 <.plt>
34# DISASM-EMPTY:
35# DISASM-NEXT: <bar@plt>:
36# DISASM-NEXT: 201200:     jmpq *8338(%rip)  # 0x203298
37# DISASM-NEXT:             pushq $1
38# DISASM-NEXT:             jmp 0x2011e0 <.plt>
39# DISASM-NOT:  {{.}}
40
41.global _start
42.weak weak
43
44_start:
45  call local
46  call bar
47  jmp bar@plt
48  jmp weak
49
50## foo is local and non-preemptale, no PLT is generated.
51local:
52  ret
53