2 # RUN: rm -rf %t && split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/shared.s -o %t/b.o
5 # RUN: ld.lld -shared -soname=b %t/b.o -o %t/b.so
7 ## With relro or without DATA_SEGMENT_RELRO_END just aligns to
10 # RUN: ld.lld --hash-style=sysv -z max-page-size=65536 -z norelro %t/a.o %t/b.so -T %t/1.t -o %t/a1
11 # RUN: llvm-readelf -S -l %t/a1 | FileCheck %s --check-prefixes=CHECK,CHECK1
13 # RUN: ld.lld --hash-style=sysv -z max-page-size=65536 -z relro --orphan-handling=warn \
14 # RUN: %t/a.o %t/b.so -T %t/1.t -o %t/a2 2>&1 | FileCheck %s --check-prefix=WARN
15 # RUN: llvm-readelf -S -l %t/a2 | FileCheck %s --check-prefixes=CHECK,CHECK2
17 # WARN: warning: <internal>:(.dynsym) is being placed in '.dynsym'
18 # WARN-NOT: (.relro_padding)
20 # CHECK: Name Type Address Off Size ES Flg
21 # CHECK-NEXT: NULL {{.*}}
22 # CHECK: .orphan.ro PROGBITS {{.*}} A
23 # CHECK: .dynamic DYNAMIC {{.*}} WA
24 # CHECK-NEXT: __libc_atexit PROGBITS {{.*}} WA
25 # CHECK-NEXT: .got PROGBITS {{.*}} WA
26 # CHECK2-NEXT:.relro_padding NOBITS 0000000000010100 010100 000f00 00 WA
27 # CHECK-NEXT: .got.plt PROGBITS {{.*}} WA
28 # CHECK: .orphan.rw PROGBITS {{.*}} WA
30 # CHECK1: Program Headers:
31 # CHECK1-NOT: GNU_RELRO
33 # CHECK2: Program Headers:
34 # CHECK2-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
35 # CHECK2-NEXT: PHDR 0x000040
36 # CHECK2-NEXT: LOAD 0x000000
37 # CHECK2-NEXT: LOAD 0x0002b0
38 # CHECK2-NEXT: LOAD 0x010000 0x0000000000010000 0x0000000000010000 0x000100 0x001000 RW 0x10000
39 # CHECK2-NEXT: LOAD 0x020000 0x0000000000020000 0x0000000000020000 0x000034 0x000034 RW 0x10000
40 # CHECK2-NEXT: DYNAMIC 0x010000 0x0000000000010000 0x0000000000010000 0x0000f0 0x0000f0 RW 0x8
41 # CHECK2-NEXT: GNU_RELRO 0x010000 0x0000000000010000 0x0000000000010000 0x000100 0x001000 R 0x1
42 # CHECK2-NEXT: GNU_STACK 0x000000
44 # CHECK2: Section to Segment mapping:
45 # CHECK2: 06 .dynamic __libc_atexit .got .relro_padding {{$}}
47 # RUN: sed '/DATA_SEGMENT_RELRO_END/d' %t/1.t > %t/2.t
48 # RUN: not ld.lld %t/a.o %t/b.so -T %t/2.t -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR
50 # ERR: error: section: .got is not contiguous with other relro sections
56 jmp *bar2@GOTPCREL(%rip)
63 .section .bss,"",@nobits
65 .section __libc_atexit,"aw",@progbits
68 .section .orphan.ro,"a",@progbits
71 .section .orphan.rw,"aw",@progbits
81 . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
83 .dynamic : { *(.dynamic) }
84 ## The custom section __libc_atexit is made relro.
85 __libc_atexit : { *(__libc_atexit) }
88 . = DATA_SEGMENT_RELRO_END (1 ? 24 : 0, .);
90 .got.plt : { *(.got.plt) }
94 . = DATA_SEGMENT_END (.);
96 .comment 0 : { *(.comment) }