Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
afa5f1fb
Commit
afa5f1fb
authored
Oct 06, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
the unicorn is coming to go
parent
26511197
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
10 deletions
+50
-10
go.mod
mipsevm/go.mod
+1
-0
go.sum
mipsevm/go.sum
+2
-0
main.go
mipsevm/main.go
+2
-0
minigeth_test.go
mipsevm/minigeth_test.go
+0
-10
unicorn.go
mipsevm/unicorn.go
+45
-0
No files found.
mipsevm/go.mod
View file @
afa5f1fb
...
...
@@ -8,6 +8,7 @@ require (
github.com/btcsuite/btcd v0.22.0-beta // indirect
github.com/ethereum/go-ethereum v1.10.8 // 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/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
)
mipsevm/go.sum
View file @
afa5f1fb
...
...
@@ -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/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/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-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
...
...
mipsevm/main.go
View file @
afa5f1fb
...
...
@@ -49,6 +49,8 @@ func main() {
steps
=
100000
}
RunMinigeth
(
os
.
Args
[
1
],
steps
,
debug
)
}
else
if
os
.
Args
[
1
]
==
"unicorn"
{
RunUnicorn
(
os
.
Args
[
2
])
}
else
{
runTest
(
os
.
Args
[
1
],
20
,
2
)
}
...
...
mipsevm/minigeth_test.go
deleted
100644 → 0
View file @
26511197
package
main
import
(
"testing"
)
func
TestProfileMinigeth
(
t
*
testing
.
T
)
{
interpreter
,
bytecode
:=
GetInterpreterAndBytecode
()
RunMinigeth
(
"../mipigeth/minigeth.bin"
,
interpreter
,
bytecode
,
400000
)
}
mipsevm/unicorn.go
0 → 100644
View file @
afa5f1fb
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
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment