jake
jake

Reputation: 29

Are their differences between lua 5.1 bytecode created using luac and string.dump()?

If so, is there any way to convert between the two?

I'm trying to load some byte code created by string.dump into a program called unluac, however it is not working.

Here are the bytes I am attempting to decompile if it helps anyone:

\27\76\80\72\1\0\0\0\146\10\2\0\161\10\2\0\9\0\0\0\21\0\0\0\228\11\200\0\130\90\116\0\224\159\228\0\152\117\220\0\228\11\200\0\126\238\144\0\228\11\200\0\130\90\116\0\42\128\222\0\122\130\173\0\158\151\177\0\194\172\181\0\6\107\218\0\240\79\114\0\78\149\226\0\90\217\140\0\224\159\228\0\84\183\183\0\224\159\228\0\86\109\169\0\0\0\0\0\0\0\0\0\0\0\0\0\2\0\0\0\21\0\0\0\228\11\200\0\130\90\116\0\224\159\228\0\152\117\220\0\228\11\200\0\126\238\144\0\228\11\200\0\130\90\116\0\42\128\222\0\122\130\173\0\158\151\177\0\194\172\181\0\6\107\218\0\240\79\114\0\78\149\226\0\90\217\140\0\224\159\228\0\84\183\183\0\224\159\228\0\86\109\169\0\0\0\0\0\1\0\0\0\1\0\0\0\8\0\0\0\21\0\0\0\188\138\224\0\14\67\161\0\90\217\140\0\94\69\112\0\12\141\175\0\58\48\108\0\22\27\104\0\194\172\181\0\114\170\230\0\40\202\236\0\22\27\104\0\78\149\226\0\58\48\108\0\234\45\157\0\194\172\181\0\190\64\210\0\122\130\173\0\6\107\218\0\224\159\228\0\150\191\234\0\0\0\0\0\0\0\0\0\2\0\0\0\1\0\0\0\36\0\0\0\21\0\0\0\188\138\224\0\14\67\161\0\90\217\140\0\94\69\112\0\12\141\175\0\58\48\108\0\22\27\104\0\194\172\181\0\114\170\230\0\40\202\236\0\22\27\104\0\78\149\226\0\58\48\108\0\234\45\157\0\194\172\181\0\190\64\210\0\122\130\173\0\6\107\218\0\224\159\228\0\150\191\234\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0\123\10\2\0\4\0\0\0\6\0\0\0\224\159\228\0\4\181\232\0\226\85\214\0\188\138\224\0\40\202\236\0\0\0\0\0\3\0\0\0\154\153\153\153\153\153\27\192\0\0\0\0\0\0\0\0

Upvotes: 1

Views: 695

Answers (1)

Vlad
Vlad

Reputation: 5857

There is no difference. Both cases will use the same luaU_dump() at the end.

Note though that Lua is saving sizes of some native types in bytecode chunk header. One of those fields is of type size_t, that makes bytecode incompatible not only between hosts with different endianness, but also between 32- and 64-bit systems.

In short - you must use Lua compiler (luac) of the same version as interpreter, and compiled for exactly the same platform that will run the interpreter. I.e. you can't use 64-bit luac to produce bytecode to be running by Lua VM within 32-bit program.

Upvotes: 3

Related Questions