File: data-segment-relro-ppc64.test

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (79 lines) | stat: -rw-r--r-- 2,444 bytes parent folder | download | duplicates (16)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
# REQUIRES: ppc
# RUN: rm -rf %t && split-file %s %t
# RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/a.s -o %t/a.o
# RUN: llvm-mc -filetype=obj -triple=powerpc64le %p/Inputs/shared.s -o %t/b.o
# RUN: ld.lld -shared -soname=b %t/b.o -o %t/b.so

# RUN: ld.lld -z max-page-size=65536 -z norelro %t/a.o %t/b.so -T %t/1.t -o %t/a1
# RN: llvm-readelf -S -l %t/a1 | FileCheck %s --check-prefixes=CHECK1

# RUN: ld.lld -z max-page-size=65536 -z relro %t/a.o %t/b.so -T %t/1.t -o %t/a2
# RUN: llvm-readelf -S -l %t/a2 | FileCheck %s --check-prefixes=CHECK2

## -z norelro suppresses the .relro_padding section.
# CHECK1:      Name           Type     Address          Off      Size ES Flg
# CHECK1:      .foo           PROGBITS
# CHECK1-NEXT: .orphan.rw     PROGBITS
# CHECK1-NEXT: .branch_lt     PROGBITS
# CHECK1-NEXT: .got           PROGBITS
# CHECK1-NEXT: .data          PROGBITS
# CHECK1-NEXT: .bss           NOBITS

# CHECK2:      Name           Type     Address          Off      Size ES Flg
# CHECK2-NEXT:                NULL     {{.*}}
# CHECK2:      .orphan.ro     PROGBITS {{.*}}                              A
# CHECK2:      .dynamic       DYNAMIC  {{.*}}                             WA
# CHECK2-NEXT: .branch_lt     PROGBITS {{.*}}                             WA
# CHECK2-NEXT: .got           PROGBITS {{.*}}                             WA
# CHECK2-NEXT: .relro_padding NOBITS   00000000000100f0 0100f0 000f10 00  WA
# CHECK2-NEXT: .data          PROGBITS {{.*}}                             WA
# CHECK2-NEXT: .foo           PROGBITS {{.*}}                             WA
# CHECK2-NEXT: .orphan.rw     PROGBITS {{.*}}                             WA
# CHECK2-NEXT: .bss           NOBITS   {{.*}}                             WA

#--- a.s
.global _start
_start:
  addis 3, 2, bar2@toc@ha
  ld 12, bar2@toc@l(3)
  mtctr 12
  bctrl
  b bar
  nop

.section .data,"aw"
.quad 0

.zero 4
.section .foo,"aw"
.section .bss,"",@nobits

.section .orphan.ro,"a",@progbits
.dc.a 0

.section .orphan.rw,"aw",@progbits
.dc.a .orphan.rw

#--- 1.t
SECTIONS {
  . = SIZEOF_HEADERS;

  .plt  : { *(.plt) }
  .text : { *(.text) }

  . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));

  .dynamic : { *(.dynamic) }
  .branch_lt : { *(.branch_lt) }
  .got : { *(.got) }

  . = DATA_SEGMENT_RELRO_END (0, .);

  .plt : { *(.plt) }
  .data : { *(.data) }
  .bss : { *(.bss) }

  . = DATA_SEGMENT_END (.);

  .comment 0 : { *(.comment) }
}