summaryrefslogtreecommitdiff
path: root/main.myr
diff options
context:
space:
mode:
Diffstat (limited to 'main.myr')
-rw-r--r--main.myr32
1 files changed, 18 insertions, 14 deletions
diff --git a/main.myr b/main.myr
index 7cb835a..c4cc8a3 100644
--- a/main.myr
+++ b/main.myr
@@ -32,6 +32,7 @@ const main = {args
.data="",
.rodata="",
.bss = 0,
+ .base=0x200028,
.outf=outf,
.sys=sys,
@@ -80,19 +81,6 @@ const link = {lnk
;;
}
-const addsym = {lnk, buf, sym
- match std.htget(lnk.stab, sym.name)
- | `std.None:
- sym.off = buf#.len
- std.sljoin(buf, sym.buf)
- std.htput(lnk.stab, sym.name, sym)
- | `std.Some old:
- if sym.kind & Symonce == 0 || old.kind & Symonce == 0
- std.fatal("duplicate symbol {}\n", sym.name)
- ;;
- ;;
-}
-
const relocate = {lnk, r
var buf : byte[8]
var addr, sz
@@ -120,7 +108,7 @@ const relocate = {lnk, r
| _:
std.fatal("corrupt relocation\n")
;;
- if addr > (1ul << 8*sz)
+ if addr > (1ul << 8*sz + lnk.base)
std.fatal("relocation overflow in {}\n", s.name)
;;
if r.off + sz > lnk.cur.len
@@ -133,6 +121,22 @@ const relocate = {lnk, r
;;
}
+const addsym = {lnk, buf, sym
+ match std.htget(lnk.stab, sym.name)
+ | `std.None:
+ sym.off = buf#.len
+ std.sljoin(buf, sym.buf)
+ std.htput(lnk.stab, sym.name, sym)
+ if std.sleq(sym.name, "_start") || std.sleq(sym.name, "start")
+ lnk.entry = lnk.base + sym.off
+ ;;
+ | `std.Some old:
+ if sym.kind & Symonce == 0 || old.kind & Symonce == 0
+ std.fatal("duplicate symbol {}\n", sym.name)
+ ;;
+ ;;
+}
+
const loadobj = {lnk, path
var rel, str, sym, o
var obj