|
1 | 1 | ---------------------------------------------------------------------------- |
2 | 2 | -- LuaJIT module to save/list bytecode. |
3 | 3 | -- |
4 | | --- Copyright (C) 2005-2016 Mike Pall. All rights reserved. |
| 4 | +-- Copyright (C) 2005-2017 Mike Pall. All rights reserved. |
5 | 5 | -- Released under the MIT license. See Copyright Notice in luajit.h |
6 | 6 | ---------------------------------------------------------------------------- |
7 | 7 | -- |
@@ -63,8 +63,8 @@ local map_type = { |
63 | 63 | } |
64 | 64 |
|
65 | 65 | local map_arch = { |
66 | | - x86 = true, x64 = true, arm = true, arm64 = true, ppc = true, |
67 | | - mips = true, mipsel = true, |
| 66 | + x86 = true, x64 = true, arm = true, arm64 = true, arm64be = true, |
| 67 | + ppc = true, mips = true, mipsel = true, |
68 | 68 | } |
69 | 69 |
|
70 | 70 | local map_os = { |
@@ -125,12 +125,12 @@ extern "C" |
125 | 125 | #ifdef _WIN32 |
126 | 126 | __declspec(dllexport) |
127 | 127 | #endif |
128 | | -const char %s%s[] = { |
| 128 | +const unsigned char %s%s[] = { |
129 | 129 | ]], LJBC_PREFIX, ctx.modname)) |
130 | 130 | else |
131 | 131 | fp:write(string.format([[ |
132 | 132 | #define %s%s_SIZE %d |
133 | | -static const char %s%s[] = { |
| 133 | +static const unsigned char %s%s[] = { |
134 | 134 | ]], LJBC_PREFIX, ctx.modname, #s, LJBC_PREFIX, ctx.modname)) |
135 | 135 | end |
136 | 136 | local t, n, m = {}, 0, 0 |
@@ -200,7 +200,7 @@ typedef struct { |
200 | 200 | ]] |
201 | 201 | local symname = LJBC_PREFIX..ctx.modname |
202 | 202 | local is64, isbe = false, false |
203 | | - if ctx.arch == "x64" or ctx.arch == "arm64" then |
| 203 | + if ctx.arch == "x64" or ctx.arch == "arm64" or ctx.arch == "arm64be" then |
204 | 204 | is64 = true |
205 | 205 | elseif ctx.arch == "ppc" or ctx.arch == "mips" then |
206 | 206 | isbe = true |
@@ -237,9 +237,9 @@ typedef struct { |
237 | 237 | hdr.eendian = isbe and 2 or 1 |
238 | 238 | hdr.eversion = 1 |
239 | 239 | hdr.type = f16(1) |
240 | | - hdr.machine = f16(({ x86=3, x64=62, arm=40, arm64=183, ppc=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 | 241 | if ctx.arch == "mips" or ctx.arch == "mipsel" then |
242 | | - hdr.flags = 0x50001006 |
| 242 | + hdr.flags = f32(0x50001006) |
243 | 243 | end |
244 | 244 | hdr.version = f32(1) |
245 | 245 | hdr.shofs = fofs(ffi.offsetof(o, "sect")) |
@@ -275,7 +275,7 @@ typedef struct { |
275 | 275 | o.sect[2].size = fofs(ofs) |
276 | 276 | o.sect[3].type = f32(3) -- .strtab |
277 | 277 | o.sect[3].ofs = fofs(sofs + ofs) |
278 | | - o.sect[3].size = fofs(#symname+1) |
| 278 | + o.sect[3].size = fofs(#symname+2) |
279 | 279 | ffi.copy(o.space+ofs+1, symname) |
280 | 280 | ofs = ofs + #symname + 2 |
281 | 281 | o.sect[4].type = f32(1) -- .rodata |
|
0 commit comments