Improved section offset calculation
This commit is contained in:
@ -9,6 +9,11 @@ import (
|
||||
"git.akyoto.dev/cli/q/src/fs"
|
||||
)
|
||||
|
||||
const (
|
||||
SizeCommands = Segment64Size*3 + ThreadSize
|
||||
HeaderEnd = HeaderSize + SizeCommands
|
||||
)
|
||||
|
||||
// MachO is the executable format used on MacOS.
|
||||
type MachO struct {
|
||||
Header
|
||||
@ -20,11 +25,6 @@ type MachO struct {
|
||||
|
||||
// Write writes the Mach-O format to the given writer.
|
||||
func Write(writer io.Writer, code []byte, data []byte) {
|
||||
const (
|
||||
SizeCommands = Segment64Size*3 + ThreadSize
|
||||
HeaderEnd = HeaderSize + SizeCommands
|
||||
)
|
||||
|
||||
var (
|
||||
codeStart, codePadding = fs.Align(HeaderEnd, config.Align)
|
||||
dataStart, dataPadding = fs.Align(codeStart+len(code), config.Align)
|
||||
@ -102,7 +102,7 @@ func Write(writer io.Writer, code []byte, data []byte) {
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
config.BaseAddress + config.CodeOffset, 0,
|
||||
uint32(config.BaseAddress + codeStart), 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0,
|
||||
|
Reference in New Issue
Block a user