Renamed the "Arch" class to "AsmArch" to avoid potential future conflicts

This commit is contained in:
Pierre Pronchery 2012-05-19 12:39:21 +00:00
parent 4030d1c97b
commit 07bc3364b4
47 changed files with 552 additions and 541 deletions

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -25,26 +25,26 @@
/* AsmArch */ /* AsmArch */
/* types */ /* types */
typedef struct _Arch Arch; typedef struct _AsmArch AsmArch;
typedef enum _ArchEndian typedef enum _AsmArchEndian
{ {
ARCH_ENDIAN_BIG = 0x1, ASM_ARCH_ENDIAN_BIG = 0x1,
ARCH_ENDIAN_LITTLE = 0x2, ASM_ARCH_ENDIAN_LITTLE = 0x2,
ARCH_ENDIAN_BOTH = 0x3 ASM_ARCH_ENDIAN_BOTH = 0x3
} ArchEndian; } AsmArchEndian;
typedef struct _ArchDescription typedef struct _AsmArchDescription
{ {
char const * format; /* default format plug-in */ char const * format; /* default format plug-in */
ArchEndian endian; AsmArchEndian endian;
uint32_t address_size; uint32_t address_size;
uint32_t alignment; uint32_t alignment;
uint32_t instruction_size; /* 0 if not constant */ uint32_t instruction_size; /* 0 if not constant */
} ArchDescription; } AsmArchDescription;
/* operands */ /* operands */
typedef enum _ArchOperandType typedef enum _AsmArchOperandType
{ {
AOT_NONE = 0x0, AOT_NONE = 0x0,
AOT_CONSTANT = 0x1, /* flags | 0 | size | value */ AOT_CONSTANT = 0x1, /* flags | 0 | size | value */
@ -52,7 +52,7 @@ typedef enum _ArchOperandType
AOT_REGISTER = 0x3, /* flags | 0 | size | id */ AOT_REGISTER = 0x3, /* flags | 0 | size | id */
AOT_DREGISTER = 0x4, /* flags | dsize | rsize | id */ AOT_DREGISTER = 0x4, /* flags | dsize | rsize | id */
AOT_DREGISTER2 = 0x5 /* flags | did | rsize | id */ AOT_DREGISTER2 = 0x5 /* flags | did | rsize | id */
} ArchOperandType; } AsmArchOperandType;
/* displacement */ /* displacement */
# define AOD_FLAGS 24 # define AOD_FLAGS 24
@ -122,11 +122,11 @@ typedef enum _ArchOperandType
| ((dsize) << AOD_SIZE) \ | ((dsize) << AOD_SIZE) \
| ((id) << AOD_VALUE)) | ((id) << AOD_VALUE))
typedef uint32_t ArchOperandDefinition; typedef uint32_t AsmArchOperandDefinition;
typedef struct _ArchOperand typedef struct _AsmArchOperand
{ {
ArchOperandDefinition definition; AsmArchOperandDefinition definition;
union union
{ {
/* AOT_DREGISTER */ /* AOT_DREGISTER */
@ -158,81 +158,81 @@ typedef struct _ArchOperand
} _register; } _register;
/* FIXME complete */ /* FIXME complete */
} value; } value;
} ArchOperand; } AsmArchOperand;
typedef struct _ArchInstruction typedef struct _AsmArchInstruction
{ {
char const * name; char const * name;
uint32_t opcode; uint32_t opcode;
ArchOperandDefinition flags; AsmArchOperandDefinition flags;
ArchOperandDefinition op1; AsmArchOperandDefinition op1;
ArchOperandDefinition op2; AsmArchOperandDefinition op2;
ArchOperandDefinition op3; AsmArchOperandDefinition op3;
ArchOperandDefinition op4; AsmArchOperandDefinition op4;
ArchOperandDefinition op5; AsmArchOperandDefinition op5;
} ArchInstruction; } AsmArchInstruction;
typedef struct _ArchInstructionCall typedef struct _AsmArchInstructionCall
{ {
char const * name; char const * name;
ArchOperand operands[5]; AsmArchOperand operands[5];
uint32_t operands_cnt; uint32_t operands_cnt;
/* meta information */ /* meta information */
off_t base; off_t base;
size_t offset; size_t offset;
size_t size; size_t size;
} ArchInstructionCall; } AsmArchInstructionCall;
typedef struct _ArchRegister typedef struct _AsmArchRegister
{ {
char const * name; char const * name;
uint32_t size; uint32_t size;
uint32_t id; uint32_t id;
} ArchRegister; } AsmArchRegister;
typedef struct _ArchPluginHelper typedef struct _AsmArchPluginHelper
{ {
Arch * arch; AsmArch * arch;
/* callbacks */ /* callbacks */
/* accessors */ /* accessors */
char const * (*get_filename)(Arch * arch); char const * (*get_filename)(AsmArch * arch);
AsmFunction * (*get_function_by_id)(Arch * arch, AsmFunctionId id); AsmFunction * (*get_function_by_id)(AsmArch * arch, AsmFunctionId id);
ArchInstruction * (*get_instruction_by_opcode)(Arch * arch, AsmArchInstruction * (*get_instruction_by_opcode)(AsmArch * arch,
uint8_t size, uint32_t opcode); uint8_t size, uint32_t opcode);
ArchRegister * (*get_register_by_id_size)(Arch * arch, uint32_t id, AsmArchRegister * (*get_register_by_id_size)(AsmArch * arch, uint32_t id,
uint32_t size); uint32_t size);
ArchRegister * (*get_register_by_name_size)(Arch * arch, AsmArchRegister * (*get_register_by_name_size)(AsmArch * arch,
char const * name, uint32_t size); char const * name, uint32_t size);
AsmString * (*get_string_by_id)(Arch * arch, AsmStringId id); AsmString * (*get_string_by_id)(AsmArch * arch, AsmStringId id);
/* assembly */ /* assembly */
ssize_t (*write)(Arch * arch, void const * buf, size_t size); ssize_t (*write)(AsmArch * arch, void const * buf, size_t size);
/* disassembly */ /* disassembly */
ssize_t (*peek)(Arch * arch, void * buf, size_t size); ssize_t (*peek)(AsmArch * arch, void * buf, size_t size);
ssize_t (*read)(Arch * arch, void * buf, size_t size); ssize_t (*read)(AsmArch * arch, void * buf, size_t size);
off_t (*seek)(Arch * arch, off_t offset, int whence); off_t (*seek)(AsmArch * arch, off_t offset, int whence);
} ArchPluginHelper; } AsmArchPluginHelper;
typedef struct _ArchPlugin ArchPlugin; typedef struct _AsmArchPlugin AsmArchPlugin;
struct _ArchPlugin struct _AsmArchPlugin
{ {
ArchPluginHelper * helper; AsmArchPluginHelper * helper;
char const * name; char const * name;
ArchDescription * description; AsmArchDescription * description;
ArchRegister * registers; AsmArchRegister * registers;
ArchInstruction * instructions; AsmArchInstruction * instructions;
int (*init)(ArchPlugin * arch); int (*init)(AsmArchPlugin * arch);
void (*exit)(ArchPlugin * arch); void (*exit)(AsmArchPlugin * arch);
int (*encode)(ArchPlugin * arch, ArchInstruction * instruction, int (*encode)(AsmArchPlugin * arch, AsmArchInstruction * instruction,
ArchInstructionCall * call); AsmArchInstructionCall * call);
int (*decode)(ArchPlugin * arch, ArchInstructionCall * call); int (*decode)(AsmArchPlugin * arch, AsmArchInstructionCall * call);
}; };
#endif /* !DEVEL_ASM_ARCH_H */ #endif /* !DEVEL_ASM_ARCH_H */

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -71,7 +71,7 @@ int asm_instruction(Asm * a, char const * name, unsigned int operands_cnt, ...);
/* deassemble */ /* deassemble */
AsmCode * asm_deassemble(Asm * a, char const * buffer, size_t size, AsmCode * asm_deassemble(Asm * a, char const * buffer, size_t size,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
AsmCode * asm_open_deassemble(Asm * a, char const * filename, int raw); AsmCode * asm_open_deassemble(Asm * a, char const * filename, int raw);
/* plug-in helpers */ /* plug-in helpers */

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -31,7 +31,7 @@ typedef struct _AsmCode AsmCode;
/* functions */ /* functions */
/* accessors */ /* accessors */
char const * asmcode_get_arch(AsmCode * code); char const * asmcode_get_arch(AsmCode * code);
ArchDescription * asmcode_get_arch_description(AsmCode * code); AsmArchDescription * asmcode_get_arch_description(AsmCode * code);
char const * asmcode_get_filename(AsmCode * code); char const * asmcode_get_filename(AsmCode * code);
char const * asmcode_get_format(AsmCode * code); char const * asmcode_get_format(AsmCode * code);
@ -62,17 +62,17 @@ void asmcode_get_strings(AsmCode * code, AsmString ** strings,
/* useful */ /* useful */
/* assembly */ /* assembly */
int asmcode_function(AsmCode * code, char const * function); int asmcode_function(AsmCode * code, char const * function);
int asmcode_instruction(AsmCode * code, ArchInstructionCall * call); int asmcode_instruction(AsmCode * code, AsmArchInstructionCall * call);
int asmcode_section(AsmCode * code, char const * section); int asmcode_section(AsmCode * code, char const * section);
/* deassembly */ /* deassembly */
int asmcode_decode(AsmCode * code, int raw); int asmcode_decode(AsmCode * code, int raw);
int asmcode_decode_at(AsmCode * code, off_t offset, size_t size, off_t base, int asmcode_decode_at(AsmCode * code, off_t offset, size_t size, off_t base,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
int asmcode_decode_buffer(AsmCode * code, char const * buffer, size_t size, int asmcode_decode_buffer(AsmCode * code, char const * buffer, size_t size,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
int asmcode_decode_section(AsmCode * code, AsmSection * section, int asmcode_decode_section(AsmCode * code, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
int asmcode_print(AsmCode * code, ArchInstructionCall * call); int asmcode_print(AsmCode * code, AsmArchInstructionCall * call);
#endif /* !DEVEL_ASM_CODE_H */ #endif /* !DEVEL_ASM_CODE_H */

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -56,7 +56,7 @@ typedef struct _FormatPluginHelper
int (*set_string)(Format * format, int id, char const * name, int (*set_string)(Format * format, int id, char const * name,
off_t offset, ssize_t size); off_t offset, ssize_t size);
int (*decode)(Format * format, off_t offset, size_t size, off_t base, int (*decode)(Format * format, off_t offset, size_t size, off_t base,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
} FormatPluginHelper; } FormatPluginHelper;
struct _FormatPlugin struct _FormatPlugin
@ -76,7 +76,7 @@ struct _FormatPlugin
char const * (*detect)(FormatPlugin * format); char const * (*detect)(FormatPlugin * format);
int (*decode)(FormatPlugin * format, int raw); int (*decode)(FormatPlugin * format, int raw);
int (*decode_section)(FormatPlugin * format, AsmSection * section, int (*decode_section)(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
void * priv; void * priv;
}; };

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -34,14 +34,14 @@
#endif #endif
/* Arch */ /* AsmArch */
/* private */ /* private */
/* types */ /* types */
struct _Arch struct _AsmArch
{ {
ArchPluginHelper helper; AsmArchPluginHelper helper;
Plugin * handle; Plugin * handle;
ArchPlugin * plugin; AsmArchPlugin * plugin;
size_t instructions_cnt; size_t instructions_cnt;
size_t registers_cnt; size_t registers_cnt;
@ -58,26 +58,26 @@ struct _Arch
/* prototypes */ /* prototypes */
/* callbacks */ /* callbacks */
static char const * _arch_get_filename(Arch * arch); static char const * _arch_get_filename(AsmArch * arch);
static AsmFunction * _arch_get_function_by_id(Arch * arch, AsmFunctionId id); static AsmFunction * _arch_get_function_by_id(AsmArch * arch, AsmFunctionId id);
static AsmString * _arch_get_string_by_id(Arch * arch, AsmStringId id); static AsmString * _arch_get_string_by_id(AsmArch * arch, AsmStringId id);
static ssize_t _arch_peek(Arch * arch, void * buf, size_t size); static ssize_t _arch_peek(AsmArch * arch, void * buf, size_t size);
static ssize_t _arch_read(Arch * arch, void * buf, size_t size); static ssize_t _arch_read(AsmArch * arch, void * buf, size_t size);
static ssize_t _arch_peek_buffer(Arch * arch, void * buf, size_t size); static ssize_t _arch_peek_buffer(AsmArch * arch, void * buf, size_t size);
static ssize_t _arch_read_buffer(Arch * arch, void * buf, size_t size); static ssize_t _arch_read_buffer(AsmArch * arch, void * buf, size_t size);
static off_t _arch_seek(Arch * arch, off_t offset, int whence); static off_t _arch_seek(AsmArch * arch, off_t offset, int whence);
static off_t _arch_seek_buffer(Arch * arch, off_t offset, int whence); static off_t _arch_seek_buffer(AsmArch * arch, off_t offset, int whence);
static ssize_t _arch_write(Arch * arch, void const * buf, size_t size); static ssize_t _arch_write(AsmArch * arch, void const * buf, size_t size);
/* public */ /* public */
/* functions */ /* functions */
/* arch_new */ /* arch_new */
Arch * arch_new(char const * name) AsmArch * arch_new(char const * name)
{ {
Arch * a; AsmArch * a;
Plugin * handle; Plugin * handle;
ArchPlugin * plugin; AsmArchPlugin * plugin;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, name); fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, name);
@ -116,7 +116,7 @@ Arch * arch_new(char const * name)
/* arch_delete */ /* arch_delete */
void arch_delete(Arch * arch) void arch_delete(AsmArch * arch)
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s()\n", __func__); fprintf(stderr, "DEBUG: %s()\n", __func__);
@ -128,21 +128,21 @@ void arch_delete(Arch * arch)
/* accessors */ /* accessors */
/* arch_can_decode */ /* arch_can_decode */
int arch_can_decode(Arch * arch) int arch_can_decode(AsmArch * arch)
{ {
return arch->plugin->decode != NULL; return arch->plugin->decode != NULL;
} }
/* arch_get_description */ /* arch_get_description */
ArchDescription * arch_get_description(Arch * arch) AsmArchDescription * arch_get_description(AsmArch * arch)
{ {
return arch->plugin->description; return arch->plugin->description;
} }
/* arch_get_format */ /* arch_get_format */
char const * arch_get_format(Arch * arch) char const * arch_get_format(AsmArch * arch)
{ {
if(arch->plugin->description != NULL if(arch->plugin->description != NULL
&& arch->plugin->description->format != NULL) && arch->plugin->description->format != NULL)
@ -152,7 +152,7 @@ char const * arch_get_format(Arch * arch)
/* arch_get_instruction */ /* arch_get_instruction */
ArchInstruction * arch_get_instruction(Arch * arch, size_t index) AsmArchInstruction * arch_get_instruction(AsmArch * arch, size_t index)
{ {
if(index >= arch->instructions_cnt) if(index >= arch->instructions_cnt)
return NULL; return NULL;
@ -161,7 +161,7 @@ ArchInstruction * arch_get_instruction(Arch * arch, size_t index)
/* arch_get_instruction_by_name */ /* arch_get_instruction_by_name */
ArchInstruction * arch_get_instruction_by_name(Arch * arch, char const * name) AsmArchInstruction * arch_get_instruction_by_name(AsmArch * arch, char const * name)
{ {
size_t i; size_t i;
@ -176,11 +176,11 @@ ArchInstruction * arch_get_instruction_by_name(Arch * arch, char const * name)
/* arch_get_instruction_by_opcode */ /* arch_get_instruction_by_opcode */
ArchInstruction * arch_get_instruction_by_opcode(Arch * arch, uint8_t size, AsmArchInstruction * arch_get_instruction_by_opcode(AsmArch * arch, uint8_t size,
uint32_t opcode) uint32_t opcode)
{ {
size_t i; size_t i;
ArchInstruction * ai; AsmArchInstruction * ai;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s(arch, %u, 0x%x)\n", __func__, size, opcode); fprintf(stderr, "DEBUG: %s(arch, %u, 0x%x)\n", __func__, size, opcode);
@ -198,22 +198,22 @@ ArchInstruction * arch_get_instruction_by_opcode(Arch * arch, uint8_t size,
/* arch_get_instruction_by_call */ /* arch_get_instruction_by_call */
static int _call_operands(Arch * arch, ArchInstruction * instruction, static int _call_operands(AsmArch * arch, AsmArchInstruction * instruction,
ArchInstructionCall * call); AsmArchInstructionCall * call);
static int _call_operands_constant(ArchOperandDefinition definition, static int _call_operands_constant(AsmArchOperandDefinition definition,
ArchOperand * operand); AsmArchOperand * operand);
static int _call_operands_dregister(Arch * arch, static int _call_operands_dregister(AsmArch * arch,
ArchOperandDefinition definition, ArchOperand * operand); AsmArchOperandDefinition definition, AsmArchOperand * operand);
static int _call_operands_immediate(ArchOperandDefinition definition, static int _call_operands_immediate(AsmArchOperandDefinition definition,
ArchOperand * operand); AsmArchOperand * operand);
static int _call_operands_register(Arch * arch, static int _call_operands_register(AsmArch * arch,
ArchOperandDefinition definition, ArchOperand * operand); AsmArchOperandDefinition definition, AsmArchOperand * operand);
ArchInstruction * arch_get_instruction_by_call(Arch * arch, AsmArchInstruction * arch_get_instruction_by_call(AsmArch * arch,
ArchInstructionCall * call) AsmArchInstructionCall * call)
{ {
size_t i; size_t i;
ArchInstruction * ai; AsmArchInstruction * ai;
int found = 0; int found = 0;
#ifdef DEBUG #ifdef DEBUG
@ -234,12 +234,12 @@ ArchInstruction * arch_get_instruction_by_call(Arch * arch,
return NULL; return NULL;
} }
static int _call_operands(Arch * arch, ArchInstruction * instruction, static int _call_operands(AsmArch * arch, AsmArchInstruction * instruction,
ArchInstructionCall * call) AsmArchInstructionCall * call)
{ {
size_t i; size_t i;
ArchOperandDefinition definition; AsmArchOperandDefinition definition;
ArchOperand * operand; AsmArchOperand * operand;
if(call->operands_cnt == 0 && AO_GET_TYPE(instruction->op1) != AOT_NONE) if(call->operands_cnt == 0 && AO_GET_TYPE(instruction->op1) != AOT_NONE)
return -1; return -1;
@ -296,8 +296,8 @@ static int _call_operands(Arch * arch, ArchInstruction * instruction,
return 0; return 0;
} }
static int _call_operands_constant(ArchOperandDefinition definition, static int _call_operands_constant(AsmArchOperandDefinition definition,
ArchOperand * operand) AsmArchOperand * operand)
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s() %u %lu\n", __func__, fprintf(stderr, "DEBUG: %s() %u %lu\n", __func__,
@ -312,8 +312,8 @@ static int _call_operands_constant(ArchOperandDefinition definition,
return 0; return 0;
} }
static int _call_operands_dregister(Arch * arch, static int _call_operands_dregister(AsmArch * arch,
ArchOperandDefinition definition, ArchOperand * operand) AsmArchOperandDefinition definition, AsmArchOperand * operand)
{ {
uint64_t offset; uint64_t offset;
@ -334,8 +334,8 @@ static int _call_operands_dregister(Arch * arch,
return 0; return 0;
} }
static int _call_operands_immediate(ArchOperandDefinition definition, static int _call_operands_immediate(AsmArchOperandDefinition definition,
ArchOperand * operand) AsmArchOperand * operand)
{ {
uint64_t value; uint64_t value;
uint32_t size; uint32_t size;
@ -359,13 +359,13 @@ static int _call_operands_immediate(ArchOperandDefinition definition,
return 0; return 0;
} }
static int _call_operands_register(Arch * arch, static int _call_operands_register(AsmArch * arch,
ArchOperandDefinition definition, ArchOperand * operand) AsmArchOperandDefinition definition, AsmArchOperand * operand)
{ {
char const * name = operand->value._register.name; char const * name = operand->value._register.name;
ArchDescription * desc; AsmArchDescription * desc;
uint32_t size; uint32_t size;
ArchRegister * ar; AsmArchRegister * ar;
/* obtain the size */ /* obtain the size */
if((desc = arch->plugin->description) != NULL if((desc = arch->plugin->description) != NULL
@ -385,14 +385,14 @@ static int _call_operands_register(Arch * arch,
/* arch_get_name */ /* arch_get_name */
char const * arch_get_name(Arch * arch) char const * arch_get_name(AsmArch * arch)
{ {
return arch->plugin->name; return arch->plugin->name;
} }
/* arch_get_register */ /* arch_get_register */
ArchRegister * arch_get_register(Arch * arch, size_t index) AsmArchRegister * arch_get_register(AsmArch * arch, size_t index)
{ {
if(index >= arch->registers_cnt) if(index >= arch->registers_cnt)
return NULL; return NULL;
@ -401,7 +401,7 @@ ArchRegister * arch_get_register(Arch * arch, size_t index)
/* arch_get_register_by_id_size */ /* arch_get_register_by_id_size */
ArchRegister * arch_get_register_by_id_size(Arch * arch, uint32_t id, AsmArchRegister * arch_get_register_by_id_size(AsmArch * arch, uint32_t id,
uint32_t size) uint32_t size)
{ {
size_t i; size_t i;
@ -418,7 +418,7 @@ ArchRegister * arch_get_register_by_id_size(Arch * arch, uint32_t id,
/* arch_get_register_by_name */ /* arch_get_register_by_name */
ArchRegister * arch_get_register_by_name(Arch * arch, char const * name) AsmArchRegister * arch_get_register_by_name(AsmArch * arch, char const * name)
{ {
size_t i; size_t i;
@ -433,7 +433,7 @@ ArchRegister * arch_get_register_by_name(Arch * arch, char const * name)
/* arch_get_register_by_name_size */ /* arch_get_register_by_name_size */
ArchRegister * arch_get_register_by_name_size(Arch * arch, char const * name, AsmArchRegister * arch_get_register_by_name_size(AsmArch * arch, char const * name,
uint32_t size) uint32_t size)
{ {
size_t i; size_t i;
@ -452,13 +452,13 @@ ArchRegister * arch_get_register_by_name_size(Arch * arch, char const * name,
/* useful */ /* useful */
/* arch_decode */ /* arch_decode */
int arch_decode(Arch * arch, AsmCode * code, off_t base, int arch_decode(AsmArch * arch, AsmCode * code, off_t base,
ArchInstructionCall ** calls, size_t * calls_cnt) AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
int ret = 0; int ret = 0;
ArchInstructionCall * c = *calls; AsmArchInstructionCall * c = *calls;
size_t c_cnt = *calls_cnt; size_t c_cnt = *calls_cnt;
ArchInstructionCall * p; AsmArchInstructionCall * p;
size_t offset = 0; size_t offset = 0;
#ifdef DEBUG #ifdef DEBUG
@ -495,8 +495,8 @@ int arch_decode(Arch * arch, AsmCode * code, off_t base,
/* arch_decode_at */ /* arch_decode_at */
int arch_decode_at(Arch * arch, AsmCode * code, off_t offset, size_t size, int arch_decode_at(AsmArch * arch, AsmCode * code, off_t offset, size_t size,
off_t base, ArchInstructionCall ** calls, size_t * calls_cnt) off_t base, AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
int ret; int ret;
@ -525,8 +525,8 @@ int arch_decode_at(Arch * arch, AsmCode * code, off_t offset, size_t size,
/* arch_encode */ /* arch_encode */
int arch_encode(Arch * arch, ArchInstruction * instruction, int arch_encode(AsmArch * arch, AsmArchInstruction * instruction,
ArchInstructionCall * call) AsmArchInstructionCall * call)
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, instruction->name); fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, instruction->name);
@ -536,7 +536,7 @@ int arch_encode(Arch * arch, ArchInstruction * instruction,
/* arch_exit */ /* arch_exit */
int arch_exit(Arch * arch) int arch_exit(AsmArch * arch)
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s()\n", __func__); fprintf(stderr, "DEBUG: %s()\n", __func__);
@ -553,7 +553,7 @@ int arch_exit(Arch * arch)
/* arch_init */ /* arch_init */
int arch_init(Arch * arch, char const * filename, FILE * fp) int arch_init(AsmArch * arch, char const * filename, FILE * fp)
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s(\"%s\", %p)\n", __func__, filename, fprintf(stderr, "DEBUG: %s(\"%s\", %p)\n", __func__, filename,
@ -586,7 +586,7 @@ int arch_init(Arch * arch, char const * filename, FILE * fp)
/* arch_init */ /* arch_init */
int arch_init_buffer(Arch * arch, char const * buffer, size_t size) int arch_init_buffer(AsmArch * arch, char const * buffer, size_t size)
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s()\n", __func__); fprintf(stderr, "DEBUG: %s()\n", __func__);
@ -618,7 +618,7 @@ int arch_init_buffer(Arch * arch, char const * buffer, size_t size)
/* arch_read */ /* arch_read */
ssize_t arch_read(Arch * arch, void * buf, size_t size) ssize_t arch_read(AsmArch * arch, void * buf, size_t size)
{ {
if(arch->helper.read == NULL) if(arch->helper.read == NULL)
return -error_set_code(1, "%s", "read: No helper defined"); return -error_set_code(1, "%s", "read: No helper defined");
@ -627,7 +627,7 @@ ssize_t arch_read(Arch * arch, void * buf, size_t size)
/* arch_seek */ /* arch_seek */
off_t arch_seek(Arch * arch, off_t offset, int whence) off_t arch_seek(AsmArch * arch, off_t offset, int whence)
{ {
if(arch->helper.seek == NULL) if(arch->helper.seek == NULL)
return -error_set_code(1, "%s", "seek: No helper defined"); return -error_set_code(1, "%s", "seek: No helper defined");
@ -638,28 +638,28 @@ off_t arch_seek(Arch * arch, off_t offset, int whence)
/* private */ /* private */
/* callbacks */ /* callbacks */
/* arch_get_filename */ /* arch_get_filename */
static char const * _arch_get_filename(Arch * arch) static char const * _arch_get_filename(AsmArch * arch)
{ {
return arch->filename; return arch->filename;
} }
/* arch_get_function_by_id */ /* arch_get_function_by_id */
static AsmFunction * _arch_get_function_by_id(Arch * arch, AsmFunctionId id) static AsmFunction * _arch_get_function_by_id(AsmArch * arch, AsmFunctionId id)
{ {
return asmcode_get_function_by_id(arch->code, id); return asmcode_get_function_by_id(arch->code, id);
} }
/* arch_get_string_by_id */ /* arch_get_string_by_id */
static AsmString * _arch_get_string_by_id(Arch * arch, AsmStringId id) static AsmString * _arch_get_string_by_id(AsmArch * arch, AsmStringId id)
{ {
return asmcode_get_string_by_id(arch->code, id); return asmcode_get_string_by_id(arch->code, id);
} }
/* arch_peek */ /* arch_peek */
static ssize_t _arch_peek(Arch * arch, void * buf, size_t size) static ssize_t _arch_peek(AsmArch * arch, void * buf, size_t size)
{ {
ssize_t s; ssize_t s;
@ -675,7 +675,7 @@ static ssize_t _arch_peek(Arch * arch, void * buf, size_t size)
/* arch_peek_buffer */ /* arch_peek_buffer */
static ssize_t _arch_peek_buffer(Arch * arch, void * buf, size_t size) static ssize_t _arch_peek_buffer(AsmArch * arch, void * buf, size_t size)
{ {
ssize_t s; ssize_t s;
@ -688,7 +688,7 @@ static ssize_t _arch_peek_buffer(Arch * arch, void * buf, size_t size)
/* arch_read */ /* arch_read */
static ssize_t _arch_read(Arch * arch, void * buf, size_t size) static ssize_t _arch_read(AsmArch * arch, void * buf, size_t size)
{ {
size_t s = min(arch->buffer_cnt - arch->buffer_pos, size); size_t s = min(arch->buffer_cnt - arch->buffer_pos, size);
@ -708,7 +708,7 @@ static ssize_t _arch_read(Arch * arch, void * buf, size_t size)
/* arch_read_buffer */ /* arch_read_buffer */
static ssize_t _arch_read_buffer(Arch * arch, void * buf, size_t size) static ssize_t _arch_read_buffer(AsmArch * arch, void * buf, size_t size)
{ {
ssize_t s = min(arch->buffer_cnt - arch->buffer_pos, size); ssize_t s = min(arch->buffer_cnt - arch->buffer_pos, size);
@ -724,7 +724,7 @@ static ssize_t _arch_read_buffer(Arch * arch, void * buf, size_t size)
/* arch_seek */ /* arch_seek */
static off_t _arch_seek(Arch * arch, off_t offset, int whence) static off_t _arch_seek(AsmArch * arch, off_t offset, int whence)
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s(arch, %ld, %d)\n", __func__, offset, whence); fprintf(stderr, "DEBUG: %s(arch, %ld, %d)\n", __func__, offset, whence);
@ -738,7 +738,7 @@ static off_t _arch_seek(Arch * arch, off_t offset, int whence)
/* arch_seek_buffer */ /* arch_seek_buffer */
static off_t _arch_seek_buffer(Arch * arch, off_t offset, int whence) static off_t _arch_seek_buffer(AsmArch * arch, off_t offset, int whence)
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s(arch, %ld, %d)\n", __func__, offset, whence); fprintf(stderr, "DEBUG: %s(arch, %ld, %d)\n", __func__, offset, whence);
@ -766,7 +766,7 @@ static off_t _arch_seek_buffer(Arch * arch, off_t offset, int whence)
/* arch_write */ /* arch_write */
static ssize_t _arch_write(Arch * arch, void const * buf, size_t size) static ssize_t _arch_write(AsmArch * arch, void const * buf, size_t size)
{ {
if(fwrite(buf, size, 1, arch->fp) == 1) if(fwrite(buf, size, 1, arch->fp) == 1)
return size; return size;

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -24,49 +24,49 @@
# include "code.h" # include "code.h"
/* Arch */ /* AsmArch */
/* public */ /* public */
/* functions */ /* functions */
Arch * arch_new(char const * name); AsmArch * arch_new(char const * name);
void arch_delete(Arch * arch); void arch_delete(AsmArch * arch);
/* accessors */ /* accessors */
int arch_can_decode(Arch * arch); int arch_can_decode(AsmArch * arch);
ArchDescription * arch_get_description(Arch * arch); AsmArchDescription * arch_get_description(AsmArch * arch);
char const * arch_get_format(Arch * arch); char const * arch_get_format(AsmArch * arch);
char const * arch_get_name(Arch * arch); char const * arch_get_name(AsmArch * arch);
ArchInstruction * arch_get_instruction(Arch * arch, size_t index); AsmArchInstruction * arch_get_instruction(AsmArch * arch, size_t index);
ArchInstruction * arch_get_instruction_by_name(Arch * arch, char const * name); AsmArchInstruction * arch_get_instruction_by_name(AsmArch * arch, char const * name);
ArchInstruction * arch_get_instruction_by_opcode(Arch * arch, uint8_t size, AsmArchInstruction * arch_get_instruction_by_opcode(AsmArch * arch, uint8_t size,
uint32_t opcode); uint32_t opcode);
ArchInstruction * arch_get_instruction_by_call(Arch * arch, AsmArchInstruction * arch_get_instruction_by_call(AsmArch * arch,
ArchInstructionCall * call); AsmArchInstructionCall * call);
ArchRegister * arch_get_register(Arch * arch, size_t index); AsmArchRegister * arch_get_register(AsmArch * arch, size_t index);
ArchRegister * arch_get_register_by_id_size(Arch * arch, uint32_t id, AsmArchRegister * arch_get_register_by_id_size(AsmArch * arch, uint32_t id,
uint32_t size); uint32_t size);
ArchRegister * arch_get_register_by_name(Arch * arch, char const * name); AsmArchRegister * arch_get_register_by_name(AsmArch * arch, char const * name);
ArchRegister * arch_get_register_by_name_size(Arch * arch, char const * name, AsmArchRegister * arch_get_register_by_name_size(AsmArch * arch, char const * name,
uint32_t size); uint32_t size);
/* useful */ /* useful */
int arch_init(Arch * arch, char const * filename, FILE * fp); int arch_init(AsmArch * arch, char const * filename, FILE * fp);
int arch_init_buffer(Arch * arch, char const * buffer, size_t size); int arch_init_buffer(AsmArch * arch, char const * buffer, size_t size);
int arch_exit(Arch * arch); int arch_exit(AsmArch * arch);
/* assembly */ /* assembly */
int arch_encode(Arch * arch, ArchInstruction * instruction, int arch_encode(AsmArch * arch, AsmArchInstruction * instruction,
ArchInstructionCall * call); AsmArchInstructionCall * call);
/* deassembly */ /* deassembly */
int arch_decode(Arch * arch, AsmCode * code, off_t base, int arch_decode(AsmArch * arch, AsmCode * code, off_t base,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
int arch_decode_at(Arch * arch, AsmCode * code, off_t offset, size_t size, int arch_decode_at(AsmArch * arch, AsmCode * code, off_t offset, size_t size,
off_t base, ArchInstructionCall ** calls, size_t * calls_cnt); off_t base, AsmArchInstructionCall ** calls, size_t * calls_cnt);
ssize_t arch_read(Arch * arch, void * buf, size_t cnt); ssize_t arch_read(AsmArch * arch, void * buf, size_t cnt);
off_t arch_seek(Arch * arch, off_t offset, int whence); off_t arch_seek(AsmArch * arch, off_t offset, int whence);
#endif /* !ASM_ARCH_H */ #endif /* !ASM_ARCH_H */

View File

@ -46,13 +46,13 @@ enum
/* variables */ /* variables */
static ArchDescription _amd64_description = static AsmArchDescription _amd64_description =
{ {
"elf", ARCH_ENDIAN_LITTLE, 64, 8, 0 "elf", ASM_ARCH_ENDIAN_LITTLE, 64, 8, 0
}; };
#define REG(name, size, id) { "" # name, size, id }, #define REG(name, size, id) { "" # name, size, id },
static ArchRegister _amd64_registers[] = static AsmArchRegister _amd64_registers[] =
{ {
#include "i386.reg" #include "i386.reg"
#include "i686.reg" #include "i686.reg"
@ -61,7 +61,7 @@ static ArchRegister _amd64_registers[] =
}; };
#undef REG #undef REG
static ArchInstruction _amd64_instructions[] = static AsmArchInstruction _amd64_instructions[] =
{ {
#include "i386.ins" #include "i386.ins"
#include "i486.ins" #include "i486.ins"
@ -79,7 +79,7 @@ static ArchInstruction _amd64_instructions[] =
/* public */ /* public */
/* variables */ /* variables */
/* plug-in */ /* plug-in */
ArchPlugin arch_plugin = AsmArchPlugin arch_plugin =
{ {
NULL, NULL,
"amd64", "amd64",

View File

@ -21,7 +21,7 @@
/* constants */ /* constants */
#ifndef ARCH_ENDIAN #ifndef ARCH_ENDIAN
# define ARCH_ENDIAN ARCH_ENDIAN_BOTH # define ARCH_ENDIAN ASM_ARCH_ENDIAN_BOTH
#endif #endif
@ -39,20 +39,20 @@ enum
/* variables */ /* variables */
static ArchDescription _arm_description = static AsmArchDescription _arm_description =
{ {
"elf", ARCH_ENDIAN, 32, 32, 32 "elf", ARCH_ENDIAN, 32, 32, 32
}; };
#define REG(name, size, id) { "" # name, size, id }, #define REG(name, size, id) { "" # name, size, id },
static ArchRegister _arm_registers[] = static AsmArchRegister _arm_registers[] =
{ {
#include "arm.reg" #include "arm.reg"
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
#undef REG #undef REG
static ArchInstruction _arm_instructions[] = static AsmArchInstruction _arm_instructions[] =
{ {
#include "arm.ins" #include "arm.ins"
#include "common.ins" #include "common.ins"
@ -67,7 +67,7 @@ static ArchInstruction _arm_instructions[] =
/* protected */ /* protected */
/* variables */ /* variables */
ArchPlugin arch_plugin = AsmArchPlugin arch_plugin =
{ {
NULL, NULL,
"arm", "arm",

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel as */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -22,19 +22,19 @@
/* private */ /* private */
/* prototypes */ /* prototypes */
/* plug-in */ /* plug-in */
static int _arm_encode(ArchPlugin * plugin, ArchInstruction * instruction, static int _arm_encode(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call); AsmArchInstructionCall * call);
/* functions */ /* functions */
/* plug-in */ /* plug-in */
/* arm_encode */ /* arm_encode */
static int _arm_encode(ArchPlugin * plugin, ArchInstruction * instruction, static int _arm_encode(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call) AsmArchInstructionCall * call)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint32_t opcode = instruction->opcode; uint32_t opcode = instruction->opcode;
ArchRegister * ar; AsmArchRegister * ar;
char const * p; char const * p;
switch(instruction->opcode & 0x0fffffff) /* ignore condition code */ switch(instruction->opcode & 0x0fffffff) /* ignore condition code */

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -15,5 +15,5 @@
#define ARCH_ENDIAN ARCH_ENDIAN_BIG #define ARCH_ENDIAN ASM_ARCH_ENDIAN_BIG
#include "arm.c" #include "arm.c"

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -15,5 +15,5 @@
#define ARCH_ENDIAN ARCH_ENDIAN_LITTLE #define ARCH_ENDIAN ASM_ARCH_ENDIAN_LITTLE
#include "arm.c" #include "arm.c"

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -26,8 +26,8 @@
/* types */ /* types */
typedef struct _DalvikDecode typedef struct _DalvikDecode
{ {
ArchPlugin * plugin; AsmArchPlugin * plugin;
ArchInstructionCall * call; AsmArchInstructionCall * call;
int u8; int u8;
} DalvikDecode; } DalvikDecode;
@ -55,21 +55,21 @@ enum
/* variables */ /* variables */
/* plug-in */ /* plug-in */
static ArchDescription _dalvik_description = static AsmArchDescription _dalvik_description =
{ {
"dex", ARCH_ENDIAN_LITTLE, 32, 16, 0 "dex", ASM_ARCH_ENDIAN_LITTLE, 32, 16, 0
}; };
#define REG(name, size, id) { "" # name, size, id }, #define REG(name, size, id) { "" # name, size, id },
static ArchRegister _dalvik_registers[] = static AsmArchRegister _dalvik_registers[] =
{ {
#include "dalvik.reg" #include "dalvik.reg"
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
#undef REG #undef REG
static ArchInstruction _dalvik_instructions[] = static AsmArchInstruction _dalvik_instructions[] =
{ {
#include "dalvik.ins" #include "dalvik.ins"
#include "common.ins" #include "common.ins"
@ -79,14 +79,14 @@ static ArchInstruction _dalvik_instructions[] =
/* prototypes */ /* prototypes */
/* plug-in */ /* plug-in */
static int _dalvik_encode(ArchPlugin * plugin, ArchInstruction * instruction, static int _dalvik_encode(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call); AsmArchInstructionCall * call);
static int _dalvik_decode(ArchPlugin * plugin, ArchInstructionCall * call); static int _dalvik_decode(AsmArchPlugin * plugin, AsmArchInstructionCall * call);
/* public */ /* public */
/* variables */ /* variables */
ArchPlugin arch_plugin = AsmArchPlugin arch_plugin =
{ {
NULL, NULL,
"dalvik", "dalvik",
@ -103,10 +103,10 @@ ArchPlugin arch_plugin =
/* private */ /* private */
/* functions */ /* functions */
/* dalvik_encode */ /* dalvik_encode */
static int _dalvik_encode(ArchPlugin * plugin, ArchInstruction * instruction, static int _dalvik_encode(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call) AsmArchInstructionCall * call)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint8_t u8; uint8_t u8;
uint16_t u16; uint16_t u16;
void const * buf; void const * buf;
@ -142,13 +142,13 @@ static int _decode_immediate(DalvikDecode * dd, size_t i);
static int _decode_operand(DalvikDecode * dd, size_t i); static int _decode_operand(DalvikDecode * dd, size_t i);
static int _decode_register(DalvikDecode * dd, size_t i); static int _decode_register(DalvikDecode * dd, size_t i);
static int _dalvik_decode(ArchPlugin * plugin, ArchInstructionCall * call) static int _dalvik_decode(AsmArchPlugin * plugin, AsmArchInstructionCall * call)
{ {
DalvikDecode dd; DalvikDecode dd;
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint8_t u8; uint8_t u8;
uint16_t u16; uint16_t u16;
ArchInstruction * ai; AsmArchInstruction * ai;
size_t i; size_t i;
dd.plugin = plugin; dd.plugin = plugin;
@ -198,8 +198,8 @@ static int _dalvik_decode(ArchPlugin * plugin, ArchInstructionCall * call)
static int _decode_immediate(DalvikDecode * dd, size_t i) static int _decode_immediate(DalvikDecode * dd, size_t i)
{ {
ArchPluginHelper * helper = dd->plugin->helper; AsmArchPluginHelper * helper = dd->plugin->helper;
ArchOperand * ao = &dd->call->operands[i]; AsmArchOperand * ao = &dd->call->operands[i];
uint8_t u8; uint8_t u8;
uint16_t u16; uint16_t u16;
uint32_t u32; uint32_t u32;
@ -279,12 +279,12 @@ static int _decode_operand(DalvikDecode * dd, size_t i)
static int _decode_register(DalvikDecode * dd, size_t i) static int _decode_register(DalvikDecode * dd, size_t i)
{ {
ArchPluginHelper * helper = dd->plugin->helper; AsmArchPluginHelper * helper = dd->plugin->helper;
ArchOperandDefinition aod = dd->call->operands[i].definition; AsmArchOperandDefinition aod = dd->call->operands[i].definition;
uint32_t id; uint32_t id;
uint8_t u8; uint8_t u8;
uint16_t u16; uint16_t u16;
ArchRegister * ar; AsmArchRegister * ar;
if(AO_GET_FLAGS(aod) & AOF_IMPLICIT) if(AO_GET_FLAGS(aod) & AOF_IMPLICIT)
id = AO_GET_VALUE(aod); id = AO_GET_VALUE(aod);

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -43,20 +43,20 @@ enum
/* variables */ /* variables */
static ArchDescription _i386_description = static AsmArchDescription _i386_description =
{ {
"elf", ARCH_ENDIAN_LITTLE, 32, 8, 0 "elf", ASM_ARCH_ENDIAN_LITTLE, 32, 8, 0
}; };
#define REG(name, size, id) { "" # name, size, id }, #define REG(name, size, id) { "" # name, size, id },
static ArchRegister _i386_registers[] = static AsmArchRegister _i386_registers[] =
{ {
#include "i386.reg" #include "i386.reg"
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
#undef REG #undef REG
static ArchInstruction _i386_instructions[] = static AsmArchInstruction _i386_instructions[] =
{ {
#include "i386.ins" #include "i386.ins"
#include "common.ins" #include "common.ins"
@ -71,7 +71,7 @@ static ArchInstruction _i386_instructions[] =
/* public */ /* public */
/* variables */ /* variables */
/* plug-in */ /* plug-in */
ArchPlugin arch_plugin = AsmArchPlugin arch_plugin =
{ {
NULL, NULL,
"i386", "i386",

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -23,36 +23,37 @@
/* i386 */ /* i386 */
/* private */ /* private */
/* prototypes */ /* prototypes */
static int _i386_decode(ArchPlugin * plugin, ArchInstructionCall * call); static int _i386_decode(AsmArchPlugin * plugin, AsmArchInstructionCall * call);
static int _i386_encode(ArchPlugin * plugin, ArchInstruction * instruction, static int _i386_encode(AsmArchPlugin * plugin,
ArchInstructionCall * call); AsmArchInstruction * instruction,
AsmArchInstructionCall * call);
/* functions */ /* functions */
/* i386_decode */ /* i386_decode */
static int _decode_constant(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_constant(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
size_t i); size_t i);
static int _decode_dregister(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_dregister(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
size_t i); size_t i);
static int _decode_immediate(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_immediate(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
size_t i); size_t i);
static int _decode_modrm(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_modrm(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
size_t * i); size_t * i);
static int _decode_modrm_do(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_modrm_do(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
size_t i, uint8_t u8); size_t i, uint8_t u8);
static ArchInstruction * _decode_opcode(ArchPlugin * plugin, static AsmArchInstruction * _decode_opcode(AsmArchPlugin * plugin,
ArchInstruction * ai); AsmArchInstruction * ai);
static int _decode_operand(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_operand(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
size_t * i); size_t * i);
static int _decode_postproc(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_postproc(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
unsigned int opcode); unsigned int opcode);
static int _decode_register(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_register(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
size_t i); size_t i);
static int _i386_decode(ArchPlugin * plugin, ArchInstructionCall * call) static int _i386_decode(AsmArchPlugin * plugin, AsmArchInstructionCall * call)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
ArchInstruction * ai = NULL; AsmArchInstruction * ai = NULL;
unsigned int opcode; unsigned int opcode;
uint8_t u8; uint8_t u8;
uint16_t u16; uint16_t u16;
@ -101,11 +102,11 @@ static int _i386_decode(ArchPlugin * plugin, ArchInstructionCall * call)
return _decode_postproc(plugin, call, opcode); return _decode_postproc(plugin, call, opcode);
} }
static int _decode_constant(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_constant(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
size_t i) size_t i)
{ {
ArchOperandDefinition aod = call->operands[i].definition; AsmArchOperandDefinition aod = call->operands[i].definition;
ArchOperand * ao = &call->operands[i]; AsmArchOperand * ao = &call->operands[i];
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s()\n", __func__); fprintf(stderr, "DEBUG: %s()\n", __func__);
@ -121,12 +122,12 @@ static int _decode_constant(ArchPlugin * plugin, ArchInstructionCall * call,
return -error_set_code(1, "%s", "Not implemented"); return -error_set_code(1, "%s", "Not implemented");
} }
static int _decode_dregister(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_dregister(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
size_t i) size_t i)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
ArchOperandDefinition aod = call->operands[i].definition; AsmArchOperandDefinition aod = call->operands[i].definition;
ArchRegister * ar; AsmArchRegister * ar;
uint8_t id; uint8_t id;
#ifdef DEBUG #ifdef DEBUG
@ -143,11 +144,11 @@ static int _decode_dregister(ArchPlugin * plugin, ArchInstructionCall * call,
return 0; return 0;
} }
static int _decode_immediate(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_immediate(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
size_t i) size_t i)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
ArchOperand * ao = &call->operands[i]; AsmArchOperand * ao = &call->operands[i];
uint8_t u8; uint8_t u8;
uint16_t u16; uint16_t u16;
uint32_t u32; uint32_t u32;
@ -184,14 +185,14 @@ static int _decode_immediate(ArchPlugin * plugin, ArchInstructionCall * call,
return 0; return 0;
} }
static int _decode_modrm(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_modrm(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
size_t * i) size_t * i)
{ {
int ret = -1; int ret = -1;
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
ArchOperand * ao = call->operands; AsmArchOperand * ao = call->operands;
ArchOperand * ao1 = &call->operands[*i]; AsmArchOperand * ao1 = &call->operands[*i];
ArchOperand * ao2 = NULL; AsmArchOperand * ao2 = NULL;
uint8_t u8; uint8_t u8;
uint8_t mod; uint8_t mod;
uint8_t reg; uint8_t reg;
@ -235,15 +236,15 @@ static int _decode_modrm(ArchPlugin * plugin, ArchInstructionCall * call,
return ret; return ret;
} }
static int _decode_modrm_do(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_modrm_do(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
size_t i, uint8_t u8) size_t i, uint8_t u8)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
ArchOperand * ao = &call->operands[i]; AsmArchOperand * ao = &call->operands[i];
uint8_t mod; uint8_t mod;
uint8_t reg; uint8_t reg;
uint8_t rm; uint8_t rm;
ArchRegister * ar; AsmArchRegister * ar;
uintW_t uW; uintW_t uW;
mod = (u8 >> 6) & 0x3; mod = (u8 >> 6) & 0x3;
@ -305,11 +306,11 @@ static int _decode_modrm_do(ArchPlugin * plugin, ArchInstructionCall * call,
return 0; return 0;
} }
static ArchInstruction * _decode_opcode(ArchPlugin * plugin, static AsmArchInstruction * _decode_opcode(AsmArchPlugin * plugin,
ArchInstruction * ai) AsmArchInstruction * ai)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
ArchInstruction * p; AsmArchInstruction * p;
size_t i; size_t i;
uint8_t mod; uint8_t mod;
@ -340,10 +341,10 @@ static ArchInstruction * _decode_opcode(ArchPlugin * plugin,
return ai; return ai;
} }
static int _decode_operand(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_operand(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
size_t * i) size_t * i)
{ {
ArchOperand * ao = &call->operands[*i]; AsmArchOperand * ao = &call->operands[*i];
switch(AO_GET_TYPE(ao->definition)) switch(AO_GET_TYPE(ao->definition))
{ {
@ -363,11 +364,11 @@ static int _decode_operand(ArchPlugin * plugin, ArchInstructionCall * call,
return -error_set_code(1, "%s", strerror(ENOSYS)); return -error_set_code(1, "%s", strerror(ENOSYS));
} }
static int _decode_postproc(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_postproc(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
unsigned int opcode) unsigned int opcode)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
ArchOperand * ao; AsmArchOperand * ao;
AsmFunction * af; AsmFunction * af;
switch(opcode) switch(opcode)
@ -411,12 +412,12 @@ static int _decode_postproc(ArchPlugin * plugin, ArchInstructionCall * call,
return 0; return 0;
} }
static int _decode_register(ArchPlugin * plugin, ArchInstructionCall * call, static int _decode_register(AsmArchPlugin * plugin, AsmArchInstructionCall * call,
size_t i) size_t i)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
ArchOperandDefinition aod = call->operands[i].definition; AsmArchOperandDefinition aod = call->operands[i].definition;
ArchRegister * ar; AsmArchRegister * ar;
uint8_t id; uint8_t id;
#ifdef DEBUG #ifdef DEBUG
@ -443,26 +444,29 @@ static int _decode_register(ArchPlugin * plugin, ArchInstructionCall * call,
/* i386_encode */ /* i386_encode */
static int _encode_constant(ArchPlugin * plugin, static int _encode_constant(AsmArchPlugin * plugin,
ArchOperandDefinition definition, ArchOperand * operand); AsmArchOperandDefinition definition, AsmArchOperand * operand);
static int _encode_dregister(ArchPlugin * plugin, uint32_t * i, static int _encode_dregister(AsmArchPlugin * plugin, uint32_t * i,
ArchOperandDefinition * definitions, ArchOperand * operands); AsmArchOperandDefinition * definitions,
static int _encode_immediate(ArchPlugin * plugin, ArchOperand * operand); AsmArchOperand * operands);
static int _encode_immediate8(ArchPlugin * plugin, uint8_t value); static int _encode_immediate(AsmArchPlugin * plugin, AsmArchOperand * operand);
static int _encode_immediate16(ArchPlugin * plugin, uint16_t value); static int _encode_immediate8(AsmArchPlugin * plugin, uint8_t value);
static int _encode_immediate24(ArchPlugin * plugin, uint32_t value); static int _encode_immediate16(AsmArchPlugin * plugin, uint16_t value);
static int _encode_immediate32(ArchPlugin * plugin, uint32_t value); static int _encode_immediate24(AsmArchPlugin * plugin, uint32_t value);
static int _encode_opcode(ArchPlugin * plugin, ArchInstruction * instruction); static int _encode_immediate32(AsmArchPlugin * plugin, uint32_t value);
static int _encode_operand(ArchPlugin * plugin, uint32_t * i, static int _encode_opcode(AsmArchPlugin * plugin,
ArchOperandDefinition * definitions, ArchOperand * operands); AsmArchInstruction * instruction);
static int _encode_register(ArchPlugin * plugin, uint32_t * i, static int _encode_operand(AsmArchPlugin * plugin, uint32_t * i,
ArchOperandDefinition * definitions, ArchOperand * operands); AsmArchOperandDefinition * definitions, AsmArchOperand * operands);
static int _encode_register(AsmArchPlugin * plugin, uint32_t * i,
AsmArchOperandDefinition * definitions, AsmArchOperand * operands);
static int _i386_encode(ArchPlugin * plugin, ArchInstruction * instruction, static int _i386_encode(AsmArchPlugin * plugin,
ArchInstructionCall * call) AsmArchInstruction * instruction,
AsmArchInstructionCall * call)
{ {
uint32_t i; uint32_t i;
ArchOperandDefinition definitions[3]; AsmArchOperandDefinition definitions[3];
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, instruction->name); fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, instruction->name);
@ -479,10 +483,10 @@ static int _i386_encode(ArchPlugin * plugin, ArchInstruction * instruction,
return 0; return 0;
} }
static int _encode_constant(ArchPlugin * plugin, static int _encode_constant(AsmArchPlugin * plugin,
ArchOperandDefinition definition, ArchOperand * operand) AsmArchOperandDefinition definition, AsmArchOperand * operand)
{ {
ArchOperand ao; AsmArchOperand ao;
if(AO_GET_FLAGS(definition) & AOF_IMPLICIT) if(AO_GET_FLAGS(definition) & AOF_IMPLICIT)
return 0; return 0;
@ -491,16 +495,17 @@ static int _encode_constant(ArchPlugin * plugin,
return _encode_immediate(plugin, &ao); return _encode_immediate(plugin, &ao);
} }
static int _encode_dregister(ArchPlugin * plugin, uint32_t * i, static int _encode_dregister(AsmArchPlugin * plugin, uint32_t * i,
ArchOperandDefinition * definitions, ArchOperand * operands) AsmArchOperandDefinition * definitions,
AsmArchOperand * operands)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
ArchOperandDefinition definition = definitions[*i]; AsmArchOperandDefinition definition = definitions[*i];
ArchOperand * operand = &operands[*i]; AsmArchOperand * operand = &operands[*i];
char const * name = operand->value._register.name; char const * name = operand->value._register.name;
size_t size = AO_GET_SIZE(definition); size_t size = AO_GET_SIZE(definition);
ArchRegister * ar; AsmArchRegister * ar;
ArchOperand ioperand; AsmArchOperand ioperand;
if((ar = helper->get_register_by_name_size(helper->arch, name, size)) if((ar = helper->get_register_by_name_size(helper->arch, name, size))
== NULL) == NULL)
@ -548,7 +553,7 @@ static int _encode_dregister(ArchPlugin * plugin, uint32_t * i,
return _encode_immediate(plugin, &ioperand); return _encode_immediate(plugin, &ioperand);
} }
static int _encode_immediate(ArchPlugin * plugin, ArchOperand * operand) static int _encode_immediate(AsmArchPlugin * plugin, AsmArchOperand * operand)
{ {
uint64_t value = operand->value.immediate.value; uint64_t value = operand->value.immediate.value;
@ -571,18 +576,18 @@ static int _encode_immediate(ArchPlugin * plugin, ArchOperand * operand)
return -error_set_code(1, "%s", "Invalid size"); return -error_set_code(1, "%s", "Invalid size");
} }
static int _encode_immediate8(ArchPlugin * plugin, uint8_t value) static int _encode_immediate8(AsmArchPlugin * plugin, uint8_t value)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
if(helper->write(helper->arch, &value, sizeof(value)) != sizeof(value)) if(helper->write(helper->arch, &value, sizeof(value)) != sizeof(value))
return -1; return -1;
return 0; return 0;
} }
static int _encode_immediate16(ArchPlugin * plugin, uint16_t value) static int _encode_immediate16(AsmArchPlugin * plugin, uint16_t value)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
value = _htol16(value); value = _htol16(value);
if(helper->write(helper->arch, &value, sizeof(value)) != sizeof(value)) if(helper->write(helper->arch, &value, sizeof(value)) != sizeof(value))
@ -590,9 +595,9 @@ static int _encode_immediate16(ArchPlugin * plugin, uint16_t value)
return 0; return 0;
} }
static int _encode_immediate24(ArchPlugin * plugin, uint32_t value) static int _encode_immediate24(AsmArchPlugin * plugin, uint32_t value)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
value = _htol32(value) >> 8; value = _htol32(value) >> 8;
if(helper->write(helper->arch, &value, 3) != 3) if(helper->write(helper->arch, &value, 3) != 3)
@ -600,9 +605,9 @@ static int _encode_immediate24(ArchPlugin * plugin, uint32_t value)
return 0; return 0;
} }
static int _encode_immediate32(ArchPlugin * plugin, uint32_t value) static int _encode_immediate32(AsmArchPlugin * plugin, uint32_t value)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
value = _htol32(value); value = _htol32(value);
if(helper->write(helper->arch, &value, sizeof(value)) != sizeof(value)) if(helper->write(helper->arch, &value, sizeof(value)) != sizeof(value))
@ -610,9 +615,10 @@ static int _encode_immediate32(ArchPlugin * plugin, uint32_t value)
return 0; return 0;
} }
static int _encode_opcode(ArchPlugin * plugin, ArchInstruction * instruction) static int _encode_opcode(AsmArchPlugin * plugin,
AsmArchInstruction * instruction)
{ {
ArchOperand operand; AsmArchOperand operand;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s() size=%u opcode=0x%x\n", __func__, fprintf(stderr, "DEBUG: %s() size=%u opcode=0x%x\n", __func__,
@ -643,8 +649,8 @@ static int _encode_opcode(ArchPlugin * plugin, ArchInstruction * instruction)
return _encode_immediate(plugin, &operand); return _encode_immediate(plugin, &operand);
} }
static int _encode_operand(ArchPlugin * plugin, uint32_t * i, static int _encode_operand(AsmArchPlugin * plugin, uint32_t * i,
ArchOperandDefinition * definitions, ArchOperand * operands) AsmArchOperandDefinition * definitions, AsmArchOperand * operands)
{ {
switch(operands[*i].definition) switch(operands[*i].definition)
{ {
@ -667,16 +673,17 @@ static int _encode_operand(ArchPlugin * plugin, uint32_t * i,
return 0; return 0;
} }
static int _encode_register(ArchPlugin * plugin, uint32_t * i, static int _encode_register(AsmArchPlugin * plugin, uint32_t * i,
ArchOperandDefinition * definitions, ArchOperand * operands) AsmArchOperandDefinition * definitions,
AsmArchOperand * operands)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
ArchOperandDefinition definition = definitions[*i]; AsmArchOperandDefinition definition = definitions[*i];
ArchOperand * operand = &operands[*i]; AsmArchOperand * operand = &operands[*i];
char const * name = operand->value._register.name; char const * name = operand->value._register.name;
size_t size = AO_GET_SIZE(definition); size_t size = AO_GET_SIZE(definition);
ArchRegister * ar; AsmArchRegister * ar;
ArchOperand ioperand; AsmArchOperand ioperand;
if(AO_GET_FLAGS(definition) & AOF_IMPLICIT) if(AO_GET_FLAGS(definition) & AOF_IMPLICIT)
return 0; return 0;

View File

@ -44,20 +44,20 @@ enum
/* variables */ /* variables */
static ArchDescription _i386_real_description = static AsmArchDescription _i386_real_description =
{ {
"elf", ARCH_ENDIAN_LITTLE, 20, 8, 0 "elf", ASM_ARCH_ENDIAN_LITTLE, 20, 8, 0
}; };
#define REG(name, size, id) { "" # name, size, id }, #define REG(name, size, id) { "" # name, size, id },
static ArchRegister _i386_real_registers[] = static AsmArchRegister _i386_real_registers[] =
{ {
#include "i386.reg" #include "i386.reg"
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
#undef REG #undef REG
static ArchInstruction _i386_real_instructions[] = static AsmArchInstruction _i386_real_instructions[] =
{ {
#include "i386.ins" #include "i386.ins"
#include "common.ins" #include "common.ins"
@ -72,7 +72,7 @@ static ArchInstruction _i386_real_instructions[] =
/* public */ /* public */
/* variables */ /* variables */
/* plug-in */ /* plug-in */
ArchPlugin arch_plugin = AsmArchPlugin arch_plugin =
{ {
NULL, NULL,
"i386_real", "i386_real",

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -43,20 +43,20 @@ enum
/* variables */ /* variables */
static ArchDescription _i486_description = static AsmArchDescription _i486_description =
{ {
"elf", ARCH_ENDIAN_LITTLE, 32, 8, 0 "elf", ASM_ARCH_ENDIAN_LITTLE, 32, 8, 0
}; };
#define REG(name, size, id) { "" # name, size, id }, #define REG(name, size, id) { "" # name, size, id },
static ArchRegister _i486_registers[] = static AsmArchRegister _i486_registers[] =
{ {
#include "i386.reg" #include "i386.reg"
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
#undef REG #undef REG
static ArchInstruction _i486_instructions[] = static AsmArchInstruction _i486_instructions[] =
{ {
#include "i386.ins" #include "i386.ins"
#include "i486.ins" #include "i486.ins"
@ -72,7 +72,7 @@ static ArchInstruction _i486_instructions[] =
/* public */ /* public */
/* variables */ /* variables */
/* plug-in */ /* plug-in */
ArchPlugin arch_plugin = AsmArchPlugin arch_plugin =
{ {
NULL, NULL,
"i486", "i486",

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -43,20 +43,20 @@ enum
/* variables */ /* variables */
static ArchDescription _i586_description = static AsmArchDescription _i586_description =
{ {
"elf", ARCH_ENDIAN_LITTLE, 32, 8, 0 "elf", ASM_ARCH_ENDIAN_LITTLE, 32, 8, 0
}; };
#define REG(name, size, id) { "" # name, size, id }, #define REG(name, size, id) { "" # name, size, id },
static ArchRegister _i586_registers[] = static AsmArchRegister _i586_registers[] =
{ {
#include "i386.reg" #include "i386.reg"
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
#undef REG #undef REG
static ArchInstruction _i586_instructions[] = static AsmArchInstruction _i586_instructions[] =
{ {
#include "i386.ins" #include "i386.ins"
#include "i486.ins" #include "i486.ins"
@ -73,7 +73,7 @@ static ArchInstruction _i586_instructions[] =
/* public */ /* public */
/* variables */ /* variables */
/* plug-in */ /* plug-in */
ArchPlugin arch_plugin = AsmArchPlugin arch_plugin =
{ {
NULL, NULL,
"i586", "i586",

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -44,13 +44,13 @@ enum
/* variables */ /* variables */
static ArchDescription _i686_description = static AsmArchDescription _i686_description =
{ {
"elf", ARCH_ENDIAN_LITTLE, 32, 8, 0 "elf", ASM_ARCH_ENDIAN_LITTLE, 32, 8, 0
}; };
#define REG(name, size, id) { "" # name, size, id }, #define REG(name, size, id) { "" # name, size, id },
static ArchRegister _i686_registers[] = static AsmArchRegister _i686_registers[] =
{ {
#include "i386.reg" #include "i386.reg"
#include "i686.reg" #include "i686.reg"
@ -58,7 +58,7 @@ static ArchRegister _i686_registers[] =
}; };
#undef REG #undef REG
static ArchInstruction _i686_instructions[] = static AsmArchInstruction _i686_instructions[] =
{ {
#include "i386.ins" #include "i386.ins"
#include "i486.ins" #include "i486.ins"
@ -75,7 +75,7 @@ static ArchInstruction _i686_instructions[] =
/* public */ /* public */
/* variables */ /* variables */
/* plug-in */ /* plug-in */
ArchPlugin arch_plugin = AsmArchPlugin arch_plugin =
{ {
NULL, NULL,
"i686", "i686",

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -25,12 +25,12 @@
/* Java */ /* Java */
/* private */ /* private */
/* variables */ /* variables */
static ArchDescription _java_description = static AsmArchDescription _java_description =
{ {
"java", ARCH_ENDIAN_BIG, 32, 8, 0 "java", ASM_ARCH_ENDIAN_BIG, 32, 8, 0
}; };
static ArchRegister _java_registers[] = static AsmArchRegister _java_registers[] =
{ {
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
@ -42,7 +42,7 @@ static ArchRegister _java_registers[] =
#define OP_U16_FUNC AO_IMMEDIATE(0, 16, AOI_REFERS_FUNCTION) #define OP_U16_FUNC AO_IMMEDIATE(0, 16, AOI_REFERS_FUNCTION)
#define OP_S32 AO_IMMEDIATE(AOF_SIGNED, 32, 0) #define OP_S32 AO_IMMEDIATE(AOF_SIGNED, 32, 0)
#define OP_U32 AO_IMMEDIATE(0, 32, 0) #define OP_U32 AO_IMMEDIATE(0, 32, 0)
static ArchInstruction _java_instructions[] = static AsmArchInstruction _java_instructions[] =
{ {
{ "aaload", 0x32, OP1F, AO_0() }, { "aaload", 0x32, OP1F, AO_0() },
{ "aastore", 0x53, OP1F, AO_0() }, { "aastore", 0x53, OP1F, AO_0() },
@ -254,14 +254,14 @@ static ArchInstruction _java_instructions[] =
/* prototypes */ /* prototypes */
/* plug-in */ /* plug-in */
static int _java_encode(ArchPlugin * plugin, ArchInstruction * instruction, static int _java_encode(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call); AsmArchInstructionCall * call);
static int _java_decode(ArchPlugin * plugin, ArchInstructionCall * call); static int _java_decode(AsmArchPlugin * plugin, AsmArchInstructionCall * call);
/* public */ /* public */
/* variables */ /* variables */
ArchPlugin arch_plugin = AsmArchPlugin arch_plugin =
{ {
NULL, NULL,
"java", "java",
@ -278,13 +278,13 @@ ArchPlugin arch_plugin =
/* private */ /* private */
/* functions */ /* functions */
/* plug-in */ /* plug-in */
static int _java_encode(ArchPlugin * plugin, ArchInstruction * instruction, static int _java_encode(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call) AsmArchInstructionCall * call)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
size_t i; size_t i;
ArchOperandDefinition definitions[3]; AsmArchOperandDefinition definitions[3];
ArchOperand * ao; AsmArchOperand * ao;
uint8_t u8; uint8_t u8;
uint16_t u16; uint16_t u16;
uint32_t u32; uint32_t u32;
@ -326,13 +326,13 @@ static int _java_encode(ArchPlugin * plugin, ArchInstruction * instruction,
/* java_decode */ /* java_decode */
static int _java_decode(ArchPlugin * plugin, ArchInstructionCall * call) static int _java_decode(AsmArchPlugin * plugin, AsmArchInstructionCall * call)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint8_t u8; uint8_t u8;
ArchInstruction * ai; AsmArchInstruction * ai;
size_t i; size_t i;
ArchOperand * ao; AsmArchOperand * ao;
uint16_t u16; uint16_t u16;
uint32_t u32; uint32_t u32;
AsmString * as; AsmString * as;

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -19,27 +19,27 @@
#include "Asm.h" #include "Asm.h"
#ifndef ARCH_ENDIAN #ifndef ARCH_ENDIAN
# define ARCH_ENDIAN ARCH_ENDIAN_BOTH # define ARCH_ENDIAN ASM_ARCH_ENDIAN_BOTH
#endif #endif
/* mips */ /* mips */
/* private */ /* private */
/* variables */ /* variables */
static ArchDescription _mips_description = static AsmArchDescription _mips_description =
{ {
"elf", ARCH_ENDIAN, 32, 32, 32 "elf", ARCH_ENDIAN, 32, 32, 32
}; };
#define REG(name, size, id) { "" # name, size, id }, #define REG(name, size, id) { "" # name, size, id },
static ArchRegister _mips_registers[] = static AsmArchRegister _mips_registers[] =
{ {
#include "mips.reg" #include "mips.reg"
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
#undef REG #undef REG
static ArchInstruction _mips_instructions[] = static AsmArchInstruction _mips_instructions[] =
{ {
#include "mips.ins" #include "mips.ins"
#include "common.ins" #include "common.ins"
@ -54,7 +54,7 @@ static ArchInstruction _mips_instructions[] =
/* protected */ /* protected */
/* variables */ /* variables */
ArchPlugin arch_plugin = AsmArchPlugin arch_plugin =
{ {
NULL, NULL,
"mips", "mips",

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel as */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -22,17 +22,19 @@
/* private */ /* private */
/* prototypes */ /* prototypes */
/* plug-in */ /* plug-in */
static int _mips_encode(ArchPlugin * plugin, ArchInstruction * instruction, static int _mips_encode(AsmArchPlugin * plugin,
ArchInstructionCall * call); AsmArchInstruction * instruction,
AsmArchInstructionCall * call);
/* functions */ /* functions */
/* plug-in */ /* plug-in */
/* mips_encode */ /* mips_encode */
static int _mips_encode(ArchPlugin * plugin, ArchInstruction * instruction, static int _mips_encode(AsmArchPlugin * plugin,
ArchInstructionCall * call) AsmArchInstruction * instruction,
AsmArchInstructionCall * call)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint32_t opcode = instruction->opcode; uint32_t opcode = instruction->opcode;
/* FIXME really implement */ /* FIXME really implement */

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -15,5 +15,5 @@
#define ARCH_ENDIAN ARCH_ENDIAN_BIG #define ARCH_ENDIAN ASM_ARCH_ENDIAN_BIG
#include "mips.c" #include "mips.c"

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -15,5 +15,5 @@
#define ARCH_ENDIAN ARCH_ENDIAN_LITTLE #define ARCH_ENDIAN ASM_ARCH_ENDIAN_LITTLE
#include "mips.c" #include "mips.c"

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -22,20 +22,20 @@
/* sparc */ /* sparc */
/* private */ /* private */
/* variables */ /* variables */
static ArchDescription _sparc_description = static AsmArchDescription _sparc_description =
{ {
"elf", ARCH_ENDIAN_BIG, 32, 32, 32 "elf", ASM_ARCH_ENDIAN_BIG, 32, 32, 32
}; };
#define REG(name, size, id) { "" # name, size, id }, #define REG(name, size, id) { "" # name, size, id },
static ArchRegister _sparc_registers[] = static AsmArchRegister _sparc_registers[] =
{ {
#include "sparc.reg" #include "sparc.reg"
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
#undef REG #undef REG
static ArchInstruction _sparc_instructions[] = static AsmArchInstruction _sparc_instructions[] =
{ {
#include "sparc.ins" #include "sparc.ins"
#include "common.ins" #include "common.ins"
@ -50,7 +50,7 @@ static ArchInstruction _sparc_instructions[] =
/* protected */ /* protected */
/* variables */ /* variables */
ArchPlugin arch_plugin = AsmArchPlugin arch_plugin =
{ {
NULL, NULL,
"sparc", "sparc",

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel as */ /* This file is part of DeforaOS Devel as */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
@ -22,20 +22,21 @@
/* private */ /* private */
/* prototypes */ /* prototypes */
/* plug-in */ /* plug-in */
static int _sparc_decode(ArchPlugin * plugin, ArchInstructionCall * call); static int _sparc_decode(AsmArchPlugin * plugin, AsmArchInstructionCall * call);
static int _sparc_encode(ArchPlugin * plugin, ArchInstruction * instruction, static int _sparc_encode(AsmArchPlugin * plugin,
ArchInstructionCall * call); AsmArchInstruction * instruction,
AsmArchInstructionCall * call);
/* functions */ /* functions */
/* plug-in */ /* plug-in */
/* sparc_decode */ /* sparc_decode */
static int _sparc_decode(ArchPlugin * plugin, ArchInstructionCall * call) static int _sparc_decode(AsmArchPlugin * plugin, AsmArchInstructionCall * call)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint32_t u32; uint32_t u32;
uint32_t opcode; uint32_t opcode;
ArchInstruction * ai; AsmArchInstruction * ai;
size_t i; size_t i;
if(helper->read(helper->arch, &u32, sizeof(u32)) != sizeof(u32)) if(helper->read(helper->arch, &u32, sizeof(u32)) != sizeof(u32))
@ -72,19 +73,20 @@ static int _sparc_decode(ArchPlugin * plugin, ArchInstructionCall * call)
/* sparc_encode */ /* sparc_encode */
static int _encode_branch(ArchInstruction * instruction, static int _encode_branch(AsmArchInstruction * instruction,
ArchInstructionCall * call, uint32_t * opcode); AsmArchInstructionCall * call, uint32_t * opcode);
static int _encode_integer(ArchPlugin * plugin, ArchInstruction * instruction, static int _encode_integer(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call, uint32_t * opcode); AsmArchInstructionCall * call, uint32_t * opcode);
static int _encode_loadstore(ArchPlugin * plugin, ArchInstruction * instruction, static int _encode_loadstore(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call, uint32_t * opcode); AsmArchInstructionCall * call, uint32_t * opcode);
static int _encode_sethi(ArchPlugin * plugin, ArchInstruction * instruction, static int _encode_sethi(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call, uint32_t * opcode); AsmArchInstructionCall * call, uint32_t * opcode);
static int _sparc_encode(ArchPlugin * plugin, ArchInstruction * instruction, static int _sparc_encode(AsmArchPlugin * plugin,
ArchInstructionCall * call) AsmArchInstruction * instruction,
AsmArchInstructionCall * call)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint32_t opcode = instruction->opcode; uint32_t opcode = instruction->opcode;
if((opcode & 0xc0000000) == 0xc0000000) if((opcode & 0xc0000000) == 0xc0000000)
@ -116,8 +118,8 @@ static int _sparc_encode(ArchPlugin * plugin, ArchInstruction * instruction,
return 0; return 0;
} }
static int _encode_branch(ArchInstruction * instruction, static int _encode_branch(AsmArchInstruction * instruction,
ArchInstructionCall * call, uint32_t * opcode) AsmArchInstructionCall * call, uint32_t * opcode)
{ {
uint32_t disp; uint32_t disp;
@ -131,15 +133,15 @@ static int _encode_branch(ArchInstruction * instruction,
return 0; return 0;
} }
static int _encode_integer(ArchPlugin * plugin, ArchInstruction * instruction, static int _encode_integer(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call, uint32_t * opcode) AsmArchInstructionCall * call, uint32_t * opcode)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint32_t rd; uint32_t rd;
uint32_t rs1; uint32_t rs1;
uint32_t rs2; uint32_t rs2;
char const * name; char const * name;
ArchRegister * ar; AsmArchRegister * ar;
/* rs1 */ /* rs1 */
if(AO_GET_TYPE(instruction->op1) != AOT_REGISTER) if(AO_GET_TYPE(instruction->op1) != AOT_REGISTER)
@ -180,15 +182,15 @@ static int _encode_integer(ArchPlugin * plugin, ArchInstruction * instruction,
return 0; return 0;
} }
static int _encode_loadstore(ArchPlugin * plugin, ArchInstruction * instruction, static int _encode_loadstore(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call, uint32_t * opcode) AsmArchInstructionCall * call, uint32_t * opcode)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint32_t rd; uint32_t rd;
uint32_t rs1; uint32_t rs1;
uint32_t rs2; uint32_t rs2;
char const * name; char const * name;
ArchRegister * ar; AsmArchRegister * ar;
if(instruction->opcode & (1 << 21)) /* store instruction */ if(instruction->opcode & (1 << 21)) /* store instruction */
{ {
@ -266,14 +268,14 @@ static int _encode_loadstore(ArchPlugin * plugin, ArchInstruction * instruction,
return 0; return 0;
} }
static int _encode_sethi(ArchPlugin * plugin, ArchInstruction * instruction, static int _encode_sethi(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call, uint32_t * opcode) AsmArchInstructionCall * call, uint32_t * opcode)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint32_t rd; uint32_t rd;
uint32_t value; uint32_t value;
char const * name; char const * name;
ArchRegister * ar; AsmArchRegister * ar;
/* nop */ /* nop */
if(AO_GET_TYPE(instruction->op1) == AOT_NONE) if(AO_GET_TYPE(instruction->op1) == AOT_NONE)

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -22,20 +22,20 @@
/* sparc64 */ /* sparc64 */
/* private */ /* private */
/* variables */ /* variables */
static ArchDescription _sparc64_description = static AsmArchDescription _sparc64_description =
{ {
"elf", ARCH_ENDIAN_BIG, 64, 32, 32 "elf", ASM_ARCH_ENDIAN_BIG, 64, 32, 32
}; };
#define REG(name, size, id) { "" # name, size, id }, #define REG(name, size, id) { "" # name, size, id },
static ArchRegister _sparc64_registers[] = static AsmArchRegister _sparc64_registers[] =
{ {
#include "sparc.reg" #include "sparc.reg"
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
#undef REG #undef REG
static ArchInstruction _sparc64_instructions[] = static AsmArchInstruction _sparc64_instructions[] =
{ {
#include "sparc.ins" #include "sparc.ins"
#include "common.ins" #include "common.ins"
@ -49,7 +49,7 @@ static ArchInstruction _sparc64_instructions[] =
/* protected */ /* protected */
/* variables */ /* variables */
ArchPlugin arch_plugin = AsmArchPlugin arch_plugin =
{ {
NULL, NULL,
"sparc64", "sparc64",

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -28,20 +28,20 @@
/* private */ /* private */
/* variables */ /* variables */
/* plug-in */ /* plug-in */
static ArchDescription _yasep_description = static AsmArchDescription _yasep_description =
{ {
"flat", ARCH_ENDIAN_LITTLE, 32, 16, 0 "flat", ASM_ARCH_ENDIAN_LITTLE, 32, 16, 0
}; };
#define REG(name, size, id) { "" # name, size, id }, #define REG(name, size, id) { "" # name, size, id },
static ArchRegister _yasep_registers[] = static AsmArchRegister _yasep_registers[] =
{ {
#include "yasep.reg" #include "yasep.reg"
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
#undef REG #undef REG
static ArchInstruction _yasep_instructions[] = static AsmArchInstruction _yasep_instructions[] =
{ {
#include "yasep.ins" #include "yasep.ins"
#include "common.ins" #include "common.ins"
@ -51,14 +51,14 @@ static ArchInstruction _yasep_instructions[] =
/* prototypes */ /* prototypes */
/* plug-in */ /* plug-in */
static int _yasep_encode(ArchPlugin * plugin, ArchInstruction * instruction, static int _yasep_encode(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call); AsmArchInstructionCall * call);
static int _yasep_decode(ArchPlugin * plugin, ArchInstructionCall * call); static int _yasep_decode(AsmArchPlugin * plugin, AsmArchInstructionCall * call);
/* public */ /* public */
/* variables */ /* variables */
ArchPlugin arch_plugin = AsmArchPlugin arch_plugin =
{ {
NULL, NULL,
_yasep_name, _yasep_name,
@ -76,25 +76,25 @@ ArchPlugin arch_plugin =
/* functions */ /* functions */
/* plug-in */ /* plug-in */
/* yasep_encode */ /* yasep_encode */
static int _encode_16(ArchPlugin * plugin, ArchInstruction * instruction, static int _encode_16(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call); AsmArchInstructionCall * call);
static int _encode_32(ArchPlugin * plugin, ArchInstruction * instruction, static int _encode_32(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call); AsmArchInstructionCall * call);
static int _yasep_encode(ArchPlugin * plugin, ArchInstruction * instruction, static int _yasep_encode(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call) AsmArchInstructionCall * call)
{ {
return (instruction->opcode & 0x1) return (instruction->opcode & 0x1)
? _encode_32(plugin, instruction, call) ? _encode_32(plugin, instruction, call)
: _encode_16(plugin, instruction, call); : _encode_16(plugin, instruction, call);
} }
static int _encode_16(ArchPlugin * plugin, ArchInstruction * instruction, static int _encode_16(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call) AsmArchInstructionCall * call)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint16_t u16 = instruction->opcode; uint16_t u16 = instruction->opcode;
ArchRegister * ar; AsmArchRegister * ar;
size_t size; size_t size;
char const * name; char const * name;
@ -129,10 +129,10 @@ static int _encode_16(ArchPlugin * plugin, ArchInstruction * instruction,
return 0; return 0;
} }
static int _encode_32(ArchPlugin * plugin, ArchInstruction * instruction, static int _encode_32(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
ArchInstructionCall * call) AsmArchInstructionCall * call)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint32_t opcode = instruction->opcode; uint32_t opcode = instruction->opcode;
opcode = _htol32(opcode); opcode = _htol32(opcode);
@ -144,13 +144,13 @@ static int _encode_32(ArchPlugin * plugin, ArchInstruction * instruction,
/* yasep_decode */ /* yasep_decode */
static int _yasep_decode(ArchPlugin * plugin, ArchInstructionCall * call) static int _yasep_decode(AsmArchPlugin * plugin, AsmArchInstructionCall * call)
{ {
ArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint16_t u16; uint16_t u16;
uint16_t opcode; uint16_t opcode;
ArchInstruction * ai; AsmArchInstruction * ai;
ArchRegister * ar; AsmArchRegister * ar;
if(helper->read(helper->arch, &u16, sizeof(u16)) != sizeof(u16)) if(helper->read(helper->arch, &u16, sizeof(u16)) != sizeof(u16))
return -1; return -1;

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License a published by * it under the terms of the GNU General Public License a published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -215,7 +215,7 @@ int asm_close(Asm * a)
/* asm_deassemble */ /* asm_deassemble */
AsmCode * asm_deassemble(Asm * a, char const * buffer, size_t size, AsmCode * asm_deassemble(Asm * a, char const * buffer, size_t size,
ArchInstructionCall ** calls, size_t * calls_cnt) AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
if(_asm_open(a, NULL) != 0) if(_asm_open(a, NULL) != 0)
return NULL; return NULL;
@ -246,10 +246,10 @@ int asm_guess_arch(Asm * a)
/* asm_instruction */ /* asm_instruction */
int asm_instruction(Asm * a, char const * name, unsigned int operands_cnt, ...) int asm_instruction(Asm * a, char const * name, unsigned int operands_cnt, ...)
{ {
ArchInstructionCall call; AsmArchInstructionCall call;
va_list ap; va_list ap;
size_t i; size_t i;
ArchOperand * operand; AsmArchOperand * operand;
memset(&call, 0, sizeof(call)); memset(&call, 0, sizeof(call));
call.name = name; call.name = name;
@ -258,7 +258,7 @@ int asm_instruction(Asm * a, char const * name, unsigned int operands_cnt, ...)
va_start(ap, operands_cnt); va_start(ap, operands_cnt);
for(i = 0; i < 3 && i < operands_cnt; i++) for(i = 0; i < 3 && i < operands_cnt; i++)
{ {
operand = va_arg(ap, ArchOperand *); operand = va_arg(ap, AsmArchOperand *);
memcpy(&call.operands[i], operand, sizeof(*operand)); memcpy(&call.operands[i], operand, sizeof(*operand));
} }
va_end(ap); va_end(ap);
@ -302,7 +302,7 @@ int asm_plugin_list(AsmPluginType type, int decode)
struct dirent * de; struct dirent * de;
size_t len; size_t len;
char const * sep = ""; char const * sep = "";
Arch * arch; AsmArch * arch;
Format * format; Format * format;
aspd = &_asm_plugin_description[type]; aspd = &_asm_plugin_description[type];

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -38,8 +38,8 @@
/* types */ /* types */
struct _AsmCode struct _AsmCode
{ {
Arch * arch; AsmArch * arch;
ArchDescription * description; AsmArchDescription * description;
Format * format; Format * format;
char * filename; char * filename;
FILE * fp; FILE * fp;
@ -237,7 +237,7 @@ char const * asmcode_get_arch(AsmCode * code)
/* asmcode_get_arch_description */ /* asmcode_get_arch_description */
ArchDescription * asmcode_get_arch_description(AsmCode * code) AsmArchDescription * asmcode_get_arch_description(AsmCode * code)
{ {
return arch_get_description(code->arch); return arch_get_description(code->arch);
} }
@ -406,7 +406,7 @@ int asmcode_decode(AsmCode * code, int raw)
/* asmcode_decode_at */ /* asmcode_decode_at */
int asmcode_decode_at(AsmCode * code, off_t offset, size_t size, off_t base, int asmcode_decode_at(AsmCode * code, off_t offset, size_t size, off_t base,
ArchInstructionCall ** calls, size_t * calls_cnt) AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s(%ld, %lu, %ld)\n", __func__, offset, size, fprintf(stderr, "DEBUG: %s(%ld, %lu, %ld)\n", __func__, offset, size,
@ -421,10 +421,10 @@ int asmcode_decode_at(AsmCode * code, off_t offset, size_t size, off_t base,
/* asmcode_decode_buffer */ /* asmcode_decode_buffer */
int asmcode_decode_buffer(AsmCode * code, char const * buffer, size_t size, int asmcode_decode_buffer(AsmCode * code, char const * buffer, size_t size,
ArchInstructionCall ** calls, size_t * calls_cnt) AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
int ret; int ret;
ArchDescription * description; AsmArchDescription * description;
arch_init_buffer(code->arch, buffer, size); arch_init_buffer(code->arch, buffer, size);
description = arch_get_description(code->arch); description = arch_get_description(code->arch);
@ -436,7 +436,7 @@ int asmcode_decode_buffer(AsmCode * code, char const * buffer, size_t size,
/* asmcode_decode_section */ /* asmcode_decode_section */
int asmcode_decode_section(AsmCode * code, AsmSection * section, int asmcode_decode_section(AsmCode * code, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt) AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
return format_decode_section(code->format, code, section, calls, return format_decode_section(code->format, code, section, calls,
calls_cnt); calls_cnt);
@ -451,9 +451,9 @@ int asmcode_function(AsmCode * code, char const * function)
/* asmcode_instruction */ /* asmcode_instruction */
int asmcode_instruction(AsmCode * code, ArchInstructionCall * call) int asmcode_instruction(AsmCode * code, AsmArchInstructionCall * call)
{ {
ArchInstruction * ai; AsmArchInstruction * ai;
if((ai = arch_get_instruction_by_call(code->arch, call)) == NULL) if((ai = arch_get_instruction_by_call(code->arch, call)) == NULL)
return -1; return -1;
@ -495,17 +495,17 @@ int asmcode_open(AsmCode * code, char const * filename)
/* asmcode_print */ /* asmcode_print */
static void _print_address(ArchDescription * description, static void _print_address(AsmArchDescription * description,
unsigned long address); unsigned long address);
static void _print_immediate(ArchOperand * ao); static void _print_immediate(AsmArchOperand * ao);
int asmcode_print(AsmCode * code, ArchInstructionCall * call) int asmcode_print(AsmCode * code, AsmArchInstructionCall * call)
{ {
ArchDescription * description; AsmArchDescription * description;
char const * sep = " "; char const * sep = " ";
size_t i; size_t i;
uint8_t u8; uint8_t u8;
ArchOperand * ao; AsmArchOperand * ao;
char const * name; char const * name;
description = arch_get_description(code->arch); description = arch_get_description(code->arch);
@ -562,7 +562,7 @@ int asmcode_print(AsmCode * code, ArchInstructionCall * call)
return 0; return 0;
} }
static void _print_address(ArchDescription * description, unsigned long address) static void _print_address(AsmArchDescription * description, unsigned long address)
{ {
uint32_t size = (description != NULL) ? description->address_size : 32; uint32_t size = (description != NULL) ? description->address_size : 32;
char const * format = "%8lx:"; char const * format = "%8lx:";
@ -581,7 +581,7 @@ static void _print_address(ArchDescription * description, unsigned long address)
printf(format, address); printf(format, address);
} }
static void _print_immediate(ArchOperand * ao) static void _print_immediate(AsmArchOperand * ao)
{ {
printf("%s$0x%lx", ao->value.immediate.negative ? "-" : "", printf("%s$0x%lx", ao->value.immediate.negative ? "-" : "",
(unsigned long)ao->value.immediate.value); (unsigned long)ao->value.immediate.value);

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -72,9 +72,9 @@ static int _deasm(char const * arch, char const * format, char const * filename,
static int _deasm_section(AsmCode * code, AsmSection * section) static int _deasm_section(AsmCode * code, AsmSection * section)
{ {
ArchDescription * description; AsmArchDescription * description;
size_t size; size_t size;
ArchInstructionCall * calls = NULL; AsmArchInstructionCall * calls = NULL;
size_t calls_cnt = 0; size_t calls_cnt = 0;
size_t i; size_t i;

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -61,7 +61,7 @@ static int _format_helper_set_string(Format * format, AsmStringId id,
char const * name, off_t offset, ssize_t size); char const * name, off_t offset, ssize_t size);
static int _format_helper_decode(Format * format, off_t offset, size_t size, static int _format_helper_decode(Format * format, off_t offset, size_t size,
off_t base, ArchInstructionCall ** calls, size_t * calls_cnt); off_t base, AsmArchInstructionCall ** calls, size_t * calls_cnt);
static ssize_t _format_helper_read(Format * format, void * buf, size_t size); static ssize_t _format_helper_read(Format * format, void * buf, size_t size);
static off_t _format_helper_seek(Format * format, off_t offset, int whence); static off_t _format_helper_seek(Format * format, off_t offset, int whence);
static ssize_t _format_helper_write(Format * format, void const * buf, static ssize_t _format_helper_write(Format * format, void const * buf,
@ -167,7 +167,7 @@ int format_decode(Format * format, AsmCode * code, int raw)
/* format_decode_section */ /* format_decode_section */
int format_decode_section(Format * format, AsmCode * code, AsmSection * section, int format_decode_section(Format * format, AsmCode * code, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt) AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
int ret; int ret;
@ -343,7 +343,7 @@ static int _format_helper_set_string(Format * format, AsmStringId id,
/* format_helper_decode */ /* format_helper_decode */
static int _format_helper_decode(Format * format, off_t offset, size_t size, static int _format_helper_decode(Format * format, off_t offset, size_t size,
off_t base, ArchInstructionCall ** calls, size_t * calls_cnt) off_t base, AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
int ret; int ret;

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -55,7 +55,7 @@ int format_section(Format * format, char const * section);
/* disassembly */ /* disassembly */
int format_decode(Format * format, AsmCode * code, int raw); int format_decode(Format * format, AsmCode * code, int raw);
int format_decode_section(Format * format, AsmCode * code, AsmSection * section, int format_decode_section(Format * format, AsmCode * code, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
char const * format_detect_arch(Format * format); char const * format_detect_arch(Format * format);
int format_match(Format * format); int format_match(Format * format);

View File

@ -127,7 +127,7 @@ static int _dex_exit(FormatPlugin * format);
static char const * _dex_detect(FormatPlugin * format); static char const * _dex_detect(FormatPlugin * format);
static int _dex_decode(FormatPlugin * format, int raw); static int _dex_decode(FormatPlugin * format, int raw);
static int _dex_decode_section(FormatPlugin * format, AsmSection * section, static int _dex_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
/* public */ /* public */
@ -366,7 +366,7 @@ static int _decode_map_string_id(FormatPlugin * format, off_t offset,
/* dex_decode_section */ /* dex_decode_section */
static int _dex_decode_section(FormatPlugin * format, AsmSection * section, static int _dex_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt) AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
FormatPluginHelper * helper = format->helper; FormatPluginHelper * helper = format->helper;
DexMapCodeItem dmci; DexMapCodeItem dmci;

View File

@ -83,7 +83,7 @@ static int _elf_decode(FormatPlugin * format, int raw);
static int _elf_decode32(FormatPlugin * format, int raw); static int _elf_decode32(FormatPlugin * format, int raw);
static int _elf_decode64(FormatPlugin * format, int raw); static int _elf_decode64(FormatPlugin * format, int raw);
static int _elf_decode_section(FormatPlugin * format, AsmSection * section, static int _elf_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
/* ELF32 */ /* ELF32 */
static int _init_32(FormatPlugin * format); static int _init_32(FormatPlugin * format);
@ -759,7 +759,7 @@ static int _decode64_symtab(FormatPlugin * format, Elf64_Ehdr * ehdr,
/* elf_decode_section */ /* elf_decode_section */
static int _elf_decode_section(FormatPlugin * format, AsmSection * section, static int _elf_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt) AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
FormatPluginHelper * helper = format->helper; FormatPluginHelper * helper = format->helper;

View File

@ -26,7 +26,7 @@
/* plug-in */ /* plug-in */
static int _flat_decode(FormatPlugin * format, int raw); static int _flat_decode(FormatPlugin * format, int raw);
static int _flat_decode_section(FormatPlugin * format, AsmSection * section, static int _flat_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
/* public */ /* public */
@ -66,7 +66,7 @@ static int _flat_decode(FormatPlugin * format, int raw)
/* flat_decode_section */ /* flat_decode_section */
static int _flat_decode_section(FormatPlugin * format, AsmSection * section, static int _flat_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt) AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
FormatPluginHelper * helper = format->helper; FormatPluginHelper * helper = format->helper;

View File

@ -147,7 +147,7 @@ static int _java_exit(FormatPlugin * format);
static char const * _java_detect(FormatPlugin * format); static char const * _java_detect(FormatPlugin * format);
static int _java_decode(FormatPlugin * format, int raw); static int _java_decode(FormatPlugin * format, int raw);
static int _java_decode_section(FormatPlugin * format, AsmSection * section, static int _java_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
/* public */ /* public */
@ -358,17 +358,17 @@ static int _java_decode(FormatPlugin * format, int raw)
/* java_decode_section */ /* java_decode_section */
static int _decode_attributes(FormatPlugin * format, uint16_t cnt, static int _decode_attributes(FormatPlugin * format, uint16_t cnt,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
static int _decode_constants(FormatPlugin * format, uint16_t cnt); static int _decode_constants(FormatPlugin * format, uint16_t cnt);
static int _decode_fields(FormatPlugin * format, uint16_t cnt); static int _decode_fields(FormatPlugin * format, uint16_t cnt);
static int _decode_interfaces(FormatPlugin * format, uint16_t cnt); static int _decode_interfaces(FormatPlugin * format, uint16_t cnt);
static int _decode_methods(FormatPlugin * format, uint16_t cnt, static int _decode_methods(FormatPlugin * format, uint16_t cnt,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
static int _methods_add(FormatPlugin * format, uint16_t id, uint16_t name, static int _methods_add(FormatPlugin * format, uint16_t id, uint16_t name,
off_t offset, size_t size); off_t offset, size_t size);
static int _java_decode_section(FormatPlugin * format, AsmSection * section, static int _java_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt) AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
FormatPluginHelper * helper = format->helper; FormatPluginHelper * helper = format->helper;
JavaPlugin * java = format->priv; JavaPlugin * java = format->priv;
@ -412,7 +412,7 @@ static int _java_decode_section(FormatPlugin * format, AsmSection * section,
} }
static int _decode_attributes(FormatPlugin * format, uint16_t cnt, static int _decode_attributes(FormatPlugin * format, uint16_t cnt,
ArchInstructionCall ** calls, size_t * calls_cnt) AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
FormatPluginHelper * helper = format->helper; FormatPluginHelper * helper = format->helper;
size_t i; size_t i;
@ -635,7 +635,7 @@ static int _decode_interfaces(FormatPlugin * format, uint16_t cnt)
} }
static int _decode_methods(FormatPlugin * format, uint16_t cnt, static int _decode_methods(FormatPlugin * format, uint16_t cnt,
ArchInstructionCall ** calls, size_t * calls_cnt) AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
FormatPluginHelper * helper = format->helper; FormatPluginHelper * helper = format->helper;
size_t i; size_t i;

View File

@ -214,7 +214,7 @@ static int _pe_init(FormatPlugin * format, char const * arch);
static char const * _pe_detect(FormatPlugin * format); static char const * _pe_detect(FormatPlugin * format);
static int _pe_decode(FormatPlugin * format, int raw); static int _pe_decode(FormatPlugin * format, int raw);
static int _pe_decode_section(FormatPlugin * format, AsmSection * section, static int _pe_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt); AsmArchInstructionCall ** calls, size_t * calls_cnt);
/* useful */ /* useful */
static char const * _pe_get_arch(uint16_t machine); static char const * _pe_get_arch(uint16_t machine);
@ -560,7 +560,7 @@ static char * _decode_string(FormatPlugin * format, off_t offset)
/* pe_decode_section */ /* pe_decode_section */
static int _pe_decode_section(FormatPlugin * format, AsmSection * section, static int _pe_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt) AsmArchInstructionCall ** calls, size_t * calls_cnt)
{ {
FormatPluginHelper * helper = format->helper; FormatPluginHelper * helper = format->helper;

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.
@ -35,7 +35,7 @@ typedef struct _State
unsigned int error_cnt; unsigned int error_cnt;
unsigned int warning_cnt; unsigned int warning_cnt;
AsmCode * code; AsmCode * code;
ArchInstructionCall call; AsmArchInstructionCall call;
} State; } State;
@ -533,7 +533,7 @@ static int _operand(State * state)
int ret = 0; int ret = 0;
TokenCode code; TokenCode code;
char const * string; char const * string;
ArchOperand * p; AsmArchOperand * p;
if(state->token == NULL) if(state->token == NULL)
return 1; return 1;

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.

View File

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */ /* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify /* 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License. * the Free Software Foundation, version 3 of the License.