diff options
author | Mike Pall <mike> | 2012-06-04 17:23:48 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2012-06-04 17:23:48 +0200 |
commit | bd23a6c42f66adc7e35c182db3989500104a01b2 (patch) | |
tree | e0a1b112ff958208988996b5b557d40d5b5ffb52 | |
parent | 5032e6d87f2873d3c4712bbbdc3438d6404499a9 (diff) | |
download | luajit-bd23a6c42f66adc7e35c182db3989500104a01b2.tar.gz luajit-bd23a6c42f66adc7e35c182db3989500104a01b2.tar.bz2 luajit-bd23a6c42f66adc7e35c182db3989500104a01b2.zip |
MIPS: Support generation of mips/mipsel bytecode object files.
-rw-r--r-- | lib/bcsave.lua | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/bcsave.lua b/lib/bcsave.lua index 7ac0ce35..70cb6925 100644 --- a/lib/bcsave.lua +++ b/lib/bcsave.lua | |||
@@ -63,6 +63,7 @@ local map_type = { | |||
63 | 63 | ||
64 | local map_arch = { | 64 | local map_arch = { |
65 | x86 = true, x64 = true, arm = true, ppc = true, ppcspe = true, | 65 | x86 = true, x64 = true, arm = true, ppc = true, ppcspe = true, |
66 | mips = true, mipsel = true, | ||
66 | } | 67 | } |
67 | 68 | ||
68 | local map_os = { | 69 | local map_os = { |
@@ -200,7 +201,7 @@ typedef struct { | |||
200 | local is64, isbe = false, false | 201 | local is64, isbe = false, false |
201 | if ctx.arch == "x64" then | 202 | if ctx.arch == "x64" then |
202 | is64 = true | 203 | is64 = true |
203 | elseif ctx.arch == "ppc" or ctx.arch == "ppcspe" then | 204 | elseif ctx.arch == "ppc" or ctx.arch == "ppcspe" or ctx.arch == "mips" then |
204 | isbe = true | 205 | isbe = true |
205 | end | 206 | end |
206 | 207 | ||
@@ -234,7 +235,10 @@ typedef struct { | |||
234 | hdr.eendian = isbe and 2 or 1 | 235 | hdr.eendian = isbe and 2 or 1 |
235 | hdr.eversion = 1 | 236 | hdr.eversion = 1 |
236 | hdr.type = f16(1) | 237 | hdr.type = f16(1) |
237 | hdr.machine = f16(({ x86=3, x64=62, arm=40, ppc=20, ppcspe=20 })[ctx.arch]) | 238 | hdr.machine = f16(({ x86=3, x64=62, arm=40, ppc=20, ppcspe=20, mips=8, mipsel=8 })[ctx.arch]) |
239 | if ctx.arch == "mips" or ctx.arch == "mipsel" then | ||
240 | hdr.flags = 0x50001006 | ||
241 | end | ||
238 | hdr.version = f32(1) | 242 | hdr.version = f32(1) |
239 | hdr.shofs = fofs(ffi.offsetof(o, "sect")) | 243 | hdr.shofs = fofs(ffi.offsetof(o, "sect")) |
240 | hdr.ehsize = f16(ffi.sizeof(hdr)) | 244 | hdr.ehsize = f16(ffi.sizeof(hdr)) |
@@ -349,7 +353,7 @@ typedef struct { | |||
349 | -- Create PE object and fill in header. | 353 | -- Create PE object and fill in header. |
350 | local o = ffi.new("PEobj") | 354 | local o = ffi.new("PEobj") |
351 | local hdr = o.hdr | 355 | local hdr = o.hdr |
352 | hdr.arch = f16(({ x86=0x14c, x64=0x8664, arm=0x1c0, ppc=0x1f2 })[ctx.arch]) | 356 | hdr.arch = f16(({ x86=0x14c, x64=0x8664, arm=0x1c0, ppc=0x1f2, mips=0x366, mipsel=0x366 })[ctx.arch]) |
353 | hdr.nsects = f16(2) | 357 | hdr.nsects = f16(2) |
354 | hdr.symtabofs = f32(ffi.offsetof(o, "sym0")) | 358 | hdr.symtabofs = f32(ffi.offsetof(o, "sym0")) |
355 | hdr.nsyms = f32(6) | 359 | hdr.nsyms = f32(6) |