Skip to content

Commit 821e124

Browse files
committed
cmd/link/internal/ld: align PE .text section to 32-byte when external linking
Some symbols, for example, masks requires 16-byte alignment, and they are placed in the text section. Before this change, the text section is only aligned to 4-byte, and it's making masks unaligned. Fixes #12415. Change-Id: I7767778d1b4f7d3e74c2719a02848350782a4160 Reviewed-on: https://go-review.googlesource.com/14166 Run-TryBot: Minux Ma <[email protected]> Reviewed-by: Alex Brainman <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 2c2cbb6 commit 821e124

File tree

1 file changed

+5
-0
lines changed
  • src/cmd/link/internal/ld

1 file changed

+5
-0
lines changed

src/cmd/link/internal/ld/pe.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,11 @@ func Asmbpe() {
11071107

11081108
t := addpesection(".text", int(Segtext.Length), int(Segtext.Length))
11091109
t.Characteristics = IMAGE_SCN_CNT_CODE | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ
1110+
if Linkmode == LinkExternal {
1111+
// some data symbols (e.g. masks) end up in the .text section, and they normally
1112+
// expect larger alignment requirement than the default text section alignment.
1113+
t.Characteristics |= IMAGE_SCN_ALIGN_32BYTES
1114+
}
11101115
chksectseg(t, &Segtext)
11111116
textsect = pensect
11121117

0 commit comments

Comments
 (0)