* More Makefile refactoring and cleanup

* Minor cleanups in r_asm.h
* First work in r_anal
This commit is contained in:
Nibble 2009-02-06 18:22:27 +01:00
parent fcb58f1ff7
commit 710adba920
13 changed files with 151 additions and 58 deletions

View File

@ -33,6 +33,10 @@ install:
@mkdir -p ${PREFIX}/bin
@for a in `find */t -perm /u+x -type f | grep 2`; \
do echo " $$a"; cp $$a ${PREFIX}/bin ; done
# plugins
@mkdir -p ${PREFIX}/plugins
@for a in `find */p -perm /u+x -type f`; \
do echo " $$a"; cp $$a ${PREFIX}/plugins ; done
# test programs
@mkdir -p ${PREFIX}/bin-test
@for a in `find */t -perm /u+x -type f | grep -v 2`; \

18
libr/anal/anal.c Normal file
View File

@ -0,0 +1,18 @@
/* radare - LGPL - Copyright 2009 nibble<.ds@gmail.com> */
struct r_anal_t *r_anal_new()
{
struct r_anal_t *a = MALLOC_STRUCT(struct r_anal_t);
r_asm_init(a);
return a;
}
void r_anal_free(struct r_anal_t *a)
{
free(a);
}
int r_anal_init(struct r_anal_t *a)
{
return R_TRUE;
}

View File

@ -3,4 +3,3 @@ OBJ=test.o
BINDEPS=r_util r_cmd
include ../../rules.mk
include ../../tests.mk

View File

@ -4,4 +4,3 @@ BIN=hello
#LIBS=../*.o ../../line/*.a ../../util/*.a
include ../../rules.mk
include ../../tests.mk

View File

@ -60,4 +60,3 @@ LIBS+=-ldl
LIBS+=-ldl
include ../../rules.mk
include ../../tests.mk

View File

@ -2,4 +2,4 @@ OBJ=hello.o
BIN=hello
LIBS=../*.o ../../io/*.o -lm
include ../../tests.mk
include ../../rules.mk

90
libr/include/r_anal.h Normal file
View File

@ -0,0 +1,90 @@
/* radare - LGPL - Copyright 2009 nibble<.ds@gmail.com> */
#ifndef _INCLUDE_R_ANAL_H_
#define _INCLUDE_R_ANAL_H_
#include "r_types.h"
enum {
R_ANAL_AOP_NULL = 0,
R_ANAL_AOP_TYPE_JMP, /* mandatory jump */
R_ANAL_AOP_TYPE_UJMP, /* unknown jump (register or so) */
R_ANAL_AOP_TYPE_CJMP, /* conditional jump */
R_ANAL_AOP_TYPE_CALL, /* call to subroutine (branch+link) */
R_ANAL_AOP_TYPE_RCALL, /* call to register */
R_ANAL_AOP_TYPE_REP, /* repeats next instruction N times */
R_ANAL_AOP_TYPE_RET, /* returns from subrutine */
R_ANAL_AOP_TYPE_ILL, /* illegal instruction // trap */
R_ANAL_AOP_TYPE_UNK, /* unknown opcode type */
R_ANAL_AOP_TYPE_NOP, /* does nothing */
R_ANAL_AOP_TYPE_MOV, /* register move */
R_ANAL_AOP_TYPE_TRAP, /* it's a trap! */
R_ANAL_AOP_TYPE_SWI, /* syscall, software interrupt */
R_ANAL_AOP_TYPE_UPUSH, /* unknown push of data into stack */
R_ANAL_AOP_TYPE_PUSH, /* push value into stack */
R_ANAL_AOP_TYPE_POP, /* pop value from stack to register */
R_ANAL_AOP_TYPE_CMP, /* copmpare something */
R_ANAL_AOP_TYPE_ADD,
R_ANAL_AOP_TYPE_SUB,
R_ANAL_AOP_TYPE_MUL,
R_ANAL_AOP_TYPE_DIV,
R_ANAL_AOP_TYPE_SHR,
R_ANAL_AOP_TYPE_SHL,
R_ANAL_AOP_TYPE_OR,
R_ANAL_AOP_TYPE_AND,
R_ANAL_AOP_TYPE_XOR,
R_ANAL_AOP_TYPE_NOT,
R_ANAL_AOP_TYPE_STORE, /* store from register to memory */
R_ANAL_AOP_TYPE_LOAD /* load from memory to register */
};
enum {
R_ANAL_DATA_NULL = 0,
R_ANAL_DATA_HEX, /* hex byte pairs */
R_ANAL_DATA_STR, /* ascii string */
R_ANAL_DATA_CODE, /* plain assembly code */
R_ANAL_DATA_FUN, /* plain assembly code */
R_ANAL_DATA_STRUCT /* memory */
};
enum {
R_ANAL_BLK_TYPE_NULL = 0,
R_ANAL_BLK_TYPE_HEAD, /* first block */
R_ANAL_BLK_TYPE_BODY, /* conditional jump */
R_ANAL_BLK_TYPE_LAST, /* ret */
R_ANAL_BLK_TYPE_FOOT /* unknown jump */
};
enum {
R_ANAL_STACK_NULL = 0,
R_ANAL_STACK_NOP, /* sub $0xc, %esp */
R_ANAL_STACK_INCSTACK, /* sub $0xc, %esp */
R_ANAL_STACK_LOCAL_GET,
R_ANAL_STACK_LOCAL_SET,
R_ANAL_STACK_ARG_GET,
R_ANAL_STACK_ARG_SET
};
struct r_anal_aop_t {
int type; /* type of opcode */
int stackop; /* operation on stack? */
int length; /* length in bytes of opcode */
int eob; /* end of block (boolean) */
u64 jump; /* true jmp */
u64 fail; /* false jmp */
u64 ref; /* referente to memory */
u64 value; /* referente to value */
int r_dst,r_src1,r_src2; /* register arguments */
u64 i_dst,i_src1,i_src2; /* inmediate arguments */
};
struct r_anal_t {
};
/* anal.c */
struct r_anal_t *r_anal_new();
void r_anal_free(struct r_anal_t *a);
int r_anal_init(struct r_anal_t *a);
#endif

