1// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
3// RUN: ld.lld %t.o -o %t
4// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
5// RUN: ld.lld -pie %t.o -o %t2
6// RUN: llvm-objdump -d --no-show-raw-insn %t2 | FileCheck --check-prefix=PIE %s
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 .text.
18// 0x201120 - (0x201120 + 5) = -5
19// 0x201120 - (0x201125 + 5) = -10
20// ...
21
22// CHECK: Disassembly of section .text:
23// CHECK-EMPTY:
24// CHECK-NEXT:  <_start>:
25// CHECK-NEXT:   201120:       callq    0x201120
26// CHECK-NEXT:                 callq    0x201120
27// CHECK-NEXT:                 callq    0x201120
28// CHECK-NEXT:                 callq    0x201120
29// CHECK-NEXT:                 callq    0x201120
30// CHECK-NEXT:                 callq    0x201120
31
32// In position-independent binaries, they resolve to .text too.
33
34// PIE:      Disassembly of section .text:
35// PIE-EMPTY:
36// PIE-NEXT: <_start>:
37// PIE-NEXT:     1210:       callq   0x1210
38// PIE-NEXT:                 callq   0x1210
39// PIE-NEXT:                 callq   0x1210
40// PIE-NEXT:                 callq   0x1210
41// PIE-NEXT:                 callq   0x1210
42// PIE-NEXT:                 callq   0x1210
43