|
1 From d4f13093729cac869fbec326222f7fd68e989998 Mon Sep 17 00:00:00 2001 |
|
2 From: Shenghou Ma <[email protected]> |
|
3 Date: Tue, 1 Sep 2015 19:58:31 -0400 |
|
4 Subject: [PATCH 05/63] cmd/link/internal/ld: align PE .text section to 32-byte |
|
5 when external linking |
|
6 |
|
7 Some symbols, for example, masks requires 16-byte alignment, and |
|
8 they are placed in the text section. Before this change, the text |
|
9 section is only aligned to 4-byte, and it's making masks unaligned. |
|
10 |
|
11 Fixes #12415. |
|
12 |
|
13 Change-Id: I7767778d1b4f7d3e74c2719a02848350782a4160 |
|
14 Reviewed-on: https://go-review.googlesource.com/14166 |
|
15 Run-TryBot: Minux Ma <[email protected]> |
|
16 Reviewed-by: Alex Brainman <[email protected]> |
|
17 TryBot-Result: Gobot Gobot <[email protected]> |
|
18 Reviewed-by: Ian Lance Taylor <[email protected]> |
|
19 (cherry picked from commit 821e124c24c2b2d753be22a04a3b20b7bf579627) |
|
20 Reviewed-on: https://go-review.googlesource.com/14279 |
|
21 --- |
|
22 src/cmd/link/internal/ld/pe.go | 5 +++++ |
|
23 1 file changed, 5 insertions(+) |
|
24 |
|
25 diff --git a/src/cmd/link/internal/ld/pe.go b/src/cmd/link/internal/ld/pe.go |
|
26 index d5f7e62..4a7d710 100644 |
|
27 --- a/src/cmd/link/internal/ld/pe.go |
|
28 +++ b/src/cmd/link/internal/ld/pe.go |
|
29 @@ -1107,6 +1107,11 @@ func Asmbpe() { |
|
30 |
|
31 t := addpesection(".text", int(Segtext.Length), int(Segtext.Length)) |
|
32 t.Characteristics = IMAGE_SCN_CNT_CODE | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ |
|
33 + if Linkmode == LinkExternal { |
|
34 + // some data symbols (e.g. masks) end up in the .text section, and they normally |
|
35 + // expect larger alignment requirement than the default text section alignment. |
|
36 + t.Characteristics |= IMAGE_SCN_ALIGN_32BYTES |
|
37 + } |
|
38 chksectseg(t, &Segtext) |
|
39 textsect = pensect |
|
40 |
|
41 -- |
|
42 2.6.1 |
|
43 |