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
efd22ad0
Commit
efd22ad0
authored
Oct 05, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
profiling
parent
24f6ce5f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
build.sh
risc/build.sh
+4
-4
run.py
risc/run.py
+14
-3
No files found.
risc/build.sh
View file @
efd22ad0
...
...
@@ -7,11 +7,11 @@ export GOMIPS=softfloat
# brew install llvm
# ...and struggle to build musl
# for 0 gain
export
CGO_ENABLED
=
1
export
CC
=
"
$PWD
/../risc/clangwrap.sh"
go build
-v
-ldflags
"-linkmode external -extldflags -static"
#
export CGO_ENABLED=1
#
export CC="$PWD/../risc/clangwrap.sh"
#
go build -v -ldflags "-linkmode external -extldflags -static"
#
go build
go build
cp
go-ethereum ../risc/go-ethereum
cd
../risc
file go-ethereum
...
...
risc/run.py
View file @
efd22ad0
...
...
@@ -5,6 +5,7 @@ import math
import
struct
import
binascii
import
traceback
from
collections
import
defaultdict
from
elftools.elf.elffile
import
ELFFile
from
capstone
import
*
md
=
Cs
(
CS_ARCH_MIPS
,
CS_MODE_32
+
CS_MODE_BIG_ENDIAN
)
...
...
@@ -40,8 +41,10 @@ bcount = 0
instrumenting
=
False
instrumenting_all
=
False
instructions_seen
=
set
()
profiler
=
defaultdict
(
int
)
phit
=
0
def
hook_code_simple
(
uc
,
address
,
size
,
user_data
):
global
icount
,
bcount
global
icount
,
bcount
,
phit
#assert size == 4
try
:
newicount
=
size
//
4
...
...
@@ -52,7 +55,13 @@ def hook_code_simple(uc, address, size, user_data):
dat
=
"EMPTY BASIC BLOCK?!?"
#instructions_seen.add(dat.mnemonic)
#print(sorted(list(instructions_seen)))
print
(
"
%10
d(
%2
d):
%8
x
%-80
s
%
s"
%
(
icount
,
newicount
,
address
,
r
[
address
]
if
address
in
r
else
"UNKNOWN"
,
dat
))
symbol
=
r
[
address
]
if
address
in
r
else
"UNKNOWN"
profiler
[
symbol
]
+=
1
phit
+=
1
print
(
"
%10
d(
%2
d):
%8
x
%-80
s
%
s"
%
(
icount
,
newicount
,
address
,
symbol
,
dat
))
if
bcount
%
1000000
==
0
:
for
k
,
v
in
sorted
(
profiler
.
items
(),
key
=
lambda
x
:
-
x
[
1
])[:
10
]:
print
(
"
%-80
s :
%.2
f
%%
"
%
(
k
,
(
v
/
phit
)
*
100.
))
icount
+=
newicount
bcount
+=
1
return
True
...
...
@@ -345,6 +354,7 @@ for section in elffile.iter_sections():
# nop gcenable
mu
.
mem_write
(
symbol
[
'st_value'
],
b
"
\x03\xe0\x00\x08\x00\x00\x00\x00
"
)
found
+=
1
"""
if symbol.name == "runtime.load_g":
# hardware?
mu.mem_write(symbol['st_value'], b"
\x03\xe0\x00\x08\x00\x00\x00\x00
")
...
...
@@ -355,6 +365,7 @@ for section in elffile.iter_sections():
found += 1
if symbol.name == "_cgo_sys_thread_start":
mu.mem_write(symbol['st_value'], b"
\x03\xe0\x00\x08\x00\x00\x00\x00
")
"""
if
symbol
.
name
==
"github.com/ethereum/go-ethereum/oracle.Halt"
:
#00400000: 2004dead ; <input:0> li $a0, 57005
# 00400004: 00042400 ; <input:1> sll $a0, $a0, 16
...
...
@@ -365,7 +376,7 @@ for section in elffile.iter_sections():
#traceback.print_exc()
pass
assert
(
found
==
4
)
assert
(
found
==
2
)
#mu.hook_add(UC_HOOK_BLOCK, hook_code, user_data=mu)
died_well
=
False
...
...
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