2 # RUN: split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/t.s -o %t.o
5 ## PR52534: https://bugs.llvm.org/show_bug.cgi?id=52534
6 ## Check case where .preinit_array is discarded.
7 ## Link should succeed without causing an out of range relocation error.
8 # RUN: ld.lld -T %t/discarded.script %t.o -o %t1 --image-base=0x80000000
9 # RUN: llvm-readelf -s %t1 | FileCheck --check-prefixes=CHECK,DISCARDED %s
11 ## Check case where .preinit_array is emitted but empty.
12 # RUN: ld.lld -T %t/empty.script %t.o -o %t2
13 # RUN: llvm-readelf -s %t2 | FileCheck --check-prefixes=CHECK,EMPTY %s
15 # CHECK: [[#%x,ADDR:]] 0 NOTYPE LOCAL HIDDEN [[#]] __preinit_array_start
16 # CHECK-NEXT: [[#ADDR]] 0 NOTYPE LOCAL HIDDEN [[#]] __preinit_array_end
18 # DISCARDED-NEXT: [[#ADDR]] 0 NOTYPE GLOBAL DEFAULT [[#]] _start
20 # EMPTY-NOT: [[#ADDR]] 0 NOTYPE GLOBAL DEFAULT [[#]] _start
21 # EMPTY: [[#ADDR]] 0 NOTYPE GLOBAL DEFAULT [[#]] ADDR
26 movq __preinit_array_start@GOTPCREL(%rip),%rax
27 movq __preinit_array_end@GOTPCREL(%rip),%rax
32 .preinit_array : { *(.preinit_array); }
38 .preinit_array : { ADDR = .; *(.preinit_array); }