Skip to content

Commit

Permalink
* More Makefile refactoring and cleanup
Browse files Browse the repository at this point in the history
* Minor cleanups in r_asm.h
* First work in r_anal
  • Loading branch information
jroimartin committed Feb 6, 2009
1 parent fcb58f1 commit 710adba
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 58 deletions.
4 changes: 4 additions & 0 deletions libr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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`; \
Expand Down
18 changes: 18 additions & 0 deletions libr/anal/anal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* radare - LGPL - Copyright 2009 nibble<[email protected]> */

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;
}
1 change: 0 additions & 1 deletion libr/cmd/t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ OBJ=test.o
BINDEPS=r_util r_cmd

include ../../rules.mk
include ../../tests.mk
1 change: 0 additions & 1 deletion libr/cons/t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ BIN=hello
#LIBS=../*.o ../../line/*.a ../../util/*.a

include ../../rules.mk
include ../../tests.mk
1 change: 0 additions & 1 deletion libr/core/t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ LIBS+=-ldl
LIBS+=-ldl

include ../../rules.mk
include ../../tests.mk
2 changes: 1 addition & 1 deletion libr/hash/t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ OBJ=hello.o
BIN=hello
LIBS=../*.o ../../io/*.o -lm

include ../../tests.mk
include ../../rules.mk
90 changes: 90 additions & 0 deletions libr/include/r_anal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/* radare - LGPL - Copyright 2009 nibble<[email protected]> */

#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
38 changes: 19 additions & 19 deletions libr/include/r_asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion libr/line/t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ BINDEPS=r_cons r_line r_util
# ${CC} ${LDFLAGS} ${OBJ} -o hello

include ../../rules.mk
include ../../tests.mk
1 change: 0 additions & 1 deletion libr/print/t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ OBJ=hex.o
BINDEPS=r_cons r_util r_line r_print

include ../../rules.mk
include ../../tests.mk
26 changes: 18 additions & 8 deletions libr/rules.mk
Original file line number Diff line number Diff line change
@@ -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))
Expand All @@ -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?=
Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion libr/syscall/t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ OBJ=hello.o
BIN=hello
LIBS=../*.o

include ../../tests.mk
include ../../rules.mk
24 changes: 0 additions & 24 deletions libr/tests.mk

This file was deleted.

0 comments on commit 710adba

Please sign in to comment.