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

View File

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

View File

@ -1,6 +1,6 @@
/* $Id$ */
/* 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
* it under the terms of the GNU General Public License as published by
* 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 */
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);
/* plug-in helpers */

View File

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

View File

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

View File

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

View File

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

View File

@ -46,13 +46,13 @@ enum
/* 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 },
static ArchRegister _amd64_registers[] =
static AsmArchRegister _amd64_registers[] =
{
#include "i386.reg"
#include "i686.reg"
@ -61,7 +61,7 @@ static ArchRegister _amd64_registers[] =
};
#undef REG
static ArchInstruction _amd64_instructions[] =
static AsmArchInstruction _amd64_instructions[] =
{
#include "i386.ins"
#include "i486.ins"
@ -79,7 +79,7 @@ static ArchInstruction _amd64_instructions[] =
/* public */
/* variables */
/* plug-in */
ArchPlugin arch_plugin =
AsmArchPlugin arch_plugin =
{
NULL,
"amd64",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -44,20 +44,20 @@ enum
/* 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 },
static ArchRegister _i386_real_registers[] =
static AsmArchRegister _i386_real_registers[] =
{
#include "i386.reg"
{ NULL, 0, 0 }
};
#undef REG
static ArchInstruction _i386_real_instructions[] =
static AsmArchInstruction _i386_real_instructions[] =
{
#include "i386.ins"
#include "common.ins"
@ -72,7 +72,7 @@ static ArchInstruction _i386_real_instructions[] =
/* public */
/* variables */
/* plug-in */
ArchPlugin arch_plugin =
AsmArchPlugin arch_plugin =
{
NULL,
"i386_real",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */
/* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
@ -38,8 +38,8 @@
/* types */
struct _AsmCode
{
Arch * arch;
ArchDescription * description;
AsmArch * arch;
AsmArchDescription * description;
Format * format;
char * filename;
FILE * fp;
@ -237,7 +237,7 @@ char const * asmcode_get_arch(AsmCode * code)
/* asmcode_get_arch_description */
ArchDescription * asmcode_get_arch_description(AsmCode * code)
AsmArchDescription * asmcode_get_arch_description(AsmCode * code)
{
return arch_get_description(code->arch);
}
@ -406,7 +406,7 @@ int asmcode_decode(AsmCode * code, int raw)
/* asmcode_decode_at */
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
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 */
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;
ArchDescription * description;
AsmArchDescription * description;
arch_init_buffer(code->arch, buffer, size);
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 */
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,
calls_cnt);
@ -451,9 +451,9 @@ int asmcode_function(AsmCode * code, char const * function)
/* 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)
return -1;
@ -495,17 +495,17 @@ int asmcode_open(AsmCode * code, char const * filename)
/* asmcode_print */
static void _print_address(ArchDescription * description,
static void _print_address(AsmArchDescription * description,
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 = " ";
size_t i;
uint8_t u8;
ArchOperand * ao;
AsmArchOperand * ao;
char const * name;
description = arch_get_description(code->arch);
@ -562,7 +562,7 @@ int asmcode_print(AsmCode * code, ArchInstructionCall * call)
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;
char const * format = "%8lx:";
@ -581,7 +581,7 @@ static void _print_address(ArchDescription * description, unsigned long address)
printf(format, address);
}
static void _print_immediate(ArchOperand * ao)
static void _print_immediate(AsmArchOperand * ao)
{
printf("%s$0x%lx", ao->value.immediate.negative ? "-" : "",
(unsigned long)ao->value.immediate.value);

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */
/* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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)
{
ArchDescription * description;
AsmArchDescription * description;
size_t size;
ArchInstructionCall * calls = NULL;
AsmArchInstructionCall * calls = NULL;
size_t calls_cnt = 0;
size_t i;

View File

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

View File

@ -1,6 +1,6 @@
/* $Id$ */
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel asm */
/* Copyright (c) 2011-2012 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Devel Asm */
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
@ -55,7 +55,7 @@ int format_section(Format * format, char const * section);
/* disassembly */
int format_decode(Format * format, AsmCode * code, int raw);
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);
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 int _dex_decode(FormatPlugin * format, int raw);
static int _dex_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt);
AsmArchInstructionCall ** calls, size_t * calls_cnt);
/* public */
@ -366,7 +366,7 @@ static int _decode_map_string_id(FormatPlugin * format, off_t offset,
/* dex_decode_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;
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_decode64(FormatPlugin * format, int raw);
static int _elf_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt);
AsmArchInstructionCall ** calls, size_t * calls_cnt);
/* ELF32 */
static int _init_32(FormatPlugin * format);
@ -759,7 +759,7 @@ static int _decode64_symtab(FormatPlugin * format, Elf64_Ehdr * ehdr,
/* elf_decode_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;

View File

@ -26,7 +26,7 @@
/* plug-in */
static int _flat_decode(FormatPlugin * format, int raw);
static int _flat_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt);
AsmArchInstructionCall ** calls, size_t * calls_cnt);
/* public */
@ -66,7 +66,7 @@ static int _flat_decode(FormatPlugin * format, int raw)
/* flat_decode_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;

View File

@ -147,7 +147,7 @@ static int _java_exit(FormatPlugin * format);
static char const * _java_detect(FormatPlugin * format);
static int _java_decode(FormatPlugin * format, int raw);
static int _java_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt);
AsmArchInstructionCall ** calls, size_t * calls_cnt);
/* public */
@ -358,17 +358,17 @@ static int _java_decode(FormatPlugin * format, int raw)
/* java_decode_section */
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_fields(FormatPlugin * format, uint16_t cnt);
static int _decode_interfaces(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,
off_t offset, size_t size);
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;
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,
ArchInstructionCall ** calls, size_t * calls_cnt)
AsmArchInstructionCall ** calls, size_t * calls_cnt)
{
FormatPluginHelper * helper = format->helper;
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,
ArchInstructionCall ** calls, size_t * calls_cnt)
AsmArchInstructionCall ** calls, size_t * calls_cnt)
{
FormatPluginHelper * helper = format->helper;
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 int _pe_decode(FormatPlugin * format, int raw);
static int _pe_decode_section(FormatPlugin * format, AsmSection * section,
ArchInstructionCall ** calls, size_t * calls_cnt);
AsmArchInstructionCall ** calls, size_t * calls_cnt);
/* useful */
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 */
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;

View File

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

View File

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

View File

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

View File

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

View File

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