From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "struct" |
|---|
| subject | "Format:Lua bytecode" |
|---|
| claim | "The Lua 5.1 chunk header is 12 bytes: signature, version 0x51, format 0, endianness (1 little, 0 big), sizeof(int), sizeof(size_t), sizeof(Instruction), sizeof(lua_Number), integral flag. The loader compares all 12 bytes with its own header and fails with 'bad header in precompiled chunk' on any difference." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:Lua bytecode" |
|---|
| observed_in | |
|---|
|
|---|
| data | | name | "lua51_header" |
|---|
| size | 12 |
|---|
| fields | | offset | 0 |
|---|
| size | 4 |
|---|
| type | "char[4]" |
|---|
| name | "signature" |
|---|
| notes | "1B 4C 75 61" |
|---|
|
| offset | 4 |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "version" |
|---|
| notes | "0x51" |
|---|
|
| offset | 5 |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "format" |
|---|
| notes | "0 = official" |
|---|
|
| offset | 6 |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "endianness" |
|---|
| notes | "1 = little endian" |
|---|
|
| offset | 7 |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "sizeof_int" |
|---|
| notes | "4" |
|---|
|
| offset | 8 |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "sizeof_size_t" |
|---|
| notes | "4 on 32-bit, 8 on 64-bit builds" |
|---|
|
| offset | 9 |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "sizeof_Instruction" |
|---|
| notes | "4" |
|---|
|
| offset | 10 |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "sizeof_lua_Number" |
|---|
| notes | "8 (double)" |
|---|
|
| offset | 11 |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "integral" |
|---|
| notes | "1 if lua_Number is an integer type" |
|---|
|
|
|---|
| endianness | "native" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "luaU_header() writes the 12 bytes; LoadHeader (line 185) memcmp's them: IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header") (tag v5.1.1)" |
|---|
| repo | "https://github.com/lua/lua" |
|---|
| commit | "98194db4295726069137d13b8d24fca8cbf892b6" |
|---|
| path | "lundump.c" |
|---|
| lines | "210-223" |
|---|
|
| type | "runtime_test" |
|---|
| detail | "MSVC x64 builds of 5.1 and 5.1.1 write 1B 4C 75 61 51 00 01 04 08 04 08 00; VLC 3.0.23 chunks have 01 04 04 04 08 00 (size_t 4) and are rejected by the stock x64 build with 'bad header in precompiled chunk'." |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "Header (Lua 5.1)" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-17T07:00:30.624Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T17:28:42.963Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read luaU_header in lundump.c at the cited commit: signature, VERSION, FORMAT, endianness byte *(char*)&x (host order), sizeof int, size_t, Instruction, lua_Number, integral flag = 12 bytes, written in host order." |
|---|
|
|
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T17:08:37.400Z" |
|---|
| summary | "Add data.endianness native: the chunk is dumped in the host byte order (byte 6 is the dumping machine's flag: luaU_header stores *(char*)&x, lundump.c 215-217) and LoadHeader memcmp's all 12 bytes…" |
|---|
| changed | |
|---|
|
|
|---|