Reputation: 113
I've been trying to decompile a LuaJIT bytecode file. I have managed to disassemble it (but can't find any way to reassemble it). So I am considering writing some software to convert from LuaJIT bytecode to standard Lua bytecode that would then run through LuaDec fine.
But what are the differences between LuaJIT bytecode and standard Lua bytecode?
Upvotes: 6
Views: 5645
Reputation: 16753
The differences are pretty substantial. LuaJIT uses a lot more opcodes than standard Lua, because it specializes on some operations, like returning from a function vs. returning with 1 return value, etc.
The best you could do is compare the definitions of Lua opcodes and LuaJIT opcodes and see if you could translate between them, but this not going to be trivial...
Upvotes: 9
Reputation: 26181
For an exact answer, you need only compare the BC generators from both projects, however, why bother with a converter, LuaJIT is open-source, and IIRC so is LuaDec, it should be pretty simple to convert it to LuaJIT's bytecode.
However, you should look at the the command-line options of LuaJIT itself of use, there are ones for dumping out the bytecode listing, or dumping out C/h/obj/o files of bytecode, both of which can be used to do what you want.
Upvotes: 1