lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I seem to have found the problem in luadec (5.0 version). It cannot handle function calls with inline tables, for example:

    f(a, {{x=1,y=2},{x=1,y=4}}, c)

I had a look at the source code where it handles the OP_CALL instruction, but the solution is not obvious. I would appreciate any assistance from someone that is more familiar with the source code of luadec.


On 7/10/2012 9:54 AM, Jaco van der Merwe wrote:
> To:
> Subject: Converting Lua 5.0 binary chunk/bytecodes to Lua 5.1 binary chunk
> I have a collection of luac files that were compiled with Lua 5.0.2.
> Unfortunately I do not have the original source code files anymore. In an
> attempt to recover the original source code I investigated the available
> Lua decompilers. The only decompiler I found that works for Lua 5.0
> binaries is luadec [1],[2]. It was only able to decompile about 60% of my
> files. On the remaining files it either asserts or complains about
> unsupported constructs in the code. Even the successfully decompiled files
> do not seem 100% correct.
> The Lua 5.1 decompilers seem to have evolved significantly in terms of
> correctness, robustness and the quality of the generated code, for example
> luadec51 [3]. If I want to utilise these decompilers I'll have to somehow
> convert the Lua 5.0 binaries to Lua 5.1 binaries.
> My question to the community is whether this has been done before? If so,
> can you provide any pointers to it?
> If the answer is no, I would appreciate some pointers on how to go about
> implementing such a conversion myself. I have found a few possible
> approaches.
> * The ChunkSpy [4] utility supports rewriting of chunks from one platform
> format to another. Maybe one can hook into the rewrite function to do such
> a conversion? Some pointers as to the differences between Lua 5.0 and 5.1
> bytecodes are provided in chapter 15 of the document "A No-Frills
> Introduction to Lua 5.1 VM Instructions" [5].
> * Another approach might be to base a converter the lundump.c and ldump.c
> files. The implementation would probably consist of modifying the
> lundump.c file from Lua 5.0 to read the chunks and create some
> intermediate data structures. Then one can modify the ldump.c file from
> Lua 5.1 to convert this intermediate representation and write out 5.1
> chunks.
> The approach may seem simple, but I suspect the difficulty will be in
> handling cases where the behaviors of existing opcodes have changed.
> Regards
> J
> [1]
> [2]
> [3]
> [4]
> [5]