Commit afa5f1fb authored by George Hotz's avatar George Hotz

the unicorn is coming to go

parent 26511197
...@@ -8,6 +8,7 @@ require ( ...@@ -8,6 +8,7 @@ require (
github.com/btcsuite/btcd v0.22.0-beta // indirect github.com/btcsuite/btcd v0.22.0-beta // indirect
github.com/ethereum/go-ethereum v1.10.8 // indirect github.com/ethereum/go-ethereum v1.10.8 // indirect
github.com/holiman/uint256 v1.2.0 // indirect github.com/holiman/uint256 v1.2.0 // indirect
github.com/unicorn-engine/unicorn v0.0.0-20211005173419-3fadb5aa5aad // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
) )
...@@ -29,6 +29,8 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W ...@@ -29,6 +29,8 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/unicorn-engine/unicorn v0.0.0-20211005173419-3fadb5aa5aad h1:NZZpAzeX5zgWVfB1bJvQCP6xJOClUujc5o7BbkA6els=
github.com/unicorn-engine/unicorn v0.0.0-20211005173419-3fadb5aa5aad/go.mod h1:vm0xtY46O4X0t1J6Ob+syPhvL38XAAidXGXmTSlcMZM=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
......
...@@ -49,6 +49,8 @@ func main() { ...@@ -49,6 +49,8 @@ func main() {
steps = 100000 steps = 100000
} }
RunMinigeth(os.Args[1], steps, debug) RunMinigeth(os.Args[1], steps, debug)
} else if os.Args[1] == "unicorn" {
RunUnicorn(os.Args[2])
} else { } else {
runTest(os.Args[1], 20, 2) runTest(os.Args[1], 20, 2)
} }
......
package main
import (
"testing"
)
func TestProfileMinigeth(t *testing.T) {
interpreter, bytecode := GetInterpreterAndBytecode()
RunMinigeth("../mipigeth/minigeth.bin", interpreter, bytecode, 400000)
}
package main
import (
"fmt"
"io/ioutil"
"log"
uc "github.com/unicorn-engine/unicorn/bindings/go/unicorn"
)
func check(err error) {
if err != nil {
log.Fatal(err)
}
}
var steps int = 0
func RunUnicorn(fn string) {
mu, err := uc.NewUnicorn(uc.ARCH_MIPS, uc.MODE_32|uc.MODE_BIG_ENDIAN)
check(err)
mu.HookAdd(uc.HOOK_INTR, func(mu uc.Unicorn, intno uint32) {
if intno != 17 {
log.Fatal("invalid interrupt ", intno)
}
syscall_no, _ := mu.RegRead(uc.MIPS_REG_V0)
fmt.Println("syscall", syscall_no)
}, 1, 0)
mu.HookAdd(uc.HOOK_CODE, func(mu uc.Unicorn, addr uint64, size uint32) {
if steps%10000 == 0 {
fmt.Printf("%6d Code: 0x%x, 0x%x\n", steps, addr, size)
}
steps += 1
}, 1, 0)
check(mu.MemMap(0, 0x80000000))
dat, _ := ioutil.ReadFile(fn)
mu.MemWrite(0, dat)
mu.Start(0, 0xdead0000)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment