Reduced size of Windows executables
All checks were successful
/ test (push) Successful in 15s

This commit is contained in:
Eduard Urbach 2025-07-09 15:57:29 +02:00
parent d98911cc8f
commit 64a80f6090
Signed by: ed
GPG key ID: 49226B848C78F6C8
2 changed files with 8 additions and 8 deletions

View file

@ -1,13 +1,13 @@
package build
// cacheLineSize is the smallest unit of data that can be transferred between the RAM and the CPU cache.
const cacheLineSize = 64
// FileAlign returns the file alignment.
func (build *Build) FileAlign() int {
if build.OS == Linux {
return cacheLineSize
}
switch build.OS {
case Linux:
return 0x40
case Windows:
return 0x200
default:
return build.MemoryAlign()
}
}

View file

@ -27,7 +27,7 @@ func Write(writer io.WriteSeeker, b *build.Build, codeBytes []byte, dataBytes []
subSystem := IMAGE_SUBSYSTEM_WINDOWS_CUI
arch := Arch(b.Arch)
importsData, dllData, dllImports, dllDataStart := importLibraries(libs, imports.FileOffset)
importsData, dllData, dllImports, dllDataStart := importLibraries(libs, imports.MemoryOffset)
buffer := bytes.Buffer{}
binary.Write(&buffer, binary.LittleEndian, &importsData)
binary.Write(&buffer, binary.LittleEndian, &dllData)