lua-users home
lua-l archive

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


On 7/10/2012 11:24 PM, Jaco van der Merwe wrote:
The differences of 5.1 relative to 5.0 (from [1]) can be summarised as follows:
* Numeric IDs of some opcodes have changed
* New opcodes have been added
* Some opcodes have been removed
* Some opcodes have been renamed
* Behaviour of some opcodes have changed
* Operand field ordering has changed
* Encoding of operand fields for some opcodes have changed
* Changes to function prototype headers, e.g. is_vararg field
* Changes in ordering, e.g. for function prototype debug data moved to end
[snip]

@KHMan, since you are the author of ChunkSpy you have much more insight into this problem than I do. I would appreciate if you could comment on the points above.

Looking at lopcodes.h only... (considering opcodes only for now):

(1) most opcodes look tantalizingly similar (touch wood), involve changing its opcode value only

(2) the ones that would cause significant transformations are:

(a) OP_FORLOOP: insert OP_FORPREP, shift locals
(b) OP_TFORLOOP/OP_TFORPREP: delete OP_TFORPREP, shift locals
(c) OP_SETLIST/OP_SETLISTO: reform in 5.1 style

For (a),(b) a simple transformation would leave the loops operating in a slightly different way, but is probably good enough to feed into a luadec-like decompiler.

For a one-time thing with not-too-long scripts, it might be more worthwhile to do a binary chunk decoder that annotates a readable dump with enough information to reconstruct the source code.

How big are the scripts? Is debug information available or the binary chunks stripped?

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia