2015-09-21 23:11:29 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -shared %t2.o -o %t2.so
|
|
|
|
// RUN: ld.lld -shared %t.o %t2.so -o %t
|
|
|
|
// RUN: ld.lld %t.o %t2.so -o %t3
|
2015-09-21 23:11:29 +08:00
|
|
|
// RUN: llvm-readobj -s -r %t | FileCheck %s
|
|
|
|
// RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s
|
2015-10-17 07:52:24 +08:00
|
|
|
// RUN: llvm-readobj -s -r %t3 | FileCheck --check-prefix=CHECK2 %s
|
|
|
|
// RUN: llvm-objdump -d %t3 | FileCheck --check-prefix=DISASM2 %s
|
|
|
|
|
2015-09-21 23:11:29 +08:00
|
|
|
// REQUIRES: x86
|
|
|
|
|
|
|
|
// CHECK: Name: .plt
|
|
|
|
// CHECK-NEXT: Type: SHT_PROGBITS
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_EXECINSTR
|
|
|
|
// CHECK-NEXT: ]
|
2015-10-11 07:25:39 +08:00
|
|
|
// CHECK-NEXT: Address: 0x1020
|
2015-09-21 23:11:29 +08:00
|
|
|
// CHECK-NEXT: Offset:
|
2015-10-20 16:54:27 +08:00
|
|
|
// CHECK-NEXT: Size: 64
|
2015-09-21 23:11:29 +08:00
|
|
|
// CHECK-NEXT: Link: 0
|
|
|
|
// CHECK-NEXT: Info: 0
|
|
|
|
// CHECK-NEXT: AddressAlignment: 16
|
|
|
|
|
|
|
|
// CHECK: Relocations [
|
2015-10-20 16:54:27 +08:00
|
|
|
// CHECK-NEXT: Section ({{.*}}) .rela.plt {
|
2015-12-23 23:20:38 +08:00
|
|
|
// CHECK-NEXT: 0x3018 R_X86_64_JUMP_SLOT bar 0x0
|
|
|
|
// CHECK-NEXT: 0x3020 R_X86_64_JUMP_SLOT zed 0x0
|
|
|
|
// CHECK-NEXT: 0x3028 R_X86_64_JUMP_SLOT _start 0x0
|
2015-09-21 23:11:29 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
|
2015-10-17 07:52:24 +08:00
|
|
|
// CHECK2: Name: .plt
|
|
|
|
// CHECK2-NEXT: Type: SHT_PROGBITS
|
|
|
|
// CHECK2-NEXT: Flags [
|
|
|
|
// CHECK2-NEXT: SHF_ALLOC
|
|
|
|
// CHECK2-NEXT: SHF_EXECINSTR
|
|
|
|
// CHECK2-NEXT: ]
|
|
|
|
// CHECK2-NEXT: Address: 0x11020
|
|
|
|
// CHECK2-NEXT: Offset:
|
2015-10-20 16:54:27 +08:00
|
|
|
// CHECK2-NEXT: Size: 48
|
2015-10-17 07:52:24 +08:00
|
|
|
// CHECK2-NEXT: Link: 0
|
|
|
|
// CHECK2-NEXT: Info: 0
|
|
|
|
// CHECK2-NEXT: AddressAlignment: 16
|
|
|
|
|
|
|
|
// CHECK2: Relocations [
|
2015-10-20 16:54:27 +08:00
|
|
|
// CHECK2-NEXT: Section ({{.*}}) .rela.plt {
|
2015-12-23 23:20:38 +08:00
|
|
|
// CHECK2-NEXT: 0x13018 R_X86_64_JUMP_SLOT bar 0x0
|
|
|
|
// CHECK2-NEXT: 0x13020 R_X86_64_JUMP_SLOT zed 0x0
|
2015-10-17 07:52:24 +08:00
|
|
|
// CHECK2-NEXT: }
|
|
|
|
// CHECK2-NEXT: ]
|
|
|
|
|
2015-09-21 23:11:29 +08:00
|
|
|
// Unfortunately FileCheck can't do math, so we have to check for explicit
|
|
|
|
// values:
|
|
|
|
|
2015-10-20 16:54:27 +08:00
|
|
|
// 0x1030 - (0x1000 + 5) = 43
|
|
|
|
// 0x1030 - (0x1005 + 5) = 38
|
|
|
|
// 0x1040 - (0x100a + 5) = 49
|
|
|
|
// 0x1048 - (0x100a + 5) = 60
|
2015-09-21 23:11:29 +08:00
|
|
|
|
|
|
|
// DISASM: _start:
|
2015-10-20 16:54:27 +08:00
|
|
|
// DISASM-NEXT: 1000: e9 {{.*}} jmp 43
|
|
|
|
// DISASM-NEXT: 1005: e9 {{.*}} jmp 38
|
|
|
|
// DISASM-NEXT: 100a: e9 {{.*}} jmp 49
|
|
|
|
// DISASM-NEXT: 100f: e9 {{.*}} jmp 60
|
2015-09-21 23:11:29 +08:00
|
|
|
|
2015-12-23 23:20:38 +08:00
|
|
|
// 0x3018 - 0x1036 = 8162
|
|
|
|
// 0x3020 - 0x1046 = 4234
|
|
|
|
// 0x3028 - 0x1056 = 4226
|
2015-09-21 23:11:29 +08:00
|
|
|
|
|
|
|
// DISASM: Disassembly of section .plt:
|
|
|
|
// DISASM-NEXT: .plt:
|
2015-12-23 23:20:38 +08:00
|
|
|
// DISASM-NEXT: 1020: ff 35 e2 1f 00 00 pushq 8162(%rip)
|
|
|
|
// DISASM-NEXT: 1026: ff 25 e4 1f 00 00 jmpq *8164(%rip)
|
2015-10-20 16:54:27 +08:00
|
|
|
// DISASM-NEXT: 102c: 0f 1f 40 00 nopl (%rax)
|
2015-12-23 23:20:38 +08:00
|
|
|
// DISASM-NEXT: 1030: ff 25 e2 1f 00 00 jmpq *8162(%rip)
|
2015-10-20 16:54:27 +08:00
|
|
|
// DISASM-NEXT: 1036: 68 00 00 00 00 pushq $0
|
2015-11-18 12:37:23 +08:00
|
|
|
// DISASM-NEXT: 103b: e9 e0 ff ff ff jmp -32 <.plt>
|
2015-12-23 23:20:38 +08:00
|
|
|
// DISASM-NEXT: 1040: ff 25 da 1f 00 00 jmpq *8154(%rip)
|
2015-10-20 16:54:27 +08:00
|
|
|
// DISASM-NEXT: 1046: 68 01 00 00 00 pushq $1
|
2015-11-18 12:37:23 +08:00
|
|
|
// DISASM-NEXT: 104b: e9 d0 ff ff ff jmp -48 <.plt>
|
2015-12-23 23:20:38 +08:00
|
|
|
// DISASM-NEXT: 1050: ff 25 d2 1f 00 00 jmpq *8146(%rip)
|
2015-10-20 16:54:27 +08:00
|
|
|
// DISASM-NEXT: 1056: 68 02 00 00 00 pushq $2
|
2015-11-18 12:37:23 +08:00
|
|
|
// DISASM-NEXT: 105b: e9 c0 ff ff ff jmp -64 <.plt>
|
2015-10-17 07:52:24 +08:00
|
|
|
|
2015-10-20 16:54:27 +08:00
|
|
|
// 0x11030 - (0x11000 + 1) - 4 = 43
|
|
|
|
// 0x11030 - (0x11005 + 1) - 4 = 38
|
|
|
|
// 0x11040 - (0x1100a + 1) - 4 = 49
|
2015-10-17 07:52:24 +08:00
|
|
|
// 0x11000 - (0x1100f + 1) - 4 = -20
|
|
|
|
|
|
|
|
// DISASM2: _start:
|
2015-10-20 16:54:27 +08:00
|
|
|
// DISASM2-NEXT: 11000: e9 {{.*}} jmp 43
|
|
|
|
// DISASM2-NEXT: 11005: e9 {{.*}} jmp 38
|
|
|
|
// DISASM2-NEXT: 1100a: e9 {{.*}} jmp 49
|
2015-10-17 07:52:24 +08:00
|
|
|
// DISASM2-NEXT: 1100f: e9 {{.*}} jmp -20
|
|
|
|
|
2015-12-23 23:20:38 +08:00
|
|
|
// 0x13018 - 0x11036 = 4242
|
|
|
|
// 0x13020 - 0x11046 = 4234
|
2015-10-20 16:54:27 +08:00
|
|
|
|
2015-10-17 07:52:24 +08:00
|
|
|
// DISASM2: Disassembly of section .plt:
|
|
|
|
// DISASM2-NEXT: .plt:
|
2015-12-23 23:20:38 +08:00
|
|
|
// DISASM2-NEXT: 11020: ff 35 e2 1f 00 00 pushq 8162(%rip)
|
|
|
|
// DISASM2-NEXT: 11026: ff 25 e4 1f 00 00 jmpq *8164(%rip)
|
2015-10-20 16:54:27 +08:00
|
|
|
// DISASM2-NEXT: 1102c: 0f 1f 40 00 nopl (%rax)
|
2015-12-23 23:20:38 +08:00
|
|
|
// DISASM2-NEXT: 11030: ff 25 e2 1f 00 00 jmpq *8162(%rip)
|
2015-10-20 16:54:27 +08:00
|
|
|
// DISASM2-NEXT: 11036: 68 00 00 00 00 pushq $0
|
2015-11-18 12:37:23 +08:00
|
|
|
// DISASM2-NEXT: 1103b: e9 e0 ff ff ff jmp -32 <.plt>
|
2015-12-23 23:20:38 +08:00
|
|
|
// DISASM2-NEXT: 11040: ff 25 da 1f 00 00 jmpq *8154(%rip)
|
2015-10-20 16:54:27 +08:00
|
|
|
// DISASM2-NEXT: 11046: 68 01 00 00 00 pushq $1
|
2015-11-18 12:37:23 +08:00
|
|
|
// DISASM2-NEXT: 1104b: e9 d0 ff ff ff jmp -48 <.plt>
|
2016-03-01 02:05:21 +08:00
|
|
|
// DISASM2-NOT: 110C0
|
2015-09-21 23:11:29 +08:00
|
|
|
|
|
|
|
.global _start
|
|
|
|
_start:
|
|
|
|
jmp bar@PLT
|
|
|
|
jmp bar@PLT
|
|
|
|
jmp zed@PLT
|
2015-09-29 03:48:34 +08:00
|
|
|
jmp _start@plt
|