1// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
2// RUN: ld.lld %t -o %t2
3// RUN: llvm-objdump -d %t2 | FileCheck %s
4// RUN: ld.lld -pie %t -o %t3
5// RUN: llvm-objdump -d %t3 | FileCheck --check-prefix=PIE %s
6// REQUIRES: x86
7
8.globl _start
9_start:
10  call __preinit_array_start
11  call __preinit_array_end
12  call __init_array_start
13  call __init_array_end
14  call __fini_array_start
15  call __fini_array_end
16
17// With no .init_array section the symbols resolve to 0
18// 0 - (0x201000 + 5) = -2101253
19// 0 - (0x201005 + 5) = -2101258
20// 0 - (0x20100a + 5) = -2101263
21// 0 - (0x20100f + 5) = -2101268
22// 0 - (0x201014 + 5) = -2101273
23// 0 - (0x201019 + 5) = -2101278
24
25// CHECK: Disassembly of section .text:
26// CHECK-NEXT:  _start:
27// CHECK-NEXT:   201000:    e8 fb ef df ff     callq    -2101253
28// CHECK-NEXT:   201005:    e8 f6 ef df ff     callq    -2101258
29// CHECK-NEXT:   20100a:    e8 f1 ef df ff     callq    -2101263
30// CHECK-NEXT:   20100f:    e8 ec ef df ff     callq    -2101268
31// CHECK-NEXT:   201014:    e8 e7 ef df ff     callq    -2101273
32// CHECK-NEXT:   201019:    e8 e2 ef df ff     callq    -2101278
33
34// In position-independent binaries, they resolve to the image base.
35
36// PIE:      Disassembly of section .text:
37// PIE-NEXT: _start:
38// PIE-NEXT:     1000:	e8 fb ef ff ff 	callq	-4101
39// PIE-NEXT:     1005:	e8 f6 ef ff ff 	callq	-4106
40// PIE-NEXT:     100a:	e8 f1 ef ff ff 	callq	-4111
41// PIE-NEXT:     100f:	e8 ec ef ff ff 	callq	-4116
42// PIE-NEXT:     1014:	e8 e7 ef ff ff 	callq	-4121
43// PIE-NEXT:     1019:	e8 e2 ef ff ff 	callq	-4126
44