Added memory address patching
This commit is contained in:
@ -43,8 +43,16 @@ func (build *Build) Run() error {
|
||||
|
||||
a.MoveRegisterNumber(register.Syscall0, syscall.Write)
|
||||
a.MoveRegisterNumber(register.Syscall1, 1)
|
||||
a.MoveRegisterNumber(register.Syscall2, 0x4000a2)
|
||||
a.MoveRegisterNumber(register.Syscall3, 6)
|
||||
hello := []byte("Hello\n")
|
||||
a.MoveRegisterData(register.Syscall2, hello)
|
||||
a.MoveRegisterNumber(register.Syscall3, uint64(len(hello)))
|
||||
a.Syscall()
|
||||
|
||||
a.MoveRegisterNumber(register.Syscall0, syscall.Write)
|
||||
a.MoveRegisterNumber(register.Syscall1, 1)
|
||||
world := []byte("World\n")
|
||||
a.MoveRegisterData(register.Syscall2, world)
|
||||
a.MoveRegisterNumber(register.Syscall3, uint64(len(world)))
|
||||
a.Syscall()
|
||||
|
||||
a.MoveRegisterNumber(register.Syscall0, syscall.Exit)
|
||||
@ -52,13 +60,12 @@ func (build *Build) Run() error {
|
||||
a.Syscall()
|
||||
|
||||
result := a.Finalize()
|
||||
result.Data.WriteString("Hello\n")
|
||||
|
||||
if !build.WriteExecutable {
|
||||
return nil
|
||||
}
|
||||
|
||||
return writeToDisk(build.Executable(), result.Code.Bytes(), result.Data.Bytes())
|
||||
return writeToDisk(build.Executable(), result.Code, result.Data)
|
||||
}
|
||||
|
||||
// Compile compiles all the functions.
|
||||
|
Reference in New Issue
Block a user