mirror of
https://github.com/notwa/lips
synced 2024-11-14 21:19:03 -08:00
ensure labels exist
This commit is contained in:
parent
f12fec5094
commit
b60ca90873
1 changed files with 10 additions and 4 deletions
14
lips.lua
14
lips.lua
|
@ -1350,12 +1350,18 @@ function Dumper:desym(tok)
|
||||||
elseif all_registers[tok] then
|
elseif all_registers[tok] then
|
||||||
return registers[tok] or fpu_registers[tok]
|
return registers[tok] or fpu_registers[tok]
|
||||||
elseif tok[1] == 'LABELSYM' then
|
elseif tok[1] == 'LABELSYM' then
|
||||||
|
local label = self.labels[tok[2]]
|
||||||
|
if label == nil then
|
||||||
|
self:error('undefined label')
|
||||||
|
end
|
||||||
local offset = self.options.offset or 0
|
local offset = self.options.offset or 0
|
||||||
return self.labels[tok[2]] + offset
|
return label + offset
|
||||||
elseif tok[1] == 'LABELREL' then
|
elseif tok[1] == 'LABELREL' then
|
||||||
-- TODO: ensure label exists
|
local label = self.labels[tok[2]]
|
||||||
local rel = floor(self.labels[tok[2]]/4)
|
if label == nil then
|
||||||
rel = rel - 1 - floor(self.pos/4)
|
self:error('undefined label')
|
||||||
|
end
|
||||||
|
local rel = floor(label/4) - 1 - floor(self.pos/4)
|
||||||
if rel > 0x8000 or rel <= -0x8000 then
|
if rel > 0x8000 or rel <= -0x8000 then
|
||||||
self:error('branch too far')
|
self:error('branch too far')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue