Merge branch 'khorben/arch/eth'

This commit is contained in:
Pierre Pronchery 2018-09-10 05:48:29 +02:00
commit ff3f310ca0
9 changed files with 522 additions and 20 deletions

264
src/arch/eth.c Normal file
View File

@ -0,0 +1,264 @@
/* $Id$ */
/* Copyright (c) 2018 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stddef.h>
#include <System.h>
#include "Asm.h"
/* eth */
/* private */
/* variables */
static AsmArchDefinition const _eth_definition =
{
"flat", ASM_ARCH_ENDIAN_BIG, 8, 8, 0
};
#define REG(name, size, id, flags, description) \
{ "" # name, size, id, flags, description },
static AsmArchRegister const _eth_registers[] =
{
#include "null.reg"
};
#undef REG
static AsmArchInstruction const _eth_instructions[] =
{
#include "eth.ins"
#include "common.ins"
#include "null.ins"
};
typedef struct _AsmArchPlugin
{
AsmArchPluginHelper * helper;
} EthArchPlugin;
/* prototypes */
/* plug-in */
static EthArchPlugin * _eth_init(AsmArchPluginHelper * helper);
static void _eth_destroy(EthArchPlugin * plugin);
static int _eth_decode(EthArchPlugin * plugin,
AsmArchInstructionCall * call);
static int _eth_encode(EthArchPlugin * plugin,
AsmArchPrefix const * prefix,
AsmArchInstruction const * instruction,
AsmArchInstructionCall const * call);
/* protected */
/* variables */
AsmArchPluginDefinition arch_plugin =
{
"eth",
"Ethereum",
LICENSE_GNU_LGPL3_FLAGS,
&_eth_definition,
_eth_registers,
NULL,
_eth_instructions,
_eth_init,
_eth_destroy,
_eth_encode,
_eth_decode
};
/* functions */
/* plug-in */
/* eth_init */
static EthArchPlugin * _eth_init(AsmArchPluginHelper * helper)
{
EthArchPlugin * plugin;
if((plugin = object_new(sizeof(*plugin))) == NULL)
return NULL;
plugin->helper = helper;
return plugin;
}
/* eth_destroy */
static void _eth_destroy(EthArchPlugin * plugin)
{
object_delete(plugin);
}
/* eth_decode */
static int _eth_decode(EthArchPlugin * plugin,
AsmArchInstructionCall * call)
{
AsmArchPluginHelper * helper = plugin->helper;
uint8_t u8;
AsmArchInstruction const * ai;
if(helper->read(helper->arch, &u8, sizeof(u8)) != sizeof(u8))
return -1;
if((ai = helper->get_instruction_by_opcode(helper->arch, 8, u8))
== NULL)
return -1;
call->name = ai->name;
call->operands[0].definition = ai->op1;
call->operands[0].value.immediate.value = u8;
call->operands_cnt = 1;
return 0;
}
/* eth_encode */
static int _encode_immediate(AsmArchPlugin * plugin,
AsmArchOperand const * operand);
static int _encode_immediate8(AsmArchPlugin * plugin, uint8_t value);
static int _encode_immediate16(AsmArchPlugin * plugin, uint16_t value);
static int _encode_immediate24(AsmArchPlugin * plugin, uint32_t value);
static int _encode_immediate32(AsmArchPlugin * plugin, uint32_t value);
static int _encode_immediate40(AsmArchPlugin * plugin, uint64_t value);
static int _encode_immediate48(AsmArchPlugin * plugin, uint64_t value);
static int _encode_immediate56(AsmArchPlugin * plugin, uint64_t value);
static int _encode_immediate64(AsmArchPlugin * plugin, uint64_t value);
static int _eth_encode(EthArchPlugin * plugin,
AsmArchPrefix const * prefix,
AsmArchInstruction const * instruction,
AsmArchInstructionCall const * call)
{
AsmArchPluginHelper * helper = plugin->helper;
uint8_t opcode;
if(prefix != NULL)
return -error_set_code(1, "%s: %s",
helper->get_filename(helper->arch),
"Prefixes not supported for this architecture");
opcode = instruction->opcode;
if(helper->write(helper->arch, &opcode, sizeof(opcode))
!= sizeof(opcode))
return -1;
if(call->operands_cnt >= 1)
if(_encode_immediate(plugin, &call->operands[0]) != 0)
return -1;
return 0;
}
static int _encode_immediate(AsmArchPlugin * plugin,
AsmArchOperand const * operand)
{
uint64_t value = operand->value.immediate.value;
switch(AO_GET_SIZE(operand->definition) >> 3)
{
case 0:
return 0;
case sizeof(uint8_t):
return _encode_immediate8(plugin, value);
case sizeof(uint16_t):
return _encode_immediate16(plugin, value);
case 3:
return _encode_immediate24(plugin, value);
case sizeof(uint32_t):
return _encode_immediate32(plugin, value);
case 5:
return _encode_immediate40(plugin, value);
case 6:
return _encode_immediate48(plugin, value);
case 7:
return _encode_immediate56(plugin, value);
case sizeof(uint64_t):
return _encode_immediate64(plugin, value);
}
return -error_set_code(1, "%s", "Invalid size for immediate value");
}
static int _encode_immediate8(AsmArchPlugin * plugin, uint8_t value)
{
AsmArchPluginHelper * helper = plugin->helper;
if(helper->write(helper->arch, &value, sizeof(value)) != sizeof(value))
return -1;
return 0;
}
static int _encode_immediate16(AsmArchPlugin * plugin, uint16_t value)
{
AsmArchPluginHelper * helper = plugin->helper;
value = _htob16(value);
if(helper->write(helper->arch, &value, sizeof(value)) != sizeof(value))
return -1;
return 0;
}
static int _encode_immediate24(AsmArchPlugin * plugin, uint32_t value)
{
AsmArchPluginHelper * helper = plugin->helper;
value = _htob32(value) >> 8;
if(helper->write(helper->arch, &value, 3) != 3)
return -1;
return 0;
}
static int _encode_immediate32(AsmArchPlugin * plugin, uint32_t value)
{
AsmArchPluginHelper * helper = plugin->helper;
value = _htob32(value);
if(helper->write(helper->arch, &value, sizeof(value)) != sizeof(value))
return -1;
return 0;
}
static int _encode_immediate40(AsmArchPlugin * plugin, uint64_t value)
{
AsmArchPluginHelper * helper = plugin->helper;
value = _htob64(value) << 24;
if(helper->write(helper->arch, &value, 5) != 5)
return -1;
return 0;
}
static int _encode_immediate48(AsmArchPlugin * plugin, uint64_t value)
{
AsmArchPluginHelper * helper = plugin->helper;
value = _htob64(value) << 16;
if(helper->write(helper->arch, &value, 6) != 6)
return -1;
return 0;
}
static int _encode_immediate56(AsmArchPlugin * plugin, uint64_t value)
{
AsmArchPluginHelper * helper = plugin->helper;
value = _htob64(value) << 8;
if(helper->write(helper->arch, &value, 7) != 7)
return -1;
return 0;
}
static int _encode_immediate64(AsmArchPlugin * plugin, uint64_t value)
{
AsmArchPluginHelper * helper = plugin->helper;
value = _htob64(value);
if(helper->write(helper->arch, &value, sizeof(value)) != sizeof(value))
return -1;
return 0;
}

188
src/arch/eth.ins Normal file
View File

@ -0,0 +1,188 @@
/* $Id$ */
/* Copyright (c) 2018 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* helpers */
/* opcodes */
#define OP1F (8 << AOD_SIZE)
/* immediate values */
#define OP_U8 AO_IMMEDIATE(0, 8, 0)
#define OP_U16 AO_IMMEDIATE(0, 16, 0)
#define OP_U24 AO_IMMEDIATE(0, 24, 0)
#define OP_U32 AO_IMMEDIATE(0, 32, 0)
#define OP_U40 AO_IMMEDIATE(0, 40, 0)
#define OP_U48 AO_IMMEDIATE(0, 48, 0)
#define OP_U56 AO_IMMEDIATE(0, 56, 0)
#define OP_U64 AO_IMMEDIATE(0, 64, 0)
#define OP_U72 AO_IMMEDIATE(0, 72, 0)
#define OP_U80 AO_IMMEDIATE(0, 80, 0)
#define OP_U88 AO_IMMEDIATE(0, 88, 0)
#define OP_U96 AO_IMMEDIATE(0, 96, 0)
#define OP_U104 AO_IMMEDIATE(0, 104, 0)
#define OP_U112 AO_IMMEDIATE(0, 112, 0)
#define OP_U120 AO_IMMEDIATE(0, 120, 0)
#define OP_U128 AO_IMMEDIATE(0, 128, 0)
#define OP_U136 AO_IMMEDIATE(0, 136, 0)
#define OP_U144 AO_IMMEDIATE(0, 144, 0)
#define OP_U152 AO_IMMEDIATE(0, 152, 0)
#define OP_U160 AO_IMMEDIATE(0, 160, 0)
#define OP_U168 AO_IMMEDIATE(0, 168, 0)
#define OP_U176 AO_IMMEDIATE(0, 176, 0)
#define OP_U184 AO_IMMEDIATE(0, 184, 0)
#define OP_U192 AO_IMMEDIATE(0, 192, 0)
#define OP_U200 AO_IMMEDIATE(0, 200, 0)
#define OP_U208 AO_IMMEDIATE(0, 208, 0)
#define OP_U216 AO_IMMEDIATE(0, 216, 0)
#define OP_U224 AO_IMMEDIATE(0, 224, 0)
#define OP_U232 AO_IMMEDIATE(0, 232, 0)
#define OP_U240 AO_IMMEDIATE(0, 240, 0)
#define OP_U248 AO_IMMEDIATE(0, 248, 0)
#define OP_U256 AO_IMMEDIATE(0, 256, 0)
/* instructions */
{ "stop", 0x00, OP1F, AO_0() },
{ "add", 0x01, OP1F, AO_0() },
{ "mul", 0x02, OP1F, AO_0() },
{ "sub", 0x03, OP1F, AO_0() },
{ "div", 0x04, OP1F, AO_0() },
{ "sdiv", 0x05, OP1F, AO_0() },
{ "mod", 0x06, OP1F, AO_0() },
{ "smod", 0x07, OP1F, AO_0() },
{ "addmod", 0x08, OP1F, AO_0() },
{ "submod", 0x09, OP1F, AO_0() },
{ "exp", 0x0a, OP1F, AO_0() },
{ "signextend", 0x0b, OP1F, AO_0() },
{ "lt", 0x10, OP1F, AO_0() },
{ "gt", 0x11, OP1F, AO_0() },
{ "slt", 0x12, OP1F, AO_0() },
{ "sgt", 0x13, OP1F, AO_0() },
{ "eq", 0x14, OP1F, AO_0() },
{ "iszero", 0x15, OP1F, AO_0() },
{ "and", 0x16, OP1F, AO_0() },
{ "or", 0x17, OP1F, AO_0() },
{ "xor", 0x18, OP1F, AO_0() },
{ "not", 0x19, OP1F, AO_0() },
{ "byte", 0x1a, OP1F, AO_0() },
{ "address", 0x30, OP1F, AO_0() },
{ "origin", 0x32, OP1F, AO_0() },
{ "caller", 0x33, OP1F, AO_0() },
{ "callvalue", 0x34, OP1F, AO_0() },
{ "calldataload",0x35,OP1F, AO_0() },
{ "calldatasize",0x36,OP1F, AO_0() },
{ "calldatacopy",0x37,OP1F, AO_0() },
{ "callsize", 0x38, OP1F, AO_0() },
{ "callcopy", 0x39, OP1F, AO_0() },
{ "gasprice", 0x3a, OP1F, AO_0() },
{ "extcodesize",0x3b, OP1F, AO_0() },
{ "extcodecopy",0x3c, OP1F, AO_0() },
{ "blockhash", 0x40, OP1F, AO_0() },
{ "coinbase", 0x41, OP1F, AO_0() },
{ "timestamp", 0x42, OP1F, AO_0() },
{ "number", 0x43, OP1F, AO_0() },
{ "difficulty", 0x44, OP1F, AO_0() },
{ "gaslimit", 0x45, OP1F, AO_0() },
{ "pop", 0x50, OP1F, AO_0() },
{ "mload", 0x51, OP1F, AO_0() },
{ "mstore", 0x52, OP1F, AO_0() },
{ "mstore8", 0x53, OP1F, AO_0() },
{ "sload", 0x54, OP1F, AO_0() },
{ "sstore", 0x55, OP1F, AO_0() },
{ "jump", 0x56, OP1F, AO_0() },
{ "jumpi", 0x57, OP1F, AO_0() },
{ "pc", 0x58, OP1F, AO_0() },
{ "msize", 0x59, OP1F, AO_0() },
{ "gas", 0x5a, OP1F, AO_0() },
{ "jumpdest", 0x5b, OP1F, AO_0() },
{ "push1", 0x60, OP1F, AO_1(OP_U8) },
{ "push2", 0x61, OP1F, AO_1(OP_U16) },
{ "push3", 0x62, OP1F, AO_1(OP_U24) },
{ "push4", 0x63, OP1F, AO_1(OP_U32) },
{ "push5", 0x64, OP1F, AO_1(OP_U40) },
{ "push6", 0x65, OP1F, AO_1(OP_U48) },
{ "push7", 0x66, OP1F, AO_1(OP_U56) },
{ "push8", 0x67, OP1F, AO_1(OP_U64) },
{ "push9", 0x68, OP1F, AO_1(OP_U72) },
{ "push10", 0x69, OP1F, AO_1(OP_U80) },
{ "push11", 0x6a, OP1F, AO_1(OP_U88) },
{ "push12", 0x6b, OP1F, AO_1(OP_U96) },
{ "push13", 0x6c, OP1F, AO_1(OP_U104) },
{ "push14", 0x6d, OP1F, AO_1(OP_U112) },
{ "push15", 0x6e, OP1F, AO_1(OP_U120) },
{ "push16", 0x6f, OP1F, AO_1(OP_U128) },
{ "push17", 0x70, OP1F, AO_1(OP_U136) },
{ "push18", 0x71, OP1F, AO_1(OP_U144) },
{ "push19", 0x72, OP1F, AO_1(OP_U152) },
{ "push20", 0x73, OP1F, AO_1(OP_U160) },
{ "push21", 0x74, OP1F, AO_1(OP_U168) },
{ "push22", 0x75, OP1F, AO_1(OP_U176) },
{ "push23", 0x76, OP1F, AO_1(OP_U184) },
{ "push24", 0x77, OP1F, AO_1(OP_U192) },
{ "push25", 0x78, OP1F, AO_1(OP_U200) },
{ "push26", 0x79, OP1F, AO_1(OP_U208) },
{ "push27", 0x7a, OP1F, AO_1(OP_U216) },
{ "push28", 0x7b, OP1F, AO_1(OP_U224) },
{ "push29", 0x7c, OP1F, AO_1(OP_U232) },
{ "push30", 0x7d, OP1F, AO_1(OP_U240) },
{ "push31", 0x7e, OP1F, AO_1(OP_U248) },
{ "push32", 0x7f, OP1F, AO_1(OP_U256) },
{ "dup1", 0x80, OP1F, AO_0() },
{ "dup2", 0x81, OP1F, AO_0() },
{ "dup3", 0x82, OP1F, AO_0() },
{ "dup4", 0x83, OP1F, AO_0() },
{ "dup5", 0x84, OP1F, AO_0() },
{ "dup6", 0x85, OP1F, AO_0() },
{ "dup7", 0x86, OP1F, AO_0() },
{ "dup8", 0x87, OP1F, AO_0() },
{ "dup9", 0x88, OP1F, AO_0() },
{ "dup10", 0x89, OP1F, AO_0() },
{ "dup11", 0x8a, OP1F, AO_0() },
{ "dup12", 0x8b, OP1F, AO_0() },
{ "dup13", 0x8c, OP1F, AO_0() },
{ "dup14", 0x8d, OP1F, AO_0() },
{ "dup15", 0x8e, OP1F, AO_0() },
{ "dup16", 0x8f, OP1F, AO_0() },
{ "swap1", 0x90, OP1F, AO_0() },
{ "swap2", 0x91, OP1F, AO_0() },
{ "swap3", 0x92, OP1F, AO_0() },
{ "swap4", 0x93, OP1F, AO_0() },
{ "swap5", 0x94, OP1F, AO_0() },
{ "swap6", 0x95, OP1F, AO_0() },
{ "swap7", 0x96, OP1F, AO_0() },
{ "swap8", 0x97, OP1F, AO_0() },
{ "swap9", 0x98, OP1F, AO_0() },
{ "swap10", 0x99, OP1F, AO_0() },
{ "swap11", 0x9a, OP1F, AO_0() },
{ "swap12", 0x9b, OP1F, AO_0() },
{ "swap13", 0x9c, OP1F, AO_0() },
{ "swap14", 0x9d, OP1F, AO_0() },
{ "swap15", 0x9e, OP1F, AO_0() },
{ "swap16", 0x9f, OP1F, AO_0() },
{ "log0", 0xa0, OP1F, AO_0() },
{ "log1", 0xa1, OP1F, AO_0() },
{ "log2", 0xa2, OP1F, AO_0() },
{ "log3", 0xa3, OP1F, AO_0() },
{ "log4", 0xa4, OP1F, AO_0() },
{ "push", 0xb0, OP1F, AO_0() },
{ "dup", 0xb1, OP1F, AO_0() },
{ "swap", 0xb2, OP1F, AO_0() },
{ "create", 0xf0, OP1F, AO_0() },
{ "call", 0xf1, OP1F, AO_0() },
{ "callcode", 0xf2, OP1F, AO_0() },
{ "return", 0xf3, OP1F, AO_0() },
{ "delegatecall",0xf4,OP1F, AO_0() },
{ "selfdestruct",0xff,OP1F, AO_0() },

View File

@ -1,4 +1,4 @@
targets=amd64,arm,armeb,armel,dalvik,i386,i386_real,i486,i586,i686,java,mips,mipseb,mipsel,sparc,sparc64,template,yasep,yasep16,yasep32
targets=amd64,arm,armeb,armel,dalvik,eth,i386,i386_real,i486,i586,i686,java,mips,mipseb,mipsel,sparc,sparc64,template,yasep,yasep16,yasep32
cppflags_force=-I ../../include
cflags_force=`pkg-config --cflags libSystem` -fPIC
cflags=-W -Wall -g -O2 -D_FORTIFY_SOURCE=2 -fstack-protector
@ -45,6 +45,14 @@ install=$(LIBDIR)/Asm/arch
[dalvik.c]
depends=common.ins,dalvik.ins,dalvik.reg,null.ins
[eth]
type=plugin
sources=eth.c
install=$(LIBDIR)/Asm/arch
[eth.c]
depends=common.ins,eth.ins,null.ins
[i386]
type=plugin
sources=i386.c

8
tests/eth.asm Normal file
View File

@ -0,0 +1,8 @@
/* $Id$ */
.section .text
push1 $0x01 /* 60 01 */
push1 $0x00 /* 60 00 */
dup2 /* 81 */
swap1 /* 90 */
sstore /* 55 */
pop /* 50 */

View File

@ -1,4 +1,4 @@
targets=amd64.o,arm.o,armeb.o,armel.o,coverage.log,dalvik.o,fixme.log,i386.o,i386_real.o,i486.o,i586.o,i686.o,mips.o,mipseb.o,mipsel.o,java.o,pylint.log,sparc.o,sparc64.o,template.o,tests.log,yasep.o,yasep16.o,yasep32.o
targets=amd64.o,arm.o,armeb.o,armel.o,coverage.log,dalvik.o,eth.o,fixme.log,i386.o,i386_real.o,i486.o,i586.o,i686.o,mips.o,mipseb.o,mipsel.o,java.o,pylint.log,sparc.o,sparc64.o,template.o,tests.log,yasep.o,yasep16.o,yasep32.o
as=$(OBJDIR)../tools/asm-static
dist=Makefile,pylint.sh,python.sh,tests.sh
@ -48,6 +48,14 @@ sources=dalvik.asm
[dalvik.asm]
depends=$(OBJDIR)../tools/asm-static$(EXEEXT)
[eth.o]
type=object
asflags=-a eth
sources=eth.asm
[eth.asm]
depends=$(OBJDIR)../tools/asm-static$(EXEEXT)
[fixme.log]
type=script
script=./fixme.sh
@ -158,7 +166,7 @@ depends=$(OBJDIR)../tools/asm-static$(EXEEXT)
[tests.log]
type=script
script=./tests.sh -v
depends=$(OBJDIR)amd64.o,$(OBJDIR)arm.o,$(OBJDIR)armeb.o,$(OBJDIR)armel.o,$(OBJDIR)i386.o,$(OBJDIR)i386_real.o,$(OBJDIR)i486.o,$(OBJDIR)i586.o,$(OBJDIR)i686.o,python.sh,$(OBJDIR)sparc.o,$(OBJDIR)sparc64.o,tests.sh,$(OBJDIR)yasep.o,$(OBJDIR)yasep16.o,$(OBJDIR)yasep32.o,$(OBJDIR)../tools/asm-static$(EXEEXT),$(OBJDIR)../tools/deasm-static$(EXEEXT)
depends=$(OBJDIR)amd64.o,$(OBJDIR)arm.o,$(OBJDIR)armeb.o,$(OBJDIR)armel.o,$(OBJDIR)eth.o,$(OBJDIR)i386.o,$(OBJDIR)i386_real.o,$(OBJDIR)i486.o,$(OBJDIR)i586.o,$(OBJDIR)i686.o,python.sh,$(OBJDIR)sparc.o,$(OBJDIR)sparc64.o,tests.sh,$(OBJDIR)yasep.o,$(OBJDIR)yasep16.o,$(OBJDIR)yasep32.o,$(OBJDIR)../tools/asm-static$(EXEEXT),$(OBJDIR)../tools/deasm-static$(EXEEXT)
[yasep.o]
type=object

View File

@ -1,6 +1,6 @@
#!/bin/sh
#$Id$
#Copyright (c) 2012-2017 Pierre Pronchery <khorben@defora.org>
#Copyright (c) 2012-2018 Pierre Pronchery <khorben@defora.org>
#This file is part of DeforaOS Devel Asm
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
@ -169,6 +169,7 @@ echo "Expected failures:" 1>&2
for test in $failures; do
_fail "$test"
done
_fail _deasm eth
if [ -n "$FAILED" ]; then
echo "Failed tests:$FAILED" 1>&2
exit 2

View File

@ -26,6 +26,7 @@ extern AsmArchPluginDefinition arch_plugin_arm;
extern AsmArchPluginDefinition arch_plugin_armeb;
extern AsmArchPluginDefinition arch_plugin_armel;
extern AsmArchPluginDefinition arch_plugin_dalvik;
extern AsmArchPluginDefinition arch_plugin_eth;
extern AsmArchPluginDefinition arch_plugin_i386;
extern AsmArchPluginDefinition arch_plugin_i386_real;
extern AsmArchPluginDefinition arch_plugin_i486;
@ -53,6 +54,7 @@ static struct
{ "armeb", NULL },
{ "armel", NULL },
{ "dalvik", NULL },
{ "eth", NULL },
{ "i386", NULL },
{ "i386_real", NULL },
{ "i486", NULL },
@ -91,21 +93,22 @@ AsmArch * arch_new(char const * name)
_arch[2].definition = &arch_plugin_armeb;
_arch[3].definition = &arch_plugin_armel;
_arch[4].definition = &arch_plugin_dalvik;
_arch[5].definition = &arch_plugin_i386;
_arch[6].definition = &arch_plugin_i386_real;
_arch[7].definition = &arch_plugin_i486;
_arch[8].definition = &arch_plugin_i586;
_arch[9].definition = &arch_plugin_i686;
_arch[10].definition = &arch_plugin_java;
_arch[11].definition = &arch_plugin_mips;
_arch[12].definition = &arch_plugin_mipseb;
_arch[13].definition = &arch_plugin_mipsel;
_arch[14].definition = &arch_plugin_sparc;
_arch[15].definition = &arch_plugin_sparc64;
_arch[16].definition = &arch_plugin_template;
_arch[17].definition = &arch_plugin_yasep;
_arch[18].definition = &arch_plugin_yasep16;
_arch[19].definition = &arch_plugin_yasep32;
_arch[5].definition = &arch_plugin_eth;
_arch[6].definition = &arch_plugin_i386;
_arch[7].definition = &arch_plugin_i386_real;
_arch[8].definition = &arch_plugin_i486;
_arch[9].definition = &arch_plugin_i586;
_arch[10].definition = &arch_plugin_i686;
_arch[11].definition = &arch_plugin_java;
_arch[12].definition = &arch_plugin_mips;
_arch[13].definition = &arch_plugin_mipseb;
_arch[14].definition = &arch_plugin_mipsel;
_arch[15].definition = &arch_plugin_sparc;
_arch[16].definition = &arch_plugin_sparc64;
_arch[17].definition = &arch_plugin_template;
_arch[18].definition = &arch_plugin_yasep;
_arch[19].definition = &arch_plugin_yasep16;
_arch[20].definition = &arch_plugin_yasep32;
}
for(i = 0; i < sizeof(_arch) / sizeof(*_arch); i++)
if(strcmp(_arch[i].name, name) == 0)

19
tools/arch/eth.c Normal file
View File

@ -0,0 +1,19 @@
/* $Id$ */
/* Copyright (c) 2018 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#define arch_plugin arch_plugin_eth
#include "../src/arch/eth.c"

View File

@ -8,7 +8,7 @@ dist=Makefile
[libAsm]
type=library
sources=arch.c,arch/amd64.c,arch/arm.c,arch/armeb.c,arch/armel.c,arch/dalvik.c,arch/i386.c,arch/i386_real.c,arch/i486.c,arch/i586.c,arch/i686.c,arch/java.c,arch/mips.c,arch/mipseb.c,arch/mipsel.c,arch/sparc.c,arch/sparc64.c,arch/template.c,arch/yasep.c,arch/yasep16.c,arch/yasep32.c,format.c,format/dex.c,format/elf.c,format/elf/elf32.c,format/elf/elf64.c,format/flat.c,format/java.c,format/mbr.c,format/pe.c,asm.c,code.c,parser.c,token.c
sources=arch.c,arch/amd64.c,arch/arm.c,arch/armeb.c,arch/armel.c,arch/dalvik.c,arch/eth.c,arch/i386.c,arch/i386_real.c,arch/i486.c,arch/i586.c,arch/i686.c,arch/java.c,arch/mips.c,arch/mipseb.c,arch/mipsel.c,arch/sparc.c,arch/sparc64.c,arch/template.c,arch/yasep.c,arch/yasep16.c,arch/yasep32.c,format.c,format/dex.c,format/elf.c,format/elf/elf32.c,format/elf/elf64.c,format/flat.c,format/java.c,format/mbr.c,format/pe.c,asm.c,code.c,parser.c,token.c
cflags=-fPIC
[arch.c]
@ -17,6 +17,9 @@ depends=../src/arch.c
[arch/amd64.c]
depends=../src/arch/amd64.c,../src/arch/i386.c,../src/arch/i386.h,../src/arch/i486.c,../src/arch/i586.c,../src/arch/i686.c
[arch/eth.c]
depends=../src/arch/eth.c
[arch/i386.c]
depends=../src/arch/i386.c,../src/arch/i386.h