Commit 9b8181a2 authored by George Hotz's avatar George Hotz

build hello world

parent 71a65cba
...@@ -2,4 +2,6 @@ __pycache__ ...@@ -2,4 +2,6 @@ __pycache__
go-ethereum go-ethereum
sysroot sysroot
test test
test.bin
minigeth
minigeth.bin minigeth.bin
...@@ -6,7 +6,7 @@ export GOMIPS=softfloat ...@@ -6,7 +6,7 @@ export GOMIPS=softfloat
go build go build
cd ../mipigeth cd ../mipigeth
cp ../minigeth/go-ethereum go-ethereum cp ../minigeth/go-ethereum minigeth
file go-ethereum file minigeth
./compile.py ./compile.py
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys
import struct import struct
from rangetree import RangeTree from rangetree import RangeTree
from elftools.elf.elffile import ELFFile from elftools.elf.elffile import ELFFile
...@@ -6,8 +7,8 @@ from elftools.elf.elffile import ELFFile ...@@ -6,8 +7,8 @@ from elftools.elf.elffile import ELFFile
from unicorn import * from unicorn import *
from unicorn.mips_const import * from unicorn.mips_const import *
def load_minigeth(mu): def load_minigeth(mu, fn="minigeth"):
elf = open("go-ethereum", "rb") elf = open(fn, "rb")
data = elf.read() data = elf.read()
elf.seek(0) elf.seek(0)
...@@ -62,16 +63,19 @@ def load_minigeth(mu): ...@@ -62,16 +63,19 @@ def load_minigeth(mu):
#traceback.print_exc() #traceback.print_exc()
pass pass
assert(found == 2) #assert(found == 2)
return prog_size, r return prog_size, r
if __name__ == "__main__": if __name__ == "__main__":
mu = Uc(UC_ARCH_MIPS, UC_MODE_32 + UC_MODE_BIG_ENDIAN) mu = Uc(UC_ARCH_MIPS, UC_MODE_32 + UC_MODE_BIG_ENDIAN)
prog_size, _ = load_minigeth(mu) fn = "minigeth"
if len(sys.argv) > 1:
fn = sys.argv[1]
prog_size, _ = load_minigeth(mu, fn)
print("compiled %d bytes" % prog_size) print("compiled %d bytes" % prog_size)
with open("minigeth.bin", "wb") as f: with open(fn+".bin", "wb") as f:
f.write(mu.mem_read(0, prog_size)) f.write(mu.mem_read(0, prog_size))
\ No newline at end of file
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
#!/bin/bash -e
export GOOS=linux
export GOARCH=mips
export GOMIPS=softfloat
go build test.go
./compile.py test
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment