summaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-04-25 16:51:41 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-04-25 16:51:41 (GMT)
commitb9977e00ff9eb6e025e86a15c858183f3f314cf5 (patch)
treeeedacb236b90228d2b4c603fa9875ecaad05ee29 /src/arch
parent216a3d0121fabd678e50ea6b4fa2447ae9b921f0 (diff)
Saved the current work on plugins.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@59 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch')
-rw-r--r--src/arch/Makefile.am9
-rw-r--r--src/arch/processor.c64
-rw-r--r--src/arch/processor.h4
-rw-r--r--src/arch/x86/processor.c3
4 files changed, 20 insertions, 60 deletions
diff --git a/src/arch/Makefile.am b/src/arch/Makefile.am
index 2f7f072..ad5e3c6 100644
--- a/src/arch/Makefile.am
+++ b/src/arch/Makefile.am
@@ -1,7 +1,7 @@
-lib_LIBRARIES = libarch.a
+lib_LTLIBRARIES = libarch.la
-libarch_a_SOURCES = \
+libarch_la_SOURCES = \
instruction-int.h \
instruction.h instruction.c \
operand-int.h \
@@ -9,7 +9,10 @@ libarch_a_SOURCES = \
processor-int.h \
processor.h processor.c
-libarch_a_CFLAGS = $(AM_CFLAGS)
+libarch_la_LIBADD = \
+ x86/libarchx86.a
+
+libarch_la_LDFLAGS =
INCLUDES = $(LIBGTK_CFLAGS)
diff --git a/src/arch/processor.c b/src/arch/processor.c
index d367949..a67986d 100644
--- a/src/arch/processor.c
+++ b/src/arch/processor.c
@@ -24,16 +24,21 @@
#include "processor.h"
-#include <regex.h>
-#include <string.h>
#include "instruction-int.h"
#include "processor-int.h"
+#include "x86/processor.h"
+asm_processor *create_processor(void)
+{
+ return create_x86_processor();
+
+}
+
/******************************************************************************
@@ -72,7 +77,7 @@ asm_instr *decode_instruction(const asm_processor *proc, const uint8_t *data, of
{
*pos = old_pos;
- printf("err while decoding opcode 0x%02hhx at 0x%08llx\n", data[*pos], offset);
+ //printf("err while decoding opcode 0x%02hhx at 0x%08llx\n", data[*pos], offset);
result = create_db_instruction(data, pos, len);
}
@@ -88,59 +93,6 @@ asm_instr *decode_instruction(const asm_processor *proc, const uint8_t *data, of
}
-/******************************************************************************
-* *
-* Paramètres : input = chaîne de caractères à traiter. *
-* *
-* Description : S'assure qu'une chaîne de caractère tient sur une ligne. *
-* *
-* Retour : Adresse de la chaîne de caractères modifiée. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-char *escape_crlf_bin_string(char *input)
-{
- size_t inlen;
- regex_t preg;
- int ret;
- size_t curpos;
- regmatch_t pmatch[2];
-
- inlen = strlen(input);
-
- ret = regcomp(&preg, "(\t|\n|\r)", REG_EXTENDED | REG_ICASE);
- /* TODO: ret */
-
- for (curpos = 0; regexec(&preg, &input[curpos], 2, pmatch, 0) != REG_NOMATCH; )
- {
- inlen += 1 + 1;
- input = (char *)realloc(input, inlen * sizeof(char *));
-
- memmove(&input[curpos + pmatch[1].rm_eo + 1], &input[curpos + pmatch[1].rm_eo], inlen - 1 - curpos - pmatch[1].rm_eo);
-
- switch (input[curpos + pmatch[1].rm_so])
- {
- case '\t':
- memcpy(&input[curpos + pmatch[1].rm_so], "\\t", 2);
- break;
- case '\n':
- memcpy(&input[curpos + pmatch[1].rm_so], "\\n", 2);
- break;
- case '\r':
- memcpy(&input[curpos + pmatch[1].rm_so], "\\r", 2);
- break;
- }
-
- curpos += pmatch[1].rm_eo + 1;
-
- }
-
- return input;
-
-}
-
/******************************************************************************
* *
diff --git a/src/arch/processor.h b/src/arch/processor.h
index 343a98c..6c65e95 100644
--- a/src/arch/processor.h
+++ b/src/arch/processor.h
@@ -53,6 +53,10 @@ typedef struct _asm_processor asm_processor;
+asm_processor *create_processor(void);
+
+
+
/* Décode une instruction dans un flux de données. */
asm_instr *decode_instruction(const asm_processor *, const uint8_t *, off_t *, off_t, off_t, uint64_t);
diff --git a/src/arch/x86/processor.c b/src/arch/x86/processor.c
index 15d26a4..b6f5c30 100644
--- a/src/arch/x86/processor.c
+++ b/src/arch/x86/processor.c
@@ -32,6 +32,7 @@
#include "instruction.h"
#include "opcodes.h"
#include "operand.h"
+#include "../../common/extstr.h"
@@ -517,7 +518,7 @@ void x86_print_instruction(const asm_x86_processor *proc, const exe_format *form
break;
case STP_STRING:
- label = escape_crlf_bin_string(label);
+ label = escape_crlf(label);
snprintf(&opbuffer[i][oplen], 256 - oplen, " \"%s\"", label);
break;