diff options
Diffstat (limited to 'src/jit/bcsave.lua')
-rw-r--r-- | src/jit/bcsave.lua | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/jit/bcsave.lua b/src/jit/bcsave.lua index c94064e4..2553d97e 100644 --- a/src/jit/bcsave.lua +++ b/src/jit/bcsave.lua | |||
@@ -11,7 +11,7 @@ | |||
11 | ------------------------------------------------------------------------------ | 11 | ------------------------------------------------------------------------------ |
12 | 12 | ||
13 | local jit = require("jit") | 13 | local jit = require("jit") |
14 | assert(jit.version_num == 20005, "LuaJIT core/library version mismatch") | 14 | assert(jit.version_num == 20100, "LuaJIT core/library version mismatch") |
15 | local bit = require("bit") | 15 | local bit = require("bit") |
16 | 16 | ||
17 | -- Symbol name prefix for LuaJIT bytecode. | 17 | -- Symbol name prefix for LuaJIT bytecode. |
@@ -63,8 +63,8 @@ local map_type = { | |||
63 | } | 63 | } |
64 | 64 | ||
65 | local map_arch = { | 65 | local map_arch = { |
66 | x86 = true, x64 = true, arm = true, ppc = true, ppcspe = true, | 66 | x86 = true, x64 = true, arm = true, arm64 = true, arm64be = true, |
67 | mips = true, mipsel = true, | 67 | ppc = true, mips = true, mipsel = true, |
68 | } | 68 | } |
69 | 69 | ||
70 | local map_os = { | 70 | local map_os = { |
@@ -125,12 +125,12 @@ extern "C" | |||
125 | #ifdef _WIN32 | 125 | #ifdef _WIN32 |
126 | __declspec(dllexport) | 126 | __declspec(dllexport) |
127 | #endif | 127 | #endif |
128 | const char %s%s[] = { | 128 | const unsigned char %s%s[] = { |
129 | ]], LJBC_PREFIX, ctx.modname)) | 129 | ]], LJBC_PREFIX, ctx.modname)) |
130 | else | 130 | else |
131 | fp:write(string.format([[ | 131 | fp:write(string.format([[ |
132 | #define %s%s_SIZE %d | 132 | #define %s%s_SIZE %d |
133 | static const char %s%s[] = { | 133 | static const unsigned char %s%s[] = { |
134 | ]], LJBC_PREFIX, ctx.modname, #s, LJBC_PREFIX, ctx.modname)) | 134 | ]], LJBC_PREFIX, ctx.modname, #s, LJBC_PREFIX, ctx.modname)) |
135 | end | 135 | end |
136 | local t, n, m = {}, 0, 0 | 136 | local t, n, m = {}, 0, 0 |
@@ -200,9 +200,9 @@ typedef struct { | |||
200 | ]] | 200 | ]] |
201 | local symname = LJBC_PREFIX..ctx.modname | 201 | local symname = LJBC_PREFIX..ctx.modname |
202 | local is64, isbe = false, false | 202 | local is64, isbe = false, false |
203 | if ctx.arch == "x64" then | 203 | if ctx.arch == "x64" or ctx.arch == "arm64" or ctx.arch == "arm64be" then |
204 | is64 = true | 204 | is64 = true |
205 | elseif ctx.arch == "ppc" or ctx.arch == "ppcspe" or ctx.arch == "mips" then | 205 | elseif ctx.arch == "ppc" or ctx.arch == "mips" then |
206 | isbe = true | 206 | isbe = true |
207 | end | 207 | end |
208 | 208 | ||
@@ -237,7 +237,7 @@ typedef struct { | |||
237 | hdr.eendian = isbe and 2 or 1 | 237 | hdr.eendian = isbe and 2 or 1 |
238 | hdr.eversion = 1 | 238 | hdr.eversion = 1 |
239 | hdr.type = f16(1) | 239 | hdr.type = f16(1) |
240 | hdr.machine = f16(({ x86=3, x64=62, arm=40, ppc=20, ppcspe=20, mips=8, mipsel=8 })[ctx.arch]) | 240 | hdr.machine = f16(({ x86=3, x64=62, arm=40, arm64=183, arm64be=183, ppc=20, mips=8, mipsel=8 })[ctx.arch]) |
241 | if ctx.arch == "mips" or ctx.arch == "mipsel" then | 241 | if ctx.arch == "mips" or ctx.arch == "mipsel" then |
242 | hdr.flags = f32(0x50001006) | 242 | hdr.flags = f32(0x50001006) |
243 | end | 243 | end |
@@ -477,13 +477,13 @@ typedef struct { | |||
477 | } mach_obj_64; | 477 | } mach_obj_64; |
478 | typedef struct { | 478 | typedef struct { |
479 | mach_fat_header fat; | 479 | mach_fat_header fat; |
480 | mach_fat_arch fat_arch[4]; | 480 | mach_fat_arch fat_arch[2]; |
481 | struct { | 481 | struct { |
482 | mach_header hdr; | 482 | mach_header hdr; |
483 | mach_segment_command seg; | 483 | mach_segment_command seg; |
484 | mach_section sec; | 484 | mach_section sec; |
485 | mach_symtab_command sym; | 485 | mach_symtab_command sym; |
486 | } arch[4]; | 486 | } arch[2]; |
487 | mach_nlist sym_entry; | 487 | mach_nlist sym_entry; |
488 | uint8_t space[4096]; | 488 | uint8_t space[4096]; |
489 | } mach_fat_obj; | 489 | } mach_fat_obj; |
@@ -494,6 +494,8 @@ typedef struct { | |||
494 | is64, align, mobj = true, 8, "mach_obj_64" | 494 | is64, align, mobj = true, 8, "mach_obj_64" |
495 | elseif ctx.arch == "arm" then | 495 | elseif ctx.arch == "arm" then |
496 | isfat, mobj = true, "mach_fat_obj" | 496 | isfat, mobj = true, "mach_fat_obj" |
497 | elseif ctx.arch == "arm64" then | ||
498 | is64, align, isfat, mobj = true, 8, true, "mach_fat_obj" | ||
497 | else | 499 | else |
498 | check(ctx.arch == "x86", "unsupported architecture for OSX") | 500 | check(ctx.arch == "x86", "unsupported architecture for OSX") |
499 | end | 501 | end |
@@ -503,8 +505,8 @@ typedef struct { | |||
503 | -- Create Mach-O object and fill in header. | 505 | -- Create Mach-O object and fill in header. |
504 | local o = ffi.new(mobj) | 506 | local o = ffi.new(mobj) |
505 | local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, align) | 507 | local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, align) |
506 | local cputype = ({ x86={7}, x64={0x01000007}, arm={7,12,12,12} })[ctx.arch] | 508 | local cputype = ({ x86={7}, x64={0x01000007}, arm={7,12}, arm64={0x01000007,0x0100000c} })[ctx.arch] |
507 | local cpusubtype = ({ x86={3}, x64={3}, arm={3,6,9,11} })[ctx.arch] | 509 | local cpusubtype = ({ x86={3}, x64={3}, arm={3,9}, arm64={3,0} })[ctx.arch] |
508 | if isfat then | 510 | if isfat then |
509 | o.fat.magic = be32(0xcafebabe) | 511 | o.fat.magic = be32(0xcafebabe) |
510 | o.fat.nfat_arch = be32(#cpusubtype) | 512 | o.fat.nfat_arch = be32(#cpusubtype) |
@@ -653,7 +655,7 @@ end | |||
653 | ------------------------------------------------------------------------------ | 655 | ------------------------------------------------------------------------------ |
654 | 656 | ||
655 | -- Public module functions. | 657 | -- Public module functions. |
656 | module(...) | 658 | return { |
657 | 659 | start = docmd -- Process -b command line option. | |
658 | start = docmd -- Process -b command line option. | 660 | } |
659 | 661 | ||