|
1 | 1 | # REQUIRES: x86 |
2 | | -# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o |
| 2 | +# RUN: split-file %s %t |
| 3 | +# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o |
3 | 4 |
|
4 | 5 | ## --randomize-section-padding= inserts segment offset padding and pre-section |
5 | 6 | ## padding, and does not affect flags. Segment offset padding is only inserted |
6 | 7 | ## when PT_LOAD changes, as shown by .bss size (.data and .bss share a PT_LOAD). |
7 | 8 |
|
8 | | -# RUN: ld.lld --randomize-section-padding=6 %t.o -o %t.out |
9 | | -# RUN: llvm-readelf -sS -x .rodata -x .text -x .data %t.out | FileCheck --check-prefix=PAD6 %s |
| 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 |
10 | 11 |
|
11 | 12 | # PAD6: .rodata PROGBITS 0000000000200158 000158 000b8d 00 A 0 0 1 |
12 | 13 | # PAD6: .text PROGBITS 0000000000201ce8 000ce8 000270 00 AX 0 0 4 |
|
28 | 29 | ## Size of segment offset padding and location of pre-section padding is |
29 | 30 | ## dependent on the seed. |
30 | 31 |
|
31 | | -# RUN: ld.lld --randomize-section-padding=46 %t.o -o %t.out |
32 | | -# RUN: llvm-readelf -sS -x .rodata -x .text -x .data %t.out | FileCheck --check-prefix=PAD46 %s |
| 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 |
33 | 34 |
|
34 | 35 | # PAD46: .rodata PROGBITS 0000000000200158 000158 000cc0 00 A 0 0 1 |
35 | 36 | # PAD46: .text PROGBITS 0000000000201e18 000e18 0009bf 00 AX 0 0 4 |
|
47 | 48 | # PAD46: Hex dump of section '.data': |
48 | 49 | # PAD46: 0x00203d07 00000000 00000000 00000000 07000809 |
49 | 50 |
|
| 51 | +## When there are multiple InputSectionDescriptions for an output section, |
| 52 | +## segment offset padding is inserted in the first InputSectionDescription. |
| 53 | + |
| 54 | +# RUN: ld.lld --randomize-section-padding=46 %t/a.o %t/a.lds -o %t/a.out |
| 55 | + |
| 56 | +# RUN: llvm-readelf -sS -x .rodata -x .text -x .data %t/a.out | FileCheck --check-prefix=PAD46-LDS %s |
| 57 | + |
| 58 | +# PAD46-LDS: .rodata PROGBITS 0000000000000158 000158 000cc0 00 A 0 0 1 |
| 59 | +# PAD46-LDS: .text PROGBITS 0000000000001000 001000 0009c0 00 AX 0 0 4 |
| 60 | +# PAD46-LDS: .data PROGBITS 0000000000002000 002000 000540 00 WA 0 0 1 |
| 61 | +# PAD46-LDS: .bss NOBITS 0000000000002540 002540 000004 00 WA 0 0 1 |
| 62 | + |
| 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 |
| 66 | + |
| 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 ................ |
| 73 | + |
| 74 | +#--- a.s |
| 75 | + |
50 | 76 | .section .rodata.a,"a",@progbits |
51 | 77 | .byte 1 |
52 | 78 |
|
|
86 | 112 | c: |
87 | 113 | .zero 1 |
88 | 114 |
|
| 115 | +#--- a.lds |
| 116 | + |
| 117 | +SECTIONS { |
| 118 | + . = SIZEOF_HEADERS; |
| 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) } |
| 125 | +} |
0 commit comments