2015-08-28 07:15:56 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
|
2015-09-30 07:22:16 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/shared.s -o %t2
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld %t2 -o %t2.so -shared
|
|
|
|
// RUN: ld.lld %t %t2.so -o %t3
|
2015-09-30 07:22:16 +08:00
|
|
|
// RUN: llvm-readobj -s %t3 | FileCheck --check-prefix=SEC %s
|
|
|
|
// RUN: llvm-objdump -s -d %t3 | FileCheck %s
|
2015-08-28 07:15:56 +08:00
|
|
|
// REQUIRES: x86
|
|
|
|
|
2015-10-02 05:15:02 +08:00
|
|
|
// SEC: Name: .plt
|
|
|
|
// SEC-NEXT: Type: SHT_PROGBITS
|
|
|
|
// SEC-NEXT: Flags [
|
|
|
|
// SEC-NEXT: SHF_ALLOC
|
|
|
|
// SEC-NEXT: SHF_EXECINSTR
|
|
|
|
// SEC-NEXT: ]
|
2016-11-24 01:44:02 +08:00
|
|
|
// SEC-NEXT: Address: 0x201030
|
2015-10-15 00:15:46 +08:00
|
|
|
// SEC-NEXT: Offset: 0x1030
|
2016-02-25 00:37:47 +08:00
|
|
|
// SEC-NEXT: Size: 48
|
2015-10-02 05:15:02 +08:00
|
|
|
|
2015-10-14 00:59:30 +08:00
|
|
|
// SEC: Name: .got
|
2015-09-24 04:08:25 +08:00
|
|
|
// SEC-NEXT: Type: SHT_PROGBITS
|
|
|
|
// SEC-NEXT: Flags [
|
|
|
|
// SEC-NEXT: SHF_ALLOC
|
|
|
|
// SEC-NEXT: SHF_WRITE
|
|
|
|
// SEC-NEXT: ]
|
2016-11-24 01:44:02 +08:00
|
|
|
// SEC-NEXT: Address: 0x2020F0
|
2015-09-24 04:08:25 +08:00
|
|
|
// SEC-NEXT: Offset:
|
2015-10-20 16:54:27 +08:00
|
|
|
// SEC-NEXT: Size: 8
|
2015-09-24 04:08:25 +08:00
|
|
|
// SEC-NEXT: Link: 0
|
|
|
|
// SEC-NEXT: Info: 0
|
|
|
|
// SEC-NEXT: AddressAlignment: 8
|
|
|
|
// SEC-NEXT: EntrySize: 0
|
|
|
|
// SEC-NEXT: }
|
2015-08-28 07:15:56 +08:00
|
|
|
|
2015-11-15 04:56:08 +08:00
|
|
|
// SEC: Name: .got.plt
|
2015-10-20 16:54:27 +08:00
|
|
|
// SEC-NEXT: Type: SHT_PROGBITS
|
|
|
|
// SEC-NEXT: Flags [
|
|
|
|
// SEC-NEXT: SHF_ALLOC
|
|
|
|
// SEC-NEXT: SHF_WRITE
|
|
|
|
// SEC-NEXT: ]
|
2016-11-24 01:44:02 +08:00
|
|
|
// SEC-NEXT: Address: 0x203000
|
2015-12-23 23:20:38 +08:00
|
|
|
// SEC-NEXT: Offset: 0x3000
|
2016-02-25 00:37:47 +08:00
|
|
|
// SEC-NEXT: Size: 40
|
2015-10-20 16:54:27 +08:00
|
|
|
// SEC-NEXT: Link: 0
|
|
|
|
// SEC-NEXT: Info: 0
|
|
|
|
// SEC-NEXT: AddressAlignment: 8
|
|
|
|
// SEC-NEXT: EntrySize: 0
|
|
|
|
// SEC-NEXT: }
|
|
|
|
|
2015-08-28 07:15:56 +08:00
|
|
|
.section .text,"ax",@progbits,unique,1
|
|
|
|
.global _start
|
|
|
|
_start:
|
|
|
|
call lulz
|
|
|
|
|
|
|
|
.section .text,"ax",@progbits,unique,2
|
|
|
|
.zero 4
|
|
|
|
.global lulz
|
|
|
|
lulz:
|
2015-09-15 21:30:08 +08:00
|
|
|
nop
|
|
|
|
|
|
|
|
// CHECK: Disassembly of section .text:
|
|
|
|
// CHECK-NEXT: _start:
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: 201000: e8 04 00 00 00 callq 4
|
|
|
|
// CHECK-NEXT: 201005:
|
2015-09-15 21:30:08 +08:00
|
|
|
|
|
|
|
// CHECK: lulz:
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: 201009: 90 nop
|
2015-09-15 21:30:08 +08:00
|
|
|
|
2015-08-28 07:15:56 +08:00
|
|
|
|
2015-09-15 21:30:08 +08:00
|
|
|
.section .text2,"ax",@progbits
|
2015-09-15 21:52:06 +08:00
|
|
|
.global R_X86_64_32
|
|
|
|
R_X86_64_32:
|
|
|
|
movl $R_X86_64_32, %edx
|
2015-08-29 21:15:42 +08:00
|
|
|
|
2015-09-15 21:30:08 +08:00
|
|
|
// FIXME: this would be far more self evident if llvm-objdump printed
|
|
|
|
// constants in hex.
|
|
|
|
// CHECK: Disassembly of section .text2:
|
2015-09-15 21:52:06 +08:00
|
|
|
// CHECK-NEXT: R_X86_64_32:
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: 20100a: {{.*}} movl $2101258, %edx
|
2015-09-15 21:52:06 +08:00
|
|
|
|
2015-09-16 08:24:19 +08:00
|
|
|
.section .R_X86_64_32S,"ax",@progbits
|
|
|
|
.global R_X86_64_32S
|
|
|
|
R_X86_64_32S:
|
|
|
|
movq lulz - 0x100000, %rdx
|
|
|
|
|
|
|
|
// CHECK: Disassembly of section .R_X86_64_32S:
|
|
|
|
// CHECK-NEXT: R_X86_64_32S:
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: {{.*}}: {{.*}} movq 1052681, %rdx
|
2015-09-16 08:24:19 +08:00
|
|
|
|
2015-09-30 07:22:16 +08:00
|
|
|
.section .R_X86_64_PC32,"ax",@progbits
|
|
|
|
.global R_X86_64_PC32
|
|
|
|
R_X86_64_PC32:
|
|
|
|
call bar
|
2015-10-15 00:15:46 +08:00
|
|
|
movl $bar, %eax
|
2015-10-20 16:54:27 +08:00
|
|
|
//16 is a size of PLT[0]
|
2016-11-24 01:44:02 +08:00
|
|
|
// 0x201030 + 16 - (0x201017 + 5) = 20
|
2015-09-30 07:22:16 +08:00
|
|
|
// CHECK: Disassembly of section .R_X86_64_PC32:
|
|
|
|
// CHECK-NEXT: R_X86_64_PC32:
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: 201017: {{.*}} callq 36
|
|
|
|
// CHECK-NEXT: 20101c: {{.*}} movl $2101312, %eax
|
2015-09-30 07:22:16 +08:00
|
|
|
|
2016-02-25 00:37:47 +08:00
|
|
|
.section .R_X86_64_32S_2,"ax",@progbits
|
|
|
|
.global R_X86_64_32S_2
|
|
|
|
R_X86_64_32S_2:
|
|
|
|
mov bar2, %eax
|
2016-11-24 01:44:02 +08:00
|
|
|
// plt is at 0x201030. The second plt entry is at 0x201050 == 69712
|
2016-02-25 00:37:47 +08:00
|
|
|
// CHECK: Disassembly of section .R_X86_64_32S_2:
|
|
|
|
// CHECK-NEXT: R_X86_64_32S_2:
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: 201021: {{.*}} movl 2101328, %eax
|
2016-02-25 00:37:47 +08:00
|
|
|
|
2015-09-15 21:52:06 +08:00
|
|
|
.section .R_X86_64_64,"a",@progbits
|
|
|
|
.global R_X86_64_64
|
|
|
|
R_X86_64_64:
|
|
|
|
.quad R_X86_64_64
|
|
|
|
|
|
|
|
// CHECK: Contents of section .R_X86_64_64:
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: 2001c8 c8012000 00000000
|
2015-09-24 04:08:25 +08:00
|
|
|
|
|
|
|
.section .R_X86_64_GOTPCREL,"a",@progbits
|
|
|
|
.global R_X86_64_GOTPCREL
|
|
|
|
R_X86_64_GOTPCREL:
|
2015-10-07 05:52:48 +08:00
|
|
|
.long zed@gotpcrel
|
2015-09-24 04:08:25 +08:00
|
|
|
|
2016-11-24 01:44:02 +08:00
|
|
|
// 0x2020F8 - 0x2001D8 = 7952
|
2015-11-25 02:48:16 +08:00
|
|
|
// 7952 = 0x101f0000 in little endian
|
2015-09-24 04:08:25 +08:00
|
|
|
// CHECK: Contents of section .R_X86_64_GOTPCREL
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: 2001d0 201f0000
|
2016-04-18 20:58:59 +08:00
|
|
|
|
|
|
|
.section .R_X86_64_GOT32,"a",@progbits
|
|
|
|
.global R_X86_64_GOT32
|
|
|
|
R_X86_64_GOT32:
|
|
|
|
.long zed@got
|
|
|
|
|
|
|
|
// CHECK: Contents of section .R_X86_64_GOT32:
|
|
|
|
// CHECK-NEXT: f8ffffff
|