From 575af689b50dfd1e2ea2425b2b95bb6c6c4c3267 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 14 Oct 2016 04:50:14 -0700 Subject: [PATCH] fix loading labels with overflowed PC --- lips/Dumper.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lips/Dumper.lua b/lips/Dumper.lua index bc80945..0347de6 100644 --- a/lips/Dumper.lua +++ b/lips/Dumper.lua @@ -221,6 +221,15 @@ function Dumper:fill(length, content) end function Dumper:pc() + --[[ work around a potential overflow issue. consider the assembly: + .base 0x80000000 ; possibly by default and not explicitly written + .org 0x80001000 + mylabel: + la a0, mylabel ; BUG: this would load 0x1000 instead of 0x80001000 + --]] + if self.pos >= 0x80000000 and self.base >= 0x80000000 then + return self.pos - 0x80000000 + self.base + end return self.pos + self.base end