View File

@ -6,31 +6,31 @@
#include "r_types.h"
enum {
R_ASM_ARCH_NULL = 0,
R_ASM_ARCH_X86 = 1,
R_ASM_ARCH_ARM = 2,
R_ASM_ARCH_PPC = 3,
R_ASM_ARCH_M68K = 4,
R_ASM_ARCH_JAVA = 5,
R_ASM_ARCH_MIPS = 6,
R_ASM_ARCH_SPARC = 7,
R_ASM_ARCH_CSR = 8,
R_ASM_ARCH_MSIL = 9,
R_ASM_ARCH_OBJD = 10,
R_ASM_ARCH_BF = 11
R_ASM_ARCH_NULL = 0,
R_ASM_ARCH_X86,
R_ASM_ARCH_ARM,
R_ASM_ARCH_PPC,
R_ASM_ARCH_M68K,
R_ASM_ARCH_JAVA,
R_ASM_ARCH_MIPS,
R_ASM_ARCH_SPARC,
R_ASM_ARCH_CSR,
R_ASM_ARCH_MSIL,
R_ASM_ARCH_OBJD,
R_ASM_ARCH_BF
};
enum {
R_ASM_SYN_NULL = 0,
R_ASM_SYN_INTEL = 1,
R_ASM_SYN_ATT = 2,
R_ASM_SYN_OLLY = 3
R_ASM_SYN_NULL = 0,
R_ASM_SYN_INTEL,
R_ASM_SYN_ATT,
R_ASM_SYN_OLLY
};
enum {
R_ASM_PAR_NULL = 0,
R_ASM_PAR_PSEUDO = 1,
R_ASM_PAR_REALLOC = 2
R_ASM_PAR_NULL = 0,
R_ASM_PAR_PSEUDO,
R_ASM_PAR_REALLOC
};
struct r_asm_t {

View File

@ -8,4 +8,3 @@ BINDEPS=r_cons r_line r_util
# ${CC} ${LDFLAGS} ${OBJ} -o hello
include ../../rules.mk
include ../../tests.mk

View File

@ -3,4 +3,3 @@ OBJ=hex.o
BINDEPS=r_cons r_util r_line r_print
include ../../rules.mk
include ../../tests.mk

View File

@ -1,9 +1,3 @@
ifeq (${BINDEPS},)
include ../config.mk
else
include ../../config.mk
endif
CFLAGS+=-DUSE_RIO=${USE_RIO}
CFLAGS+=${CFLAGS_APPEND}
LDFLAGS+=$(subst r_,-lr_,$(DEPS))
@ -16,7 +10,7 @@ LDFLAGS+=$(subst r_,${BOO},$(BINDEPS))
# Compiler
CC?=gcc
CFLAGS+=-I../include -fPIC
CFLAGS+=-fPIC
CC_LIB=${CC} -shared -o ${LIBSO}
CC_AR=ar -r ${LIBAR}
LINK?=
@ -32,7 +26,10 @@ LIBAR=${LIB}.${EXT_AR}
LIBSO=${LIB}.${EXT_SO}
# ${LIBAR}
# Rules
ifeq (${BINDEPS},)
ifneq ($(NAME),)
include ../config.mk
CFLAGS+=-I../include
all: ${LIBSO}
echo $(NAME)
@-if [ -e t/Makefile ]; then (cd t && ${MAKE} all) ; fi
@ -51,6 +48,19 @@ clean:
@if [ -e t/Makefile ]; then (cd t && ${MAKE} clean) ; fi
@if [ -e p/Makefile ]; then (cd p && ${MAKE} clean) ; fi
@true
.PHONY: all clean ${LIBSO} ${LIBAR}
endif
else
include ../../config.mk
CFLAGS+=-I../../include
all: ${BIN}
@true
${BIN}: ${OBJ}
${CC} ${LDFLAGS} ${OBJ} -o ${BIN} ${LIBS}
clean:
-rm -f ${OBJ} ${BIN}
.PHONY: all clean ${BIN}
endif

View File

@ -2,4 +2,4 @@ OBJ=hello.o
BIN=hello
LIBS=../*.o
include ../../tests.mk
include ../../rules.mk

View File

@ -1,24 +0,0 @@
# Compiler
CC?=gcc
CFLAGS+=-I../../include -fPIC
LIBS?=
# Output
EXT_AR=a
EXT_SO=so
LIBAR=${LIB}.${EXT_AR}
LIBSO=${LIB}.${EXT_SO}
# Rules
ifeq ($(NAME),)
all: ${BIN}
@true
${BIN}: ${OBJ}
${CC} ${LDFLAGS} ${OBJ} -o ${BIN} ${LIBS}
clean:
-rm -f ${OBJ} ${BIN}
.PHONY: all clean ${BIN}
endif