Skip to content

Instantly share code, notes, and snippets.

@GitSparTV
Created November 22, 2019 20:28
Show Gist options
  • Save GitSparTV/a0e36f2bc52badbce7723cb2e552285a to your computer and use it in GitHub Desktop.
Save GitSparTV/a0e36f2bc52badbce7723cb2e552285a to your computer and use it in GitHub Desktop.
LuaJIT bytecode structure (partial, no const lua_Number, upvalues, etc)
print(a)
GMod (strip):
[27]LJ -- signature (3 bytes)
[1] -- version (byte)
[2] -- flags (long int ULEB128)
[31] -- proto len (long int ULEB128)
[0] -- proto flags (PROTO_CHILD 0x01 Has child prototypes | PROTO_VARARG 0x02 Function has vararg | PROTO_FFI 0x04 Has CDATA opcode) (byte)
[0] -- proto parameters count (byte)
[2] -- proto frame size (byte)
[0] -- proto upvalue count (byte)
[2] -- proto GCable constants count (long int ULEB128)
[0] -- proto const lua_Number count (long int ULEB128)
[4] -- proto instructions count (bc - 1 on writing) (long int ULEB128)
Instructions:
4 (OP) [0] (A) [0] (C) [0] (B)
4 (OP) [1] (A) [1] (C) [0] (B)
> (OP) [0] (A) [2] (C) [1] (B)
G (OP) [0] (A) [1] (C) [0] (B)
[6] (const type long int ULEB128, len = type - 5) a (value)
[10] (const type long int ULEB128, len = type - 5) print (value)
[0] -- proto EOF
LuaJIT 2 (strip):
[27]LJ -- signature (3 bytes)
[2] -- version (1 byte)
[2] -- flags (long int ULEB128)
[31] -- proto len (long int ULEB128)
[0] -- proto flags (PROTO_CHILD 0x01 Has child prototypes | PROTO_VARARG 0x02 Function has vararg | PROTO_FFI 0x04 Has CDATA opcode)
[0] -- proto parameters count
[2] -- proto frame size
[0] -- proto upvalue count
[2] -- proto GCable constants (long int ULEB128)
[0] -- proto const lua_Number count (long int ULEB128)
[4] -- proto instructions count (bc - 1 on writing) (long int ULEB128)
Instructions:
6 (OP) [0] (A) [0] (C) [0] (B)
6 (OP) [1] (A) [1] (C) [0] (B)
B (OP) [0] (A) [2] (C) [1] (B)
K (OP) [0] (A) [1] (C) [0] (B)
[6] (const type long int ULEB128, len = type - 5) a (value)
[10] (const type long int ULEB128, len = type - 5) print (value)
[0] -- proto EOF
GMod (debug):
[27]LJ -- signature (3 bytes)
[1] -- version (1 byte)
[0] -- flags (long int ULEB128)
Q -- chunk name len (long int ULEB128)
@*gmod folder* -- chunk name
' -- (39)
[0] -- proto flags (PROTO_CHILD 0x01 Has child prototypes | PROTO_VARARG 0x02 Function has vararg | PROTO_FFI 0x04 Has CDATA opcode)
[0] -- proto parameters count
[2] -- proto frame size
[0] -- proto upvalue count
[2] -- proto GCable constants (long int ULEB128)
[0] -- proto const lua_Number count (long int ULEB128)
[4] -- proto instructions count (bc - 1 on writing) (long int ULEB128)
[5] -- debug len
[4] -- first line number
[0] -- total amount of lines
Instructions:
4 (OP) [0] (A) [0] (C) [0] (B)
4 (OP) [1] (A) [1] (C) [0] (B)
> (OP) [0] (A) [2] (C) [1] (B)
G (OP) [0] (A) [1] (C) [0] (B)
[6] (const type long int ULEB128, len = type - 5) a (value)
[10] (const type long int ULEB128, len = type - 5) print (value)
[0][0][0][0][0] -- debug info
[0] -- proto EOF
LuaJIT 2 (debug):
[27]LJ -- signature (3 bytes)
[2] -- version (1 byte)
[0] -- flags (long int ULEB128)
[13] -- chunk name len (long int ULEB128)
@C:\lua\b.lua -- chunk name
' -- (39) proto len (long int ULEB128)
[0] -- proto flags (PROTO_CHILD 0x01 Has child prototypes | PROTO_VARARG 0x02 Function has vararg | PROTO_FFI 0x04 Has CDATA opcode)
[0] -- proto parameters count
[2] -- proto frame size
[0] -- proto upvalue count
[2] -- proto GCable constants (long int ULEB128)
[0] -- proto const lua_Number count (long int ULEB128)
[4] -- proto instructions count (bc - 1 on writing) (long int ULEB128)
[5] -- debug len
[1] -- first line number
[0] -- total amount of lines
Instructions:
6 (OP) [0] (A) [0] (C) [0] (B)
6 (OP) [1] (A) [1] (C) [0] (B)
B (OP) [0] (A) [2] (C) [1] (B)
K (OP) [0] (A) [1] (C) [0] (B)
[6] (const type long int ULEB128, len = type - 5) a (value)
[10] (const type long int ULEB128, len = type - 5) print (value)
[0][0][0][0][0] -- debug info
[0] -- proto EOF
----------------------
print(aa)
GMod (strip):
[27]LJ -- signature (3 bytes)
[1] -- version (1 byte)
[2] -- flags (long int ULEB128)
[32] -- proto len (long int ULEB128)
[0] -- proto flags (PROTO_CHILD 0x01 Has child prototypes | PROTO_VARARG 0x02 Function has vararg | PROTO_FFI 0x04 Has CDATA opcode)
[0] -- proto parameters count
[2] -- proto frame size
[0] -- proto upvalue count
[2] -- proto GCable constants (long int ULEB128)
[0] -- proto const lua_Number count (long int ULEB128)
[4] -- proto instructions count (bc - 1 on writing) (long int ULEB128)
Instructions:
4 (OP) [0] (A) [0] (C) [0] (B)
4 (OP) [1] (A) [1] (C) [0] (B)
> (OP) [0] (A) [2] (C) [1] (B)
G (OP) [0] (A) [1] (C) [0] (B)
[7] (const type long int ULEB128, len = type - 5) aa (value)
[10] (const type long int ULEB128, len = type - 5) print (value)
[0] -- proto EOF
LuaJIT 2 (strip):
[27]LJ -- signature (3 bytes)
[2] -- version (1 byte)
[2] -- flags (long int ULEB128)
[32] -- proto len (long int ULEB128)
[0] -- proto flags (PROTO_CHILD 0x01 Has child prototypes | PROTO_VARARG 0x02 Function has vararg | PROTO_FFI 0x04 Has CDATA opcode)
[0] -- proto parameters count
[2] -- proto frame size
[0] -- proto upvalue count
[2] -- proto GCable constants (long int ULEB128)
[0] -- proto const lua_Number count (long int ULEB128)
[4] -- proto instructions count (bc - 1 on writing) (long int ULEB128)
Instructions:
6 (OP) [0] (A) [0] (C) [0] (B)
6 (OP) [1] (A) [1] (C) [0] (B)
B (OP) [0] (A) [2] (C) [1] (B)
K (OP) [0] (A) [1] (C) [0] (B)
[7] (const type long int ULEB128, len = type - 5) aa (value)
[10] (const type long int ULEB128, len = type - 5) print (value)
[0] -- proto EOF
GMod (debug):
[27]LJ -- signature (3 bytes)
[1] -- version (1 byte)
[0] -- flags (long int ULEB128)
Q -- chunk name len (long int ULEB128)
@*gmod folder* -- chunk name
( -- (40) proto len (long int ULEB128)
[0] -- proto flags (PROTO_CHILD 0x01 Has child prototypes | PROTO_VARARG 0x02 Function has vararg | PROTO_FFI 0x04 Has CDATA opcode)
[0] -- proto parameters count
[2] -- proto frame size
[0] -- proto upvalue count
[2] -- proto GCable constants (long int ULEB128)
[0] -- proto const lua_Number count (long int ULEB128)
[4] -- proto instructions count (bc - 1 on writing) (long int ULEB128)
[5] -- debug len
[4] -- first line number
[0] -- total amount of lines
Instructions:
4 (OP) [0] (A) [0] (B) [0] (C)
4 (OP) [1] (A) [1] (C) [0] (C)
> (OP) [0] (A) [2] (C) [1] (B)
G (OP) [0] (A) [1] (C) [0] (B)
[7] (const type long int ULEB128, len = type - 5) aa (value)
[10] (const type long int ULEB128, len = type - 5) print (value)
[0][0][0][0][0] -- debug info
[0] -- proto EOF
LuaJIT 2 (debug):
[27]LJ -- signature (3 bytes)
[2] -- version (1 byte)
[0] -- flags (long int ULEB128)
[13] -- chunk name len (long int ULEB128)
@C:\lua\b.lua -- chunk name
( -- (40) proto len (long int ULEB128)
[0] -- proto flags (PROTO_CHILD 0x01 Has child prototypes | PROTO_VARARG 0x02 Function has vararg | PROTO_FFI 0x04 Has CDATA opcode)
[0] -- proto parameters count
[2] -- proto frame size
[0] -- proto upvalue count
[2] -- proto GCable constants (long int ULEB128)
[0] -- proto const lua_Number count (long int ULEB128)
[4] -- proto instructions count (bc - 1 on writing) (long int ULEB128)
[5] -- debug len
[1] -- first line number
[0] -- total amount of lines
Instructions:
6 (OP) [0] (A) [0] (B) [0] (C)
6 (OP) [1] (A) [1] (B) [0] (C)
B (OP) [0] (A) [2] (B) [1] (C)
K (OP) [0] (A) [1] (B) [0] (C)
[7] (const type long int ULEB128, len = type - 5) aa (value)
[10] (const type long int ULEB128, len = type - 5) print (value)
[0][0][0][0][0] -- debug info
[0] -- proto EOF
----------------------
printb(aa)
GMod (strip):
[27]LJ -- signature (3 bytes)
[1] -- version (1 byte)
[2] -- flags (long int ULEB128)
! -- proto len (long int ULEB128)
[0] -- proto flags (PROTO_CHILD 0x01 Has child prototypes | PROTO_VARARG 0x02 Function has vararg | PROTO_FFI 0x04 Has CDATA opcode)
[0] -- proto parameters count
[2] -- proto frame size
[0] -- proto upvalue count
[2] -- proto GCable constants (long int ULEB128)
[0] -- proto const lua_Number count (long int ULEB128)
[4] -- proto instructions count (bc - 1 on writing) (long int ULEB128)
Instructions:
4 (OP) [0] (A) [0] (C) [0] (B)
4 (OP) [1] (A) [1] (C) [0] (B)
> (OP) [0] (A) [2] (C) [1] (B)
G (OP) [0] (A) [1] (C) [0] (B)
[7] (const type long int ULEB128, len = type - 5) aa (value)
[11] (const type long int ULEB128, len = type - 5) printb (value)
[0] -- proto EOF
LuaJIT 2 (strip):
[27]LJ -- signature (3 bytes)
[2] -- version (1 byte)
[2] -- flags (long int ULEB128)
! -- (33) proto len (long int ULEB128)
[0] -- proto flags (PROTO_CHILD 0x01 Has child prototypes | PROTO_VARARG 0x02 Function has vararg | PROTO_FFI 0x04 Has CDATA opcode)
[0] -- proto parameters count
[2] -- proto frame size
[0] -- proto upvalue count
[2] -- proto GCable constants (long int ULEB128)
[0] -- proto const lua_Number count (long int ULEB128)
[4] -- proto instructions count (bc - 1 on writing) (long int ULEB128)
Instructions:
6 (OP) [0] (A) [0] (C) [0] (B)
6 (OP) [1] (A) [1] (C) [0] (B)
B (OP) [0] (A) [2] (C) [1] (B)
K (OP) [0] (A) [1] (C) [0] (B)
[7] (const type long int ULEB128, len = type - 5) aa (value)
[11] (const type long int ULEB128, len = type - 5) printb (value)
[0] -- proto EOF
GMod (debug):
[27]LJ -- signature (3 bytes)
[1] -- version (1 byte)
[0] -- flags (long int ULEB128)
Q -- chunk name len (long int ULEB128)
@*gmod folder* -- chunk name
) -- (33) proto len (long int ULEB128)
[0] -- proto flags (PROTO_CHILD 0x01 Has child prototypes | PROTO_VARARG 0x02 Function has vararg | PROTO_FFI 0x04 Has CDATA opcode)
[0] -- proto parameters count
[2] -- proto frame size
[0] -- proto upvalue count
[2] -- proto GCable constants (long int ULEB128)
[0] -- proto const lua_Number count (long int ULEB128)
[4] -- proto instructions count (bc - 1 on writing) (long int ULEB128)
[5] -- debug len
[4] -- first line number
[0] -- total amount of lines
Instructions:
4 (OP) [0] (A) [0] (C) [0] (B)
4 (OP) [1] (A) [1] (C) [0] (B)
> (OP) [0] (A) [2] (C) [1] (B)
G (OP) [0] (A) [1] (C) [0] (B)
[7] (const type long int ULEB128, len = type - 5) aa (value)
[11] (const type long int ULEB128, len = type - 5) printb (value)
[0][0][0][0][0] -- debug info
[0] -- proto EOF
LuaJIT 2 (debug):
[27]LJ -- signature (3 bytes)
[2] -- version (1 byte)
[0] -- flags (long int ULEB128)
[13] -- chunk name len (long int ULEB128)
@C:\lua\b.lua -- chunk name
) -- proto len (long int ULEB128)
[0] -- proto flags (PROTO_CHILD 0x01 Has child prototypes | PROTO_VARARG 0x02 Function has vararg | PROTO_FFI 0x04 Has CDATA opcode)
[0] -- proto parameters count
[2] -- proto frame size
[0] -- proto upvalue count
[2] -- proto GCable constants (long int ULEB128)
[0] -- proto const lua_Number count (long int ULEB128)
[4] -- proto instructions count (bc - 1 on writing) (long int ULEB128)
[5] -- debug len
[1] -- first line number
[0] -- total amount of lines
Instructions:
6 (OP) [0] (A) [0] (C) [0] (B)
6 (OP) [1] (A) [1] (C) [0] (B)
B (OP) [0] (A) [2] (C) [1] (B)
K (OP) [0] (A) [1] (C) [0] (B)
[7] (const type long int ULEB128, len = type - 5) aa (value)
[11] (const type long int ULEB128, len = type - 5) printb (value)
[0][0][0][0][0] -- debug info
[0] -- proto EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment