1# REQUIRES: x86
2
3## Test that DT_INIT_ARRAYSZ/DT_FINI_ARRAYSZ/DT_PREINIT_ARRAYSZ are computed
4## correctly, no matter their associated sections are orphans or not.
5
6# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
7# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o
8# RUN: ld.lld -shared %t2.o -soname=so -o %t2.so
9
10# RUN: echo "SECTIONS { .init_array : { *(.init_array) } }" > %t.script
11# RUN: ld.lld -T %t.script %t1.o %t2.so -o %t
12# RUN: llvm-readobj --dynamic-table %t | FileCheck %s
13
14# CHECK:      DynamicSection [
15# CHECK-NEXT:  Tag                 Type             Name/Value
16# CHECK:       0x0000000000000021  PREINIT_ARRAYSZ  9 (bytes)
17# CHECK:       0x000000000000001B  INIT_ARRAYSZ     8 (bytes)
18# CHECK:       0x000000000000001C  FINI_ARRAYSZ     10 (bytes)
19
20.globl _start
21_start:
22
23.section .init_array,"aw",@init_array
24  .quad 0
25
26.section .preinit_array,"aw",@preinit_array
27  .quad 0
28  .byte 0
29
30.section .fini_array,"aw",@fini_array
31  .quad 0
32  .short 0
33