Added memory address patching
This commit is contained in:
parent
6f097c9eee
commit
23e8b67e88
9 changed files with 98 additions and 35 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue