MIPS: Support generation of mips/mipsel bytecode object files.

This commit is contained in:
Mike Pall 2012-06-04 17:23:48 +02:00
parent 5032e6d87f
commit bd23a6c42f

View File

@ -63,6 +63,7 @@ local map_type = {
local map_arch = { local map_arch = {
x86 = true, x64 = true, arm = true, ppc = true, ppcspe = true, x86 = true, x64 = true, arm = true, ppc = true, ppcspe = true,
mips = true, mipsel = true,
} }
local map_os = { local map_os = {
@ -200,7 +201,7 @@ typedef struct {
local is64, isbe = false, false local is64, isbe = false, false
if ctx.arch == "x64" then if ctx.arch == "x64" then
is64 = true is64 = true
elseif ctx.arch == "ppc" or ctx.arch == "ppcspe" then elseif ctx.arch == "ppc" or ctx.arch == "ppcspe" or ctx.arch == "mips" then
isbe = true isbe = true
end end
@ -234,7 +235,10 @@ typedef struct {
hdr.eendian = isbe and 2 or 1 hdr.eendian = isbe and 2 or 1
hdr.eversion = 1 hdr.eversion = 1
hdr.type = f16(1) hdr.type = f16(1)
hdr.machine = f16(({ x86=3, x64=62, arm=40, ppc=20, ppcspe=20 })[ctx.arch]) hdr.machine = f16(({ x86=3, x64=62, arm=40, ppc=20, ppcspe=20, mips=8, mipsel=8 })[ctx.arch])
if ctx.arch == "mips" or ctx.arch == "mipsel" then
hdr.flags = 0x50001006
end
hdr.version = f32(1) hdr.version = f32(1)
hdr.shofs = fofs(ffi.offsetof(o, "sect")) hdr.shofs = fofs(ffi.offsetof(o, "sect"))
hdr.ehsize = f16(ffi.sizeof(hdr)) hdr.ehsize = f16(ffi.sizeof(hdr))
@ -349,7 +353,7 @@ typedef struct {
-- Create PE object and fill in header. -- Create PE object and fill in header.
local o = ffi.new("PEobj") local o = ffi.new("PEobj")
local hdr = o.hdr local hdr = o.hdr
hdr.arch = f16(({ x86=0x14c, x64=0x8664, arm=0x1c0, ppc=0x1f2 })[ctx.arch]) hdr.arch = f16(({ x86=0x14c, x64=0x8664, arm=0x1c0, ppc=0x1f2, mips=0x366, mipsel=0x366 })[ctx.arch])
hdr.nsects = f16(2) hdr.nsects = f16(2)
hdr.symtabofs = f32(ffi.offsetof(o, "sym0")) hdr.symtabofs = f32(ffi.offsetof(o, "sym0"))
hdr.nsyms = f32(6) hdr.nsyms = f32(6)