data-segment-relro.test
1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/data-segment-relro.s -o %t1.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o
# RUN: ld.lld -shared %t2.o -o %t2.so
## With relro or without DATA_SEGMENT_RELRO_END just aligns to
## page boundary.
# RUN: ld.lld --hash-style=sysv -z norelro %t1.o %t2.so --script %s -o %t
# RUN: llvm-readobj -S %t | FileCheck %s
# RUN: ld.lld --hash-style=sysv -z relro %t1.o %t2.so --script %s -o %t2
# RUN: llvm-readobj -S %t2 | FileCheck %s
SECTIONS {
. = SIZEOF_HEADERS;
.plt : { *(.plt) }
.text : { *(.text) }
. = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
.dynamic : { *(.dynamic) }
.got : { *(.got) }
. = DATA_SEGMENT_RELRO_END (1 ? 24 : 0, .);
.got.plt : { *(.got.plt) }
.data : { *(.data) }
.bss : { *(.bss) }
. = DATA_SEGMENT_END (.);
}
# CHECK: Section {
# CHECK: Index:
# CHECK: Name: .got
# CHECK-NEXT: Type: SHT_PROGBITS
# CHECK-NEXT: Flags [
# CHECK-NEXT: SHF_ALLOC
# CHECK-NEXT: SHF_WRITE
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x10F0
# CHECK-NEXT: Offset: 0x10F0
# CHECK-NEXT: Size:
# CHECK-NEXT: Link:
# CHECK-NEXT: Info:
# CHECK-NEXT: AddressAlignment:
# CHECK-NEXT: EntrySize:
# CHECK-NEXT: }
# CHECK-NEXT: Section {
# CHECK-NEXT: Index:
# CHECK-NEXT: Name: .got.plt
# CHECK-NEXT: Type: SHT_PROGBITS
# CHECK-NEXT: Flags [
# CHECK-NEXT: SHF_ALLOC
# CHECK-NEXT: SHF_WRITE
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x2000
# CHECK-NEXT: Offset: 0x2000
# CHECK-NEXT: Size:
# CHECK-NEXT: Link:
# CHECK-NEXT: Info:
# CHECK-NEXT: AddressAlignment:
# CHECK-NEXT: EntrySize:
# CHECK-NEXT: }