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
ac764451
Unverified
Commit
ac764451
authored
Apr 18, 2023
by
protolambda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mipsevm: fix initial heap, set initial PC to entrypoint
parent
3d1052d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
patch.go
mipsevm/patch.go
+11
-1
unicorn.go
mipsevm/unicorn.go
+2
-2
No files found.
mipsevm/patch.go
View file @
ac764451
...
...
@@ -9,7 +9,17 @@ import (
)
func
LoadELF
(
f
*
elf
.
File
)
(
*
State
,
error
)
{
s
:=
&
State
{}
s
:=
&
State
{
PC
:
uint32
(
f
.
Entry
),
Hi
:
0
,
Lo
:
0
,
Heap
:
1
<<
20
,
// start heap at 1 GiB offset for now
Registers
:
[
32
]
uint32
{},
Memory
:
nil
,
Exit
:
0
,
Exited
:
false
,
Step
:
0
,
}
for
i
,
prog
:=
range
f
.
Progs
{
if
prog
.
Type
==
0x70000003
{
// MIPS_ABIFLAGS
...
...
mipsevm/unicorn.go
View file @
ac764451
...
...
@@ -42,7 +42,7 @@ func LoadUnicorn(st *State, mu uc.Unicorn) error {
func
HookUnicorn
(
st
*
State
,
mu
uc
.
Unicorn
,
stdOut
,
stdErr
io
.
Writer
)
error
{
_
,
err
:=
mu
.
HookAdd
(
uc
.
HOOK_INTR
,
func
(
mu
uc
.
Unicorn
,
intno
uint32
)
{
if
intno
!=
17
{
log
.
Fatal
(
"invalid interrupt "
,
intno
,
" at step "
,
st
eps
)
log
.
Fatal
(
"invalid interrupt "
,
intno
,
" at step "
,
st
.
Step
)
}
syscallNum
,
_
:=
mu
.
RegRead
(
uc
.
MIPS_REG_V0
)
...
...
@@ -64,7 +64,7 @@ func HookUnicorn(st *State, mu uc.Unicorn, stdOut, stdErr io.Writer) error {
a0
,
_
:=
mu
.
RegRead
(
uc
.
MIPS_REG_A0
)
sz
,
_
:=
mu
.
RegRead
(
uc
.
MIPS_REG_A1
)
if
a0
==
0
{
v0
=
0x20000000
+
heap_start
v0
=
uint64
(
st
.
Heap
)
st
.
Heap
+=
uint32
(
sz
)
}
else
{
v0
=
a0
...
...
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