Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / relro-init-fini-script.s
blobab7c928d49b9337af28796a75586f607159bfa10
1 // REQUIRES: x86
2 // RUN: llvm-mc -filetype=obj -triple=x86_64-none-elf %s -o %t.o
3 // RUN: echo "SECTIONS { \
4 // RUN: .dynamic 0x10000 : { *(.dynamic) } \
5 // RUN: .preinit_array : { PROVIDE_HIDDEN (__preinit_array_start = .); \
6 // RUN: KEEP (*(.preinit_array)) } \
7 // RUN: .init_array : { PROVIDE_HIDDEN (__init_array_start = .); \
8 // RUN: KEEP (*(.init_array)) } \
9 // RUN: .fini_array : { PROVIDE_HIDDEN (__fini_array_start = .); \
10 // RUN: KEEP (*(.fini_array)) } \
11 // RUN: .data.rel.ro : { *(.data.rel.ro) } \
12 // RUN: .data : { *(.data) } } " > %t.script
13 // RUN: ld.lld %t.o -o %t.so --shared --script=%t.script
14 // RUN: llvm-readelf -S %t.so | FileCheck %s
15 // RUN: llvm-readobj --segments %t.so | FileCheck %s --check-prefix=PHDR
17 /// Check that an empty .init_array, .fini_array or .preinit_array that is
18 /// kept due to symbol references, is still counted as RELRO. The _array
19 /// sections are zero size. The RELRO extent is [.dynamic, .data.rel.ro)
21 // CHECK: .dynamic DYNAMIC 0000000000010000 002000 000110
22 // CHECK-NEXT: .preinit_array PROGBITS {{0+}}[[# %x,ADDR:]]
23 // CHECK-NEXT: .init_array PROGBITS {{0+}}[[# ADDR]]
24 // CHECK-NEXT: .fini_array PROGBITS {{0+}}[[# ADDR]]
25 // CHECK-NEXT: .data.rel.ro PROGBITS 0000000000010110 002110 000008
27 // PHDR: Type: PT_GNU_RELRO
28 // PHDR-NEXT: Offset: 0x2000
29 // PHDR-NEXT: VirtualAddress: 0x10000
30 // PHDR-NEXT: PhysicalAddress: 0x10000
31 // PHDR-NEXT: FileSize: 280
32 .section .data.rel.ro, "aw", %progbits
33 .global foo
34 .quad foo
36 .data
37 .quad __init_array_start
38 .quad __fini_array_start
39 .quad __preinit_array_start