Skip to content

Commit 0a3cd94

Browse files
author
Mike Pall
committed
ARM64: Add support for saving bytecode as object files.
1 parent ba617df commit 0a3cd94

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/jit/bcsave.lua

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ local map_type = {
6363
}
6464

6565
local map_arch = {
66-
x86 = true, x64 = true, arm = true, ppc = true,
66+
x86 = true, x64 = true, arm = true, arm64 = true, ppc = true,
6767
mips = true, mipsel = true,
6868
}
6969

@@ -237,7 +237,7 @@ typedef struct {
237237
hdr.eendian = isbe and 2 or 1
238238
hdr.eversion = 1
239239
hdr.type = f16(1)
240-
hdr.machine = f16(({ x86=3, x64=62, arm=40, ppc=20, mips=8, mipsel=8 })[ctx.arch])
240+
hdr.machine = f16(({ x86=3, x64=62, arm=40, arm64=183, ppc=20, mips=8, mipsel=8 })[ctx.arch])
241241
if ctx.arch == "mips" or ctx.arch == "mipsel" then
242242
hdr.flags = 0x50001006
243243
end
@@ -477,13 +477,13 @@ typedef struct {
477477
} mach_obj_64;
478478
typedef struct {
479479
mach_fat_header fat;
480-
mach_fat_arch fat_arch[4];
480+
mach_fat_arch fat_arch[2];
481481
struct {
482482
mach_header hdr;
483483
mach_segment_command seg;
484484
mach_section sec;
485485
mach_symtab_command sym;
486-
} arch[4];
486+
} arch[2];
487487
mach_nlist sym_entry;
488488
uint8_t space[4096];
489489
} mach_fat_obj;
@@ -494,6 +494,8 @@ typedef struct {
494494
is64, align, mobj = true, 8, "mach_obj_64"
495495
elseif ctx.arch == "arm" then
496496
isfat, mobj = true, "mach_fat_obj"
497+
elseif ctx.arch == "arm64" then
498+
is64, align, isfat, mobj = true, 8, true, "mach_fat_obj"
497499
else
498500
check(ctx.arch == "x86", "unsupported architecture for OSX")
499501
end
@@ -503,8 +505,8 @@ typedef struct {
503505
-- Create Mach-O object and fill in header.
504506
local o = ffi.new(mobj)
505507
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]
507-
local cpusubtype = ({ x86={3}, x64={3}, arm={3,6,9,11} })[ctx.arch]
508+
local cputype = ({ x86={7}, x64={0x01000007}, arm={7,12}, arm64={0x01000007,0x0100000c} })[ctx.arch]
509+
local cpusubtype = ({ x86={3}, x64={3}, arm={3,9}, arm64={3,0} })[ctx.arch]
508510
if isfat then
509511
o.fat.magic = be32(0xcafebabe)
510512
o.fat.nfat_arch = be32(#cpusubtype)

0 commit comments

Comments
 (0)