File tree 1 file changed +8
-7
lines changed
1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,8 @@ const (
66
66
IMAGE_SCN_MEM_WRITE = 0x80000000
67
67
IMAGE_SCN_MEM_DISCARDABLE = 0x2000000
68
68
IMAGE_SCN_LNK_NRELOC_OVFL = 0x1000000
69
+ IMAGE_SCN_ALIGN_4BYTES = 0x300000
70
+ IMAGE_SCN_ALIGN_8BYTES = 0x400000
69
71
IMAGE_SCN_ALIGN_32BYTES = 0x600000
70
72
)
71
73
@@ -478,20 +480,19 @@ func (f *peFile) addInitArray(ctxt *Link) *peSection {
478
480
// However, the entire Go runtime is initialized from just one function, so it is unlikely
479
481
// that this will need to grow in the future.
480
482
var size int
483
+ var alignment uint32
481
484
switch objabi .GOARCH {
482
485
default :
483
486
Exitf ("peFile.addInitArray: unsupported GOARCH=%q\n " , objabi .GOARCH )
484
- case "386" :
485
- size = 4
486
- case "amd64" :
487
- size = 8
488
- case "arm" :
487
+ case "386" , "arm" :
489
488
size = 4
490
- case "arm64" :
489
+ alignment = IMAGE_SCN_ALIGN_4BYTES
490
+ case "amd64" , "arm64" :
491
491
size = 8
492
+ alignment = IMAGE_SCN_ALIGN_8BYTES
492
493
}
493
494
sect := f .addSection (".ctors" , size , size )
494
- sect .characteristics = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
495
+ sect .characteristics = IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE | alignment
495
496
sect .sizeOfRawData = uint32 (size )
496
497
ctxt .Out .SeekSet (int64 (sect .pointerToRawData ))
497
498
sect .checkOffset (ctxt .Out .Offset ())
You can’t perform that action at this time.
0 commit comments