2 # RUN: split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o
5 ## --randomize-section-padding= inserts segment offset padding and pre-section
6 ## padding, and does not affect flags. Segment offset padding is only inserted
7 ## when PT_LOAD changes, as shown by .bss size (.data and .bss share a PT_LOAD).
9 # RUN: ld.lld --randomize-section-padding=6 %t/a.o -o %t/a.out
10 # RUN: llvm-readelf -sS -x .rodata -x .text -x .data %t/a.out | FileCheck --check-prefix=PAD6 %s
12 # PAD6: .rodata PROGBITS 0000000000200158 000158 000b8d 00 A 0 0 1
13 # PAD6-NEXT: .text PROGBITS 0000000000201ce8 000ce8 000270 00 AX 0 0 4
14 # PAD6-NEXT: .data PROGBITS 0000000000202f58 000f58 000941 00 WA 0 0 1
15 # PAD6-NEXT: .bss NOBITS 0000000000203899 001899 000003 00 WA 0 0 1
17 # PAD6: 0000000000203899 0 NOTYPE LOCAL DEFAULT 4 a
18 # PAD6: 000000000020389a 0 NOTYPE LOCAL DEFAULT 4 b
19 # PAD6: 000000000020389b 0 NOTYPE LOCAL DEFAULT 4 c
21 # PAD6: Hex dump of section '.rodata':
22 # PAD6: 0x00200cd8 00000000 00000000 00000102 03
23 # PAD6: Hex dump of section '.text':
24 # PAD6: 0x00201f48 cccccccc cccccccc cccccccc 0405cc06
25 # PAD6: Hex dump of section '.data':
26 # PAD6: 0x00203888 00000000 00000000 00000000 00000708
29 ## Size of segment offset padding and location of pre-section padding is
30 ## dependent on the seed.
32 # RUN: ld.lld --randomize-section-padding=46 %t/a.o -o %t/a.out
33 # RUN: llvm-readelf -sS -x .rodata -x .text -x .data %t/a.out | FileCheck --check-prefix=PAD46 %s
35 # PAD46: .rodata PROGBITS 0000000000200158 000158 000cc0 00 A 0 0 1
36 # PAD46-NEXT: .text PROGBITS 0000000000201e18 000e18 0009bf 00 AX 0 0 4
37 # PAD46-NEXT: .data PROGBITS 00000000002037d7 0017d7 000540 00 WA 0 0 1
38 # PAD46-NEXT: .bss NOBITS 0000000000203d17 001d17 000004 00 WA 0 0 1
40 # PAD46: 0000000000203d17 0 NOTYPE LOCAL DEFAULT 4 a
41 # PAD46: 0000000000203d18 0 NOTYPE LOCAL DEFAULT 4 b
42 # PAD46: 0000000000203d1a 0 NOTYPE LOCAL DEFAULT 4 c
44 # PAD46: Hex dump of section '.rodata':
45 # PAD46: 0x00200e08 00000000 00000000 00000000 00010203
46 # PAD46: Hex dump of section '.text':
47 # PAD46: 0x002027c8 cccccccc cccccccc cccccccc 040506
48 # PAD46: Hex dump of section '.data':
49 # PAD46: 0x00203d07 00000000 00000000 00000000 07000809
51 ## When there are multiple InputSectionDescriptions for an output section,
52 ## segment offset padding is inserted in the first InputSectionDescription.
54 # RUN: ld.lld --randomize-section-padding=46 %t/a.o %t/a.lds -o %t/a.out
56 # RUN: llvm-readelf -sS -x .rodata -x .text -x .data %t/a.out | FileCheck --check-prefix=PAD46-LDS %s
58 # PAD46-LDS: .rodata PROGBITS 0000000000000158 000158 000cc0 00 A 0 0 1
59 # PAD46-LDS-NEXT: .text PROGBITS 0000000000001000 001000 0009c0 00 AX 0 0 4
60 # PAD46-LDS-NEXT: .data PROGBITS 0000000000002000 002000 000540 00 WA 0 0 1
61 # PAD46-LDS-NEXT: .bss NOBITS 0000000000002540 002540 000004 00 WA 0 0 1
63 # PAD46-LDS: 0000000000002543 0 NOTYPE LOCAL DEFAULT 4 a
64 # PAD46-LDS: 0000000000002541 0 NOTYPE LOCAL DEFAULT 4 b
65 # PAD46-LDS: 0000000000002540 0 NOTYPE LOCAL DEFAULT 4 c
67 # PAD46-LDS: Hex dump of section '.rodata':
68 # PAD46-LDS: 0x00000e08 00000000 00000000 00000000 00030201 ................
69 # PAD46-LDS: Hex dump of section '.text':
70 # PAD46-LDS: 0x000019b0 cccccccc cccccccc cccc0605 04cccccc ................
71 # PAD46-LDS: Hex dump of section '.data':
72 # PAD46-LDS: 0x00002530 00000000 00000000 00000000 09000807 ................
76 .section .rodata.a,"a",@progbits
79 .section .rodata.b,"a",@progbits
82 .section .rodata.c,"a",@progbits
85 .section .text.a,"ax",@progbits
88 .section .text.b,"ax",@progbits
91 .section .text.c,"ax",@progbits
94 .section .data.a,"aw",@progbits
97 .section .data.b,"aw",@progbits
100 .section .data.c,"aw",@progbits
103 .section .bss.a,"a",@nobits
107 .section .bss.b,"a",@nobits
111 .section .bss.c,"a",@nobits
119 .rodata : { *(.rodata.c) *(.rodata.b) *(.rodata.a) }
120 . = ALIGN(CONSTANT(MAXPAGESIZE));
121 .text : { *(.text.c) *(.text.b) *(.text.a) }
122 . = ALIGN(CONSTANT(MAXPAGESIZE));
123 .data : { *(.data.c) *(.data.b) *(.data.a) }
124 .bss : { *(.bss.c) *(.bss.b) *(.bss.a) }