6

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?

finnw
  • 47,861
  • 24
  • 143
  • 221
R4000
  • 113
  • 2
  • 7

2 Answers2

9

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...

Michal Kottman
  • 16,375
  • 3
  • 47
  • 62
1

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.

Necrolis
  • 25,836
  • 3
  • 63
  • 101
  • I have tried all the flags for bytecode dumping, none of them return a format I can reassemble OR feed into LuaDec. – R4000 Dec 24 '11 at 12:23