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
362a0e0c
Commit
362a0e0c
authored
Sep 24, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
softfloat and other block
parent
f8f93972
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
16 deletions
+38
-16
test_embedded.yml
.github/workflows/test_embedded.yml
+3
-1
build.sh
risc/build.sh
+5
-2
run.py
risc/run.py
+30
-13
No files found.
.github/workflows/test_embedded.yml
View file @
362a0e0c
...
...
@@ -16,7 +16,9 @@ jobs:
-
name
:
Install Python deps
run
:
pip3 install -r risc/requirements.txt
-
name
:
Build minigeth and run default block (cache)
run
:
./run.sh
run
:
|
./run.sh
minigeth/go-ethereum 13284491
-
name
:
Test in the embedded world
run
:
|
cd risc
...
...
risc/build.sh
View file @
362a0e0c
#!/bin/bash
#!/bin/bash
-e
cd
../minigeth
GOOS
=
linux
GOARCH
=
mips go build
export
GOOS
=
linux
export
GOARCH
=
mips
export
GOMIPS
=
softfloat
go build
cp
go-ethereum ../risc/go-ethereum
cd
../risc
file go-ethereum
...
...
risc/run.py
View file @
362a0e0c
#!/usr/bin/env python3
import
os
import
sys
import
math
import
struct
import
traceback
from
elftools.elf.elffile
import
ELFFile
...
...
@@ -15,6 +16,9 @@ from rangetree import RangeTree
mu
=
Uc
(
UC_ARCH_MIPS
,
UC_MODE_32
+
UC_MODE_BIG_ENDIAN
)
# memory trie
# register trie
mregs
=
[
UC_MIPS_REG_AT
,
UC_MIPS_REG_V0
,
UC_MIPS_REG_V1
,
UC_MIPS_REG_A0
,
UC_MIPS_REG_A1
,
UC_MIPS_REG_A2
,
UC_MIPS_REG_A3
]
regs
=
[
"at"
,
"v0"
,
"v1"
,
"a0"
,
"a1"
,
"a2"
,
"a3"
]
...
...
@@ -27,14 +31,20 @@ brk_start = 0x40000000 # 0x40000000-0x80000000
icount
=
0
bcount
=
0
instrumenting
=
False
instrumenting_all
=
False
def
hook_code_simple
(
uc
,
address
,
size
,
user_data
):
global
icount
,
bcount
#assert size == 4
try
:
if
bcount
%
100000
==
0
:
dat
=
next
(
md
.
disasm
(
uc
.
mem_read
(
address
,
size
),
address
))
print
(
"
%10
d:
%
s
%
s"
%
(
icount
,
r
[
address
],
dat
))
icount
+=
size
//
4
newicount
=
size
//
4
if
bcount
%
10000
==
0
or
instrumenting_all
:
if
size
>
0
:
dat
=
next
(
md
.
disasm
(
uc
.
mem_read
(
address
,
size
),
address
))
else
:
dat
=
"EMPTY BASIC BLOCK?!?"
print
(
"
%10
d(
%2
d):
%8
x
%-80
s
%
s"
%
(
icount
,
newicount
,
address
,
r
[
address
],
dat
))
icount
+=
newicount
bcount
+=
1
return
True
except
Exception
as
e
:
...
...
@@ -42,14 +52,17 @@ def hook_code_simple(uc, address, size, user_data):
except
:
raise
Exception
started
=
False
def
start_instrumenting
():
global
started
if
not
started
:
#mu.hook_add(UC_HOOK_CODE, hook_code_simple, user_data=mu)
if
os
.
getenv
(
"TRACE"
)
!=
"0"
:
global
instrumenting
,
instrumenting_all
if
not
instrumenting
:
tracelevel
=
int
(
os
.
getenv
(
"TRACE"
,
0
))
if
tracelevel
>=
2
:
mu
.
hook_add
(
UC_HOOK_CODE
,
hook_code_simple
,
user_data
=
mu
)
elif
tracelevel
==
1
:
mu
.
hook_add
(
UC_HOOK_BLOCK
,
hook_code_simple
,
user_data
=
mu
)
started
=
True
if
tracelevel
>=
3
:
instrumenting_all
=
True
instrumenting
=
True
tfd
=
10
files
=
{}
...
...
@@ -171,7 +184,10 @@ def hook_interrupt(uc, intno, user_data):
uc
.
reg_write
(
UC_MIPS_REG_V0
,
len
(
ret
))
elif
syscall_no
==
4246
:
a0
=
uc
.
reg_read
(
UC_MIPS_REG_A0
)
print
(
"exit(
%
d) ran
%.2
f million instructions"
%
(
a0
,
icount
/
1_000_000
))
if
icount
>
0
:
print
(
"exit(
%
d) ran
%.2
f million instructions,
%
d binary searches"
%
(
a0
,
icount
/
1_000_000
,
math
.
ceil
(
math
.
log2
(
icount
))))
else
:
print
(
"exit(
%
d)"
%
a0
)
sys
.
stdout
.
flush
()
sys
.
stderr
.
flush
()
os
.
_exit
(
a0
)
...
...
@@ -270,8 +286,9 @@ mu.mem_write(SIZE-0x2000, struct.pack(">IIIIIIIII",
_AT_PAGESZ
,
0x1000
,
0
))
# auxv
# block
#mu.mem_write(SIZE-0x800, b"13284491\x00")
mu
.
mem_write
(
SIZE
-
0x800
,
b
"13284469
\x00
"
)
mu
.
mem_write
(
SIZE
-
0x800
,
b
"13284491
\x00
"
)
#mu.mem_write(SIZE-0x800, b"13284469\x00")
mu
.
mem_write
(
SIZE
-
0x400
,
b
"GOGC=off
\x00
"
)
#hexdump(mu.mem_read(SIZE-0x2000, 0x100))
...
...
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