Differences between standard Lua bytecode and LuaJIT bytecode
Asked Answered
C

2

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?

Cystolith answered 24/12, 2011 at 6:11 Comment(0)
E
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...

Eighty answered 24/12, 2011 at 13:34 Comment(1)
I was afraid of this :( Thank you for you're help, i'll take a peek.Cystolith
A
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.

Anglicize answered 24/12, 2011 at 6:51 Comment(1)
I have tried all the flags for bytecode dumping, none of them return a format I can reassemble OR feed into LuaDec.Cystolith

© 2022 - 2024 — McMap. All rights reserved.