Skip to content

Commit cd48297

Browse files
committed
Address review comments
Created using spr 1.3.6-beta.1
1 parent a02fa37 commit cd48297

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

lld/ELF/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ defm section_start: Eq<"section-start", "Set address of section">,
435435
def shared: F<"shared">, HelpText<"Build a shared object">;
436436

437437
def randomize_section_padding: JJ<"randomize-section-padding=">,
438-
HelpText<"Randomly insert padding between input sections using given seed">;
438+
HelpText<"Randomly insert padding between input sections and at the start of each segment using given seed">;
439439

440440
defm soname: Eq<"soname", "Set DT_SONAME">;
441441

lld/ELF/Writer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,8 @@ static void finalizeSynthetic(Ctx &ctx, SyntheticSection *sec) {
14461446

14471447
static bool canInsertPadding(OutputSection *sec) {
14481448
StringRef s = sec->name;
1449-
return s == ".bss" || s == ".data" || s == ".data.rel.ro" || s == ".rodata" ||
1449+
return s == ".bss" || s == ".data" || s == ".data.rel.ro" || s == ".lbss" ||
1450+
s == ".ldata" || s == ".lrodata" || s == ".ltext" || s == ".rodata" ||
14501451
s.starts_with(".text");
14511452
}
14521453

lld/docs/ld.lld.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ and
530530
Restore the states saved by
531531
.Fl -push-state.
532532
.It Fl -randomize-section-padding Ns = Ns Ar seed
533-
Randomly insert padding between input sections using the given seed.
533+
Randomly insert padding between input sections and at the start of each segment using the given seed.
534534
Padding is inserted into output sections with names matching the following patterns:
535535
.Cm .bss ,
536536
.Cm .data ,

lld/test/ELF/randomize-section-padding.test

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
# RUN: ld.lld --randomize-section-padding=6 %t/a.o -o %t/a.out
1010
# RUN: llvm-readelf -sS -x .rodata -x .text -x .data %t/a.out | FileCheck --check-prefix=PAD6 %s
1111

12-
# PAD6: .rodata PROGBITS 0000000000200158 000158 000b8d 00 A 0 0 1
13-
# PAD6: .text PROGBITS 0000000000201ce8 000ce8 000270 00 AX 0 0 4
14-
# PAD6: .data PROGBITS 0000000000202f58 000f58 000941 00 WA 0 0 1
15-
# PAD6: .bss NOBITS 0000000000203899 001899 000003 00 WA 0 0 1
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
1616

1717
# PAD6: 0000000000203899 0 NOTYPE LOCAL DEFAULT 4 a
1818
# PAD6: 000000000020389a 0 NOTYPE LOCAL DEFAULT 4 b
@@ -32,10 +32,10 @@
3232
# RUN: ld.lld --randomize-section-padding=46 %t/a.o -o %t/a.out
3333
# RUN: llvm-readelf -sS -x .rodata -x .text -x .data %t/a.out | FileCheck --check-prefix=PAD46 %s
3434

35-
# PAD46: .rodata PROGBITS 0000000000200158 000158 000cc0 00 A 0 0 1
36-
# PAD46: .text PROGBITS 0000000000201e18 000e18 0009bf 00 AX 0 0 4
37-
# PAD46: .data PROGBITS 00000000002037d7 0017d7 000540 00 WA 0 0 1
38-
# PAD46: .bss NOBITS 0000000000203d17 001d17 000004 00 WA 0 0 1
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
3939

4040
# PAD46: 0000000000203d17 0 NOTYPE LOCAL DEFAULT 4 a
4141
# PAD46: 0000000000203d18 0 NOTYPE LOCAL DEFAULT 4 b
@@ -55,10 +55,10 @@
5555

5656
# RUN: llvm-readelf -sS -x .rodata -x .text -x .data %t/a.out | FileCheck --check-prefix=PAD46-LDS %s
5757

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
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
6262

6363
# PAD46-LDS: 0000000000002543 0 NOTYPE LOCAL DEFAULT 4 a
6464
# PAD46-LDS: 0000000000002541 0 NOTYPE LOCAL DEFAULT 4 b

0 commit comments

Comments
 (0)