diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000000..9ac37bc79e --- /dev/null +++ b/AUTHORS @@ -0,0 +1,4 @@ +Main developers aka /dev/radare + + - pancake + - nibble.ds diff --git a/libr/Makefile b/libr/Makefile index 0268e82b09..de7d1002e3 100644 --- a/libr/Makefile +++ b/libr/Makefile @@ -1,8 +1,8 @@ # XXX -PREFIX=/tmp/libr-install +PREFIX=../prefix # Libraries -LIBLIST=io io/p util lib lang bin macro hash line cons print config flags syscall range socket cmd asm search diff debug reg core +LIBLIST=io util lib lang flags bin macro hash line cons line print config syscall range socket cmd asm search diff debug reg core # Under development @@ -31,10 +31,11 @@ install: cp -f include/* ${PREFIX}/include # programs @mkdir -p ${PREFIX}/bin - cp -f util/t/rax2 ${PREFIX}/bin + @for a in `find */t -perm /u+x -type f | grep 2`; \ + do echo " $$a"; cp $$a ${PREFIX}/bin ; done # test programs @mkdir -p ${PREFIX}/bin-test - @for a in `find */t -perm /u+x -type f`; \ + @for a in `find */t -perm /u+x -type f | grep -v 2`; \ do echo " $$a"; cp $$a ${PREFIX}/bin-test ; done @echo libr aka radare2 has been installed in PREFIX=${PREFIX} diff --git a/libr/TODO b/libr/TODO index da9246c041..7d26fee314 100644 --- a/libr/TODO +++ b/libr/TODO @@ -6,6 +6,11 @@ ----------------------------------------[ todo +|| search || +------------ + - implement r_search_xrefs + - configure before throw the search + || asm || --------- - Add support for more architectures diff --git a/libr/asm/Makefile b/libr/asm/Makefile index 86e063e9ad..317c645ed5 100644 --- a/libr/asm/Makefile +++ b/libr/asm/Makefile @@ -1,5 +1,7 @@ NAME=r_asm OBJ=asm.o +DEPS=r_util + CFLAGS+=-Iarch/include # XXX CFLAGS+=-DLIL_ENDIAN=1 diff --git a/libr/asm/t/Makefile b/libr/asm/t/Makefile index 36ed1037e4..58e3a34483 100644 --- a/libr/asm/t/Makefile +++ b/libr/asm/t/Makefile @@ -1,31 +1,33 @@ +LDFLAGS=-L../../util -lr_util -L../ -lr_asm +LDFLAGS_BIN=${LDFLAGS} -lr_bin -L../../bin all: disasm_x86 disasm_arm disasm_mips disasm_sparc disasm_ppc disasm_bf asm_x86 rasm2 realloc_x86 disasm_x86: - ${CC} -g -I ../../include disasm_x86.c ../libr_asm.a ../../util/*.a -o disasm_x86 + ${CC} -g -I ../../include disasm_x86.c ${LDFLAGS} -o disasm_x86 disasm_arm: - ${CC} -g -I ../../include disasm_arm.c ../libr_asm.a ../../util/*.a -o disasm_arm + ${CC} -g -I ../../include disasm_arm.c ${LDFLAGS} -o disasm_arm disasm_mips: - ${CC} -g -I ../../include disasm_mips.c ../libr_asm.a ../../util/*.a -o disasm_mips + ${CC} -g -I ../../include disasm_mips.c ${LDFLAGS} -o disasm_mips disasm_sparc: - ${CC} -g -I ../../include disasm_sparc.c ../libr_asm.a ../../util/*.a -o disasm_sparc + ${CC} -g -I ../../include disasm_sparc.c ${LDFLAGS} -o disasm_sparc disasm_ppc: - ${CC} -g -I ../../include disasm_ppc.c ../libr_asm.a ../../util/*.a -o disasm_ppc + ${CC} -g -I ../../include disasm_ppc.c ${LDFLAGS} -o disasm_ppc disasm_bf: - ${CC} -g -I ../../include disasm_bf.c ../libr_asm.a ../../util/*.a -o disasm_bf + ${CC} -g -I ../../include disasm_bf.c ${LDFLAGS} -o disasm_bf asm_x86: - ${CC} -g -I ../../include asm_x86.c ../libr_asm.a ../../util/*.a -o asm_x86 + ${CC} -g -I ../../include asm_x86.c ${LDFLAGS} -o asm_x86 rasm2: - ${CC} -g -I ../../include rasm2.c ../libr_asm.a ../../util/*.a -o rasm2 + ${CC} -g -I ../../include rasm2.c ${LDFLAGS} -o rasm2 realloc_x86: - ${CC} -g -I ../../include realloc_x86.c ../libr_asm.a ../../bin/*.a ../../util/*.a -o realloc_x86 + ${CC} -g -I ../../include realloc_x86.c ${LDFLAGS_BIN} -o realloc_x86 clean: rm -f disasm_x86 disasm_arm disasm_mips disasm_sparc disasm_ppc disasm_bf asm_x86 rasm2 realloc_x86 diff --git a/libr/asm/t/rasm2.c b/libr/asm/t/rasm2.c index 23f48bac9b..16eaaf46ed 100644 --- a/libr/asm/t/rasm2.c +++ b/libr/asm/t/rasm2.c @@ -43,11 +43,13 @@ static int rasm_disasm(char *buf, u64 offset, char *arch, char *syntax, int big_ r_asm_set_arch(&a, R_ASM_ARCH_ARM); else r_asm_set_arch(&a, R_ASM_ARCH_X86); - if (!strcmp(syntax, "att")) - r_asm_set_syntax(&a, R_ASM_SYN_ATT); - else if (!strcmp(syntax, "olly")) - r_asm_set_syntax(&a, R_ASM_SYN_OLLY); - else r_asm_set_syntax(&a, R_ASM_SYN_INTEL); + if (syntax != NULL) { + if (!strcmp(syntax, "att")) + r_asm_set_syntax(&a, R_ASM_SYN_ATT); + else if (!strcmp(syntax, "olly")) + r_asm_set_syntax(&a, R_ASM_SYN_OLLY); + else r_asm_set_syntax(&a, R_ASM_SYN_INTEL); + } r_asm_set_big_endian(&a, big_endian); r_asm_set_pc(&a, offset); diff --git a/libr/bin/t/Makefile b/libr/bin/t/Makefile index 115a5eae57..a5ec4f57cc 100644 --- a/libr/bin/t/Makefile +++ b/libr/bin/t/Makefile @@ -15,7 +15,8 @@ imports: data_resize: ${CC} -g -I ../../include data_resize.c ../*.o -o data_resize rabin2: - ${CC} -g -I ../../include rabin2.c ../*.a ../../util/*.a ../../flags/*.a -o rabin2 + ${CC} -g -I ../../include rabin2.c -lr_bin -lr_util -lr_flags \ + -L.. -L../..bin -L../../flags -L../../util -o rabin2 clean: rm -f baddr entry info sections symbols imports data_resize rabin2 diff --git a/libr/cmd/Makefile b/libr/cmd/Makefile index bae87ad7ed..7ec5d5b092 100644 --- a/libr/cmd/Makefile +++ b/libr/cmd/Makefile @@ -1,4 +1,5 @@ NAME=r_cmd OBJ=cmd.o +DEPS=r_util include ../rules.mk diff --git a/libr/cmd/t/Makefile b/libr/cmd/t/Makefile index 8c026cb4bd..53cbc1ae6d 100644 --- a/libr/cmd/t/Makefile +++ b/libr/cmd/t/Makefile @@ -1,7 +1,6 @@ -all: test +BIN=test +OBJ=test.o +BINDEPS=r_util r_cmd -test: - ${CC} -g -I ../../include test.c ../*.o ../../util/*.a -o test - -clean: - rm -f test test.o +include ../../rules.mk +include ../../tests.mk diff --git a/libr/config/Makefile b/libr/config/Makefile index 86e8a67e58..058f7df29d 100644 --- a/libr/config/Makefile +++ b/libr/config/Makefile @@ -1,4 +1,5 @@ NAME=r_config +DEPS=r_util OBJ=config.o callback.o diff --git a/libr/cons/Makefile b/libr/cons/Makefile index d3adab4dae..14bc56a2a7 100644 --- a/libr/cons/Makefile +++ b/libr/cons/Makefile @@ -1,5 +1,7 @@ NAME=r_cons OBJ=cons.o strsub.o pipe.o print.o input.o color.o -LINK=../line/*.o ../util/*.a +DEPS=r_util +#r_line ?? +#LINK=../line/*.o ../util/*.a include ../rules.mk diff --git a/libr/cons/t/Makefile b/libr/cons/t/Makefile index 40f05d5cfe..0f86c4ee05 100644 --- a/libr/cons/t/Makefile +++ b/libr/cons/t/Makefile @@ -1,5 +1,7 @@ OBJ=hello.o +BINDEPS=r_line r_util r_cons BIN=hello -LIBS=../*.o ../../line/*.a ../../util/*.a +#LIBS=../*.o ../../line/*.a ../../util/*.a +include ../../rules.mk include ../../tests.mk diff --git a/libr/core/Makefile b/libr/core/Makefile index 5a06edffff..8e2caaa1c1 100644 --- a/libr/core/Makefile +++ b/libr/core/Makefile @@ -1,4 +1,5 @@ NAME=r_core +DEPS=r_config r_cons r_line r_io r_cmd r_util r_print r_flags r_asm r_lib r_macro r_debug r_hash r_bin r_lang r_io r_asm r_config r_macro r_print OBJ=core.o cmd.o file.o config.o visual.o io.o diff --git a/libr/core/core.c b/libr/core/core.c index 3c761e193e..141ff92923 100644 --- a/libr/core/core.c +++ b/libr/core/core.c @@ -97,7 +97,7 @@ int r_core_init(struct r_core_t *core) &__lib_dbg_cb, &__lib_dbg_dt, core); r_lib_add_handler(&core->lib, R_LIB_TYPE_LNG, "language plugins", &__lib_lng_cb, &__lib_lng_dt, core); - r_lib_opendir(&core->lib, "/home/pancake/prg/radare/src/libr/io/plugins"); + r_lib_opendir(&core->lib, getenv("LIBR_PLUGINS")); { char *homeplugindir = r_str_home(".radare/plugins"); r_lib_opendir(&core->lib, homeplugindir); diff --git a/libr/core/t/Makefile b/libr/core/t/Makefile index da64639a9d..13be8bd09c 100644 --- a/libr/core/t/Makefile +++ b/libr/core/t/Makefile @@ -1,42 +1,44 @@ OBJ=radare2.o BIN=radare2 +BINDEPS=r_core r_cons r_macro r_util r_flags r_lib r_io r_hash r_cmd r_config r_asm r_lang r_debug r_print r_line r_bin -## shared -LIBS=../*.o \ - -Wl,-R../../config/ \ - -Wl,-R../../cons/ \ - -Wl,-R../../line/ \ - -Wl,-R../../io/ \ - -Wl,-R../../cmd/ \ - -Wl,-R../../util/ \ - -Wl,-R../../print/ \ - -Wl,-R../../flags/ \ - -Wl,-R../../asm/ \ - -Wl,-R../../lib/ \ - -Wl,-R../../macro/ \ - -Wl,-R../../debug/ \ - -Wl,-R../../hash/ \ - -Wl,-R../../bin/ \ - -Wl,-R../../lang/ \ - -Wl,-R../ \ - -L../../config/ \ - -L../../cons/ \ - -L../../lang/ \ - -L../../line/ \ - -L../../io/ \ - -L../../cmd/ \ - -L../../util/ \ - -L../../print/ \ - -L../../flags/ \ - -L../../asm/ \ - -L../../lib/ \ - -L../../macro/ \ - -L../../debug/ \ - -L../../hash/ \ - -L../../bin/ \ - -L../ \ - -lr_core -lr_config -lr_cons -lr_line -lr_cmd -lr_util -lr_print \ - -lr_flags -lr_asm -lr_lib -lr_macro -lr_debug -lr_bin -lr_io -lr_hash -lr_lang +#LIBS=-lr_core -L.. +### shared +#LIBS=../*.o \ +# -Wl,-R../../config/ \ +# -Wl,-R../../cons/ \ +# -Wl,-R../../line/ \ +# -Wl,-R../../io/ \ +# -Wl,-R../../cmd/ \ +# -Wl,-R../../util/ \ +# -Wl,-R../../print/ \ +# -Wl,-R../../flags/ \ +# -Wl,-R../../asm/ \ +# -Wl,-R../../lib/ \ +# -Wl,-R../../macro/ \ +# -Wl,-R../../debug/ \ +# -Wl,-R../../hash/ \ +# -Wl,-R../../bin/ \ +# -Wl,-R../../lang/ \ +# -Wl,-R../ \ +# -L../../config/ \ +# -L../../cons/ \ +# -L../../lang/ \ +# -L../../line/ \ +# -L../../io/ \ +# -L../../cmd/ \ +# -L../../util/ \ +# -L../../print/ \ +# -L../../flags/ \ +# -L../../asm/ \ +# -L../../lib/ \ +# -L../../macro/ \ +# -L../../debug/ \ +# -L../../hash/ \ +# -L../../bin/ \ +# -L../ \ +# -lr_core -lr_config -lr_cons -lr_line -lr_cmd -lr_util -lr_print \ +# -lr_flags -lr_asm -lr_lib -lr_macro -lr_debug -lr_bin -lr_io -lr_hash -lr_lang LIBS+=-ldl # static @@ -57,4 +59,5 @@ LIBS+=-ldl ../../hash/*.a LIBS+=-ldl +include ../../rules.mk include ../../tests.mk diff --git a/libr/diff/Makefile b/libr/diff/Makefile index 1ece33e6f4..a6448a288b 100644 --- a/libr/diff/Makefile +++ b/libr/diff/Makefile @@ -1,4 +1,5 @@ NAME=r_diff OBJ=diff.o +DEPS=r_util include ../rules.mk diff --git a/libr/diff/t/Makefile b/libr/diff/t/Makefile index bbeafdf1cb..88ff9f4f76 100644 --- a/libr/diff/t/Makefile +++ b/libr/diff/t/Makefile @@ -1,10 +1,17 @@ +BINDEPS=r_diff r_util + +include ../../rules.mk + +.PHONY: clean + all: test radiff2 test: - ${CC} -g -I ../../include test.c ../*.o ../../util/*.a -o test + ${CC} -g -I ../../include test.c ${LDFLAGS} -o test radiff2: - ${CC} -g -I ../../include radiff2.c ../*.o ../../util/*.a -o radiff2 + ${CC} -g -I ../../include radiff2.c ${LDFLAGS} -o radiff2 clean: rm -f test test.o radiff2 + diff --git a/libr/flags/flags.c b/libr/flags/flags.c index bf94572f99..60d3ea93de 100644 --- a/libr/flags/flags.c +++ b/libr/flags/flags.c @@ -40,9 +40,9 @@ struct r_flag_item_t *r_flag_list(struct r_flag_t *f, int rad) struct list_head *pos; list_for_each_prev(pos, &f->flags) { struct r_flag_item_t *flag = list_entry(pos, struct r_flag_item_t, list); - if (rad) r_cons_printf("f %s %d @ 0x%08llx\n", flag->name, + if (rad) printf("f %s %d @ 0x%08llx\n", flag->name, flag->size, flag->offset); - else r_cons_printf("0x%08llx %d %s\n", + else printf("0x%08llx %d %s\n", flag->offset, flag->size, flag->name); } return NULL; diff --git a/libr/include/r_search.h b/libr/include/r_search.h index 62bb8b5eb5..8999f10aba 100644 --- a/libr/include/r_search.h +++ b/libr/include/r_search.h @@ -10,6 +10,7 @@ enum { R_SEARCH_REGEXP, R_SEARCH_PATTERN, R_SEARCH_STRING, + R_SEARCH_XREFS, R_SEARCH_AES }; diff --git a/libr/io/p/Makefile b/libr/io/p/Makefile index b15585685c..bcd6943993 100644 --- a/libr/io/p/Makefile +++ b/libr/io/p/Makefile @@ -1,4 +1,5 @@ CFLAGS=-I../../include -Wall +BINDEPS= all: ptrace.so dbg.so malloc.so @true @@ -12,7 +13,7 @@ ptrace.so: ptrace.o #strip -s ptrace.so dbg.so: dbg.o - ${CC} ${CFLAGS} -fPIC -shared -o dbg.so dbg.c -lr_io -L../../io + ${CC} ${CFLAGS} -fPIC -shared -o dbg.so dbg.c -lr_io -L../../io -Wl,-R.. #strip -s ptrace.so clean: diff --git a/libr/lib/t/Makefile b/libr/lib/t/Makefile index 1a389593a8..a1e50109e8 100644 --- a/libr/lib/t/Makefile +++ b/libr/lib/t/Makefile @@ -5,7 +5,7 @@ plugin.so: gcc -Wall -o plugin.so -shared plugin.c -I../../include test-plugin: - gcc -Wall -o test-plugin test-plugin.c -I ../../include ../../lib/*.a -ldl + gcc -Wall -o test-plugin test-plugin.c -I ../../include ../../lib/*.o -ldl clean: -rm -f plugin.so test-plugin diff --git a/libr/line/Makefile b/libr/line/Makefile index a1c43e9dbe..16693b248f 100644 --- a/libr/line/Makefile +++ b/libr/line/Makefile @@ -1,5 +1,6 @@ NAME=r_line +DEPS=r_util r_cons OBJ=dietline.o -LINK=-L../cons -lr_cons -Wl,-R../cons ../util/*.a +#LINK=-L../cons -lr_cons -Wl,-R../cons ../util/*.a include ../rules.mk diff --git a/libr/line/t/Makefile b/libr/line/t/Makefile index fbd65e0773..9cbba57cb8 100644 --- a/libr/line/t/Makefile +++ b/libr/line/t/Makefile @@ -1,6 +1,11 @@ OBJ=hello.o BIN=hello -LIBS=../*.o -L../../cons -Wl,-R../../cons -lr_cons \ - ../../util/*.a +BINDEPS=r_cons r_line r_util +#LIBS=../*.o -L../../cons -Wl,-R../../cons -lr_cons \ +# ../../util/*.a +#hello: ${OBJ} +# ${CC} ${LDFLAGS} ${OBJ} -o hello + +include ../../rules.mk include ../../tests.mk diff --git a/libr/print/t/Makefile b/libr/print/t/Makefile index b55035d037..83f06a6b02 100644 --- a/libr/print/t/Makefile +++ b/libr/print/t/Makefile @@ -1,7 +1,6 @@ -all: hex +BIN=hex +OBJ=hex.o +BINDEPS=r_cons r_util r_line r_print -hex: - ${CC} ${CFLAGS} -I ../../include hex.c ../*.o ../../cons/*.o ../../util/*.a ../../line/*.a -o hex - -clean: - rm -f hex +include ../../rules.mk +include ../../tests.mk diff --git a/libr/rules.mk b/libr/rules.mk index 69a05d9154..c45de8f60c 100644 --- a/libr/rules.mk +++ b/libr/rules.mk @@ -1,7 +1,18 @@ +ifeq (${BINDEPS},) include ../config.mk +else +include ../../config.mk +endif CFLAGS+=-DUSE_RIO=${USE_RIO} CFLAGS+=${CFLAGS_APPEND} +LDFLAGS+=$(subst r_,-lr_,$(DEPS)) +LDFLAGS+=$(subst r_,-L../,$(DEPS)) + +LDFLAGS+=$(subst r_,-lr_,$(BINDEPS)) +LDFLAGS+=$(subst r_,-L../../,$(BINDEPS)) +BOO=-Wl,-R../../ +LDFLAGS+=$(subst r_,${BOO},$(BINDEPS)) # Compiler CC?=gcc @@ -19,21 +30,27 @@ EXT_SO=so LIB=lib${NAME} LIBAR=${LIB}.${EXT_AR} LIBSO=${LIB}.${EXT_SO} - +# ${LIBAR} # Rules -all: ${OBJ} ${LIBSO} ${LIBAR} - @if [ -e t/Makefile ]; then (cd t && ${MAKE} all) ; else true ; fi - @if [ -e plugins/Makefile ]; then (cd plugins && ${MAKE} all) ; else true ; fi +ifneq ($(NAME),) +all: ${LIBSO} + echo $(NAME) + @-if [ -e t/Makefile ]; then (cd t && ${MAKE} all) ; fi + @-if [ -e p/Makefile ]; then (cd p && ${MAKE} all) ; fi + @true -${LIBSO}: +${LIBSO}: ${OBJ} ${CC_LIB} ${LDFLAGS} ${LINK} ${OBJ} - @sh ../stripsyms.sh ${LIBSO} ${NAME} + @if [ -f "../stripsyms.sh" ]; then sh ../stripsyms.sh ${LIBSO} ${NAME} ; fi -${LIBAR}: +${LIBAR}: ${OBJ} ${CC_AR} ${OBJ} clean: - -rm -f ${LIBSO} ${LIBAR} ${OBJ} ${BIN} *.so a.out *.a - @if [ -e t/Makefile ]; then (cd t && ${MAKE} clean) ; else true ; fi + -rm -f ${LIBSO} ${LIBAR} ${OBJ} ${BIN} *.so a.out *.a *.exe + @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 diff --git a/libr/search/Makefile b/libr/search/Makefile index 5b6216cc4d..2d417e3a68 100644 --- a/libr/search/Makefile +++ b/libr/search/Makefile @@ -1,5 +1,6 @@ NAME=r_search OBJ=search.o bytepat.o stripstr.o aes-find.o +DEPS=r_util CFLAGS+=-g #OBJ+=binparse.o # on solaris only diff --git a/libr/search/t/Makefile b/libr/search/t/Makefile index a6fc5e45c4..fe3a34b165 100644 --- a/libr/search/t/Makefile +++ b/libr/search/t/Makefile @@ -1,10 +1,15 @@ +BINDEPS=r_util r_search + +include ../../rules.mk + all: test test-str test: - ${CC} -g -I ../../include test.c ../*.o ../../util/*.a -o test + ${CC} -g -I ../../include test.c ${LDFLAGS} -o test test-str: - ${CC} -g -I ../../include test-str.c ../*.o ../../util/*.a -o test-str + ${CC} -g -I ../../include test-str.c ${LDFLAGS} -o test-str clean: rm -f test test.o test-str test-str.o + diff --git a/libr/tests.mk b/libr/tests.mk index 58d09bc163..0ab09e0652 100644 --- a/libr/tests.mk +++ b/libr/tests.mk @@ -10,6 +10,7 @@ LIBAR=${LIB}.${EXT_AR} LIBSO=${LIB}.${EXT_SO} # Rules +ifeq ($(NAME),) all: ${BIN} @true @@ -20,3 +21,4 @@ clean: -rm -f ${OBJ} ${BIN} .PHONY: all clean ${BIN} +endif diff --git a/libr/util/t/Makefile b/libr/util/t/Makefile index 79c8a036d2..34f18e48e3 100644 --- a/libr/util/t/Makefile +++ b/libr/util/t/Makefile @@ -10,4 +10,4 @@ rax2: ${CC} -g -I ../../include rax2.c ../*.o -o rax2 clean: - rm -f calc rax2 ralloc + rm -f calc rax2 ralloc test diff --git a/libr/util/t/ralloc.c b/libr/util/t/ralloc.c index 44a7d33349..8c60097bdb 100644 --- a/libr/util/t/ralloc.c +++ b/libr/util/t/ralloc.c @@ -22,7 +22,7 @@ int fun(const char *str, int iters) int ret; char *ptr; if (iters == 0) return 0; - ptr = r_alloca_str(str); + ptr = (char *)r_alloca_str(str); ret = fun(str, iters-1); return r_alloca_ret_i( ret ); }