luadec icon indicating copy to clipboard operation
luadec copied to clipboard

bytecode generated by 'luac -s' can't be decompiled.

Open intheway opened this issue 8 years ago • 4 comments

assume the lua file is testbyte.lua and the code is :

function add(x, y)
    return x + y
end
print (add(3, 4))

first i use luac -s -o testbyte.luac testbyte.lua then i use luadec testbyte.luac it failed with error

cannot find blockend > 9 , pc = 8, f->sizecode = 9
cannot find blockend > 3 , pc = 2, f->sizecode = 3
-- Decompiled using luadec 2.2 rev: 033cc84 for Lua 5.2 from https://github.com/viruscamp/luadec\
[1]    2129 bus error  ./luadec 

so, am i did something wrong? or how to decompile the ' luac -s' file? @jeffallen Thanks a lot!

intheway avatar Aug 03 '15 03:08 intheway

bug of local guessing

viruscamp avatar Nov 03 '15 03:11 viruscamp

Thanks. Did you mean that you have solved it ? I get the result nicer in lua 5.1.

cannot find blockend > 8 , pc = 7, f->sizecode = 9
cannot find blockend > 9 , pc = 8, f->sizecode = 9
cannot find blockend > 2 , pc = 1, f->sizecode = 3
cannot find blockend > 3 , pc = 2, f->sizecode = 3
-- Decompiled using luadec 2.2 rev: 6a4592c for Lua 5.1 from https://github.com/viruscamp/luadec
-- Command line: test-add.luac 

-- params : ...
-- function num : 0
add = function(l_1_0, l_1_1)
  -- function num : 0_0
  return l_1_0 + l_1_1
end
print(add(3, 4))

but still error in 5.2

cannot find blockend > 9 , pc = 8, f->sizecode = 9
cannot find blockend > 3 , pc = 2, f->sizecode = 3
-- Decompiled using luadec 2.2 rev: 6a4592c for Lua 5.2 from https://github.com/viruscamp/luadec
-- Command line: testbyte-strip.luac 

[1]    14637 segmentation fault  ./luadec testbyte-strip.luac

intheway avatar Nov 06 '15 09:11 intheway

Thanks. Did you mean that you have solved it ?

No. Local guessing for stripped code is really hard, and the priority is low.

viruscamp avatar Nov 06 '15 11:11 viruscamp

For my case I created a super simple test file

a = 1

And it simply returns bad value at getUpvalName.

kotori2 avatar Sep 11 '20 20:09 kotori2