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
94ca24b1
Commit
94ca24b1
authored
Sep 24, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mallocing heap
parent
1d6b3b9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
run.py
risc/run.py
+20
-1
test.go
risc/test.go
+3
-0
No files found.
risc/run.py
View file @
94ca24b1
...
...
@@ -12,7 +12,10 @@ mu = Uc(UC_ARCH_MIPS, UC_MODE_32 + UC_MODE_BIG_ENDIAN)
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"
]
heap_start
=
16
*
1024
*
1024
def
hook_interrupt
(
uc
,
intno
,
user_data
):
global
heap_start
pc
=
uc
.
reg_read
(
UC_MIPS_REG_PC
)
if
intno
==
17
:
syscall_no
=
uc
.
reg_read
(
UC_MIPS_REG_V0
)
...
...
@@ -39,6 +42,19 @@ def hook_interrupt(uc, intno, user_data):
print
(
"read"
,
fd
,
hex
(
buf
),
count
)
uc
.
mem_write
(
buf
,
b
"16384
\n\x00
"
)
uc
.
reg_write
(
UC_MIPS_REG_V0
,
6
)
elif
syscall_no
==
4090
:
a0
=
uc
.
reg_read
(
UC_MIPS_REG_A0
)
a1
=
uc
.
reg_read
(
UC_MIPS_REG_A1
)
a2
=
uc
.
reg_read
(
UC_MIPS_REG_A2
)
print
(
"mmap"
,
hex
(
a0
),
hex
(
a1
),
hex
(
a2
),
"at"
,
hex
(
heap_start
))
if
a0
==
0
:
print
(
"malloced new"
)
#mu.mem_map(heap_start, a1)
heap_start
+=
a1
uc
.
reg_write
(
UC_MIPS_REG_V0
,
heap_start
)
else
:
uc
.
reg_write
(
UC_MIPS_REG_V0
,
a0
)
else
:
jj
=
[]
for
i
,
r
in
zip
(
mregs
,
regs
):
...
...
@@ -47,7 +63,7 @@ def hook_interrupt(uc, intno, user_data):
return
True
print
(
"interrupt"
,
intno
,
hex
(
pc
))
if
intno
==
22
:
if
intno
!=
17
:
raise
Exception
return
True
...
...
@@ -89,6 +105,9 @@ elf.seek(0)
SIZE
=
16
*
1024
*
1024
mu
.
mem_map
(
0
,
SIZE
)
# heap
mu
.
mem_map
(
SIZE
,
0x10000000
)
elffile
=
ELFFile
(
elf
)
for
seg
in
elffile
.
iter_segments
():
print
(
seg
.
header
,
hex
(
seg
.
header
.
p_vaddr
))
...
...
risc/test.go
View file @
94ca24b1
package
main
import
"fmt"
func
main
()
{
fmt
.
Println
(
"hello world"
)
}
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