From 3540924f4010d42f5decd59e20f9eb2faea4a605 Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 4 Oct 2012 01:20:00 +0200 Subject: [PATCH] Better paralelization of build system --- AUTHORS | 2 +- TODO | 30 ++++++- TODO.decompiler | 81 ------------------ TODO.hackaton | 63 -------------- TODO.poll | 42 ---------- binr/blob/Makefile | 1 - binr/rabin2/Makefile | 2 +- binr/radare2/Makefile | 2 +- binr/radiff2/Makefile | 2 +- binr/rafind2/Makefile | 4 +- binr/rahash2/Makefile | 3 +- configure | 2 +- configure.acr | 1 - global.mk | 2 +- libr/Makefile | 29 +++++-- libr/anal/Makefile | 18 ++-- libr/anal/fcn.c | 2 +- libr/anal/p/Makefile | 4 +- libr/anal/p/arc.mk | 6 +- libr/anal/p/arm.mk | 6 +- libr/anal/p/bf.mk | 6 +- libr/anal/p/m68k.mk | 6 +- libr/anal/p/z80.mk | 6 +- libr/anal/var.c | 4 +- libr/bin/Makefile | 11 ++- libr/bp/Makefile | 14 ++-- libr/cons/Makefile | 3 + libr/{line => cons}/TODO | 0 libr/{line => cons}/dietline.c | 3 +- libr/{line => cons}/line.c | 4 +- libr/core/Makefile | 2 +- libr/db/Makefile | 23 +++--- libr/db/sdb/Makefile | 2 - libr/egg/Makefile | 13 +-- libr/include/r_cons.h | 62 +++++++++++++- libr/include/r_core.h | 1 - libr/include/r_line.h | 64 -------------- libr/io/Makefile | 3 +- libr/lang/Makefile | 2 +- libr/line/Makefile | 10 --- libr/line/label.c | 147 --------------------------------- libr/line/t/Makefile | 11 --- libr/line/t/hello.c | 32 ------- libr/rules.mk | 25 +++--- libr/vm/Makefile | 2 + pkgcfg/r_line.pc.acr | 11 --- r2-bindings/vapi/r_cons.vapi | 17 +++- r2-bindings/vapi/r_line.vapi | 1 - sys/README | 8 -- 49 files changed, 210 insertions(+), 585 deletions(-) delete mode 100644 TODO.decompiler delete mode 100644 TODO.hackaton delete mode 100644 TODO.poll rename libr/{line => cons}/TODO (100%) rename libr/{line => cons}/dietline.c (99%) rename libr/{line => cons}/line.c (89%) delete mode 100644 libr/include/r_line.h delete mode 100644 libr/line/Makefile delete mode 100644 libr/line/label.c delete mode 100644 libr/line/t/Makefile delete mode 100644 libr/line/t/hello.c delete mode 100644 pkgcfg/r_line.pc.acr delete mode 100644 sys/README diff --git a/AUTHORS b/AUTHORS index 2e6191c2ac..4b5cbfb5c5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -11,7 +11,7 @@ Contributors: (sorted by length) ================================ - Anton Bolotinksy - Glyn Kennington - - @schrotthaufen + - schrotthaufen - elektranox - neuroflip - rvalles diff --git a/TODO b/TODO index 7a8ab88918..072c27e830 100644 --- a/TODO +++ b/TODO @@ -155,8 +155,34 @@ Assembler - So one can change from one arch to another with a pointer - Cool for defining ranges of memory -0.8: focus on debugger and UI -============================= + +* r_io + - We need a way to get the underlying file which responds + to the read call (this way we can know which library + lives at a specified offset. (is this already done?) + +* r_bin + - Find why objdump can find stripped symbols with objcopy (see /TODO) + +* radare2 + - Use r_bin with r_io to get symbols + - The offset to read will define the module to analyze and retrieve syms + - Import msdn doc as comments + +* r_db + - Implement iterators r_db_next() and r_db_prev() (HIGH PRIO) + - Write test programs to ensure the data is stored correctly + +* r_search + - The pattern finding functions are not following the design + of the rest of the library, it needs a redesign and code cleanup + (see bytepat.c) + - Implement radare/src/xrefs.c into r_search + - Add support to change the case sensitive of searchs (ignore case) + - This must be keyword-based. Not globally + - Sync vapi (r_search_regexp not implemented) + - Enable/disable nested hits? (discuss+ implement in parent app?) + - Just skip bytes until end of keyword * Ranged/scrollable zoom mode * AES/RSA Key finding http://citp.princeton.edu/memory/code/ <- implement this stuff in r2 diff --git a/TODO.decompiler b/TODO.decompiler deleted file mode 100644 index 990650b337..0000000000 --- a/TODO.decompiler +++ /dev/null @@ -1,81 +0,0 @@ -Decompiler for radare2 trackline -================================ - -Objectives -========== -- Name local variables argments and global vars (Cv ...) -- Common construct detection (if/switch/for/while/do) -- Enum detection/support (load from .h ?) #define /enum parse only -- Detect sign of variables (depending on the conditionals used) -- Change operations to ease reading ('\n' instead of 0xa.. sub<->add) -- Detect and propagate variable types -- Symbol recognition - -Core (RAnal, RMeta, RBin, ...) -============================== -* Language: C -* Analyze opcodes -* Detect numeric sign -* Detect data type and size by analyzing the accesses -* Analyze conditionals (if () goto .., labels, ...) -* Support push+ret constructions -* Analyze function calls (fast/slowcall, parameters, data types, return values..) -* Define data types (as 'pm' structs (memory format string)) -* Analyze common constructions - -Plugin (Radare.Decompiler class) -================================ -* Language: Vala -* Using visitor paradigm -* Bidirectional sync methods for core - - Caches data and code from the core - - Comments must be syncronized too -* Independent structure compared to core -* Optimize sequences of opcodes -* Optimize AST (remove unaccessible code, join nodes, ...) -* Polimorph operations to simplify reading (shl eax, 1 => eax *= 2) -* Remove stack-related operations -* Resolve and propagate data types -* Parse .h files in order to import function signatures, defines, enums, .. -* Support to decompile single function or full program -* Each node must have a to_string() method to serialize -* Indent resulting code -* Remove trash code - -UI (Gtk+) -========= -* Language: Vala -* Implemented as a Gtk.Widget -* Walk along the decompiled program code - - change variable names (read/write value) - - go xrefs - -Future -====== -* Floating point support -* Support high-level language constructions (objective-C, gobject, c++, ...) - -External linkz -============== -* http://www.pivotaltracker.com/ - - --------------8<-------------------------------------------- -- - - - - - -+-------------------+ -| Plugin API design | -+-------------------+ - -public class RadareDecompiler.AST { } -public class RadareDecompiler.Node { } -public class RadareDecompiler.Function { } -public class RadareDecompiler.Variable { } -public class RadareDecompiler.Constant { } -public class RadareDecompiler.Conditional { } -public class RadareDecompiler.Enum { } - -public class Radare.Decompiler { - public class Decompiler(RCore core) { - ... - } - public void sync(bool write) { ... } -} diff --git a/TODO.hackaton b/TODO.hackaton deleted file mode 100644 index bb2c1984ec..0000000000 --- a/TODO.hackaton +++ /dev/null @@ -1,63 +0,0 @@ -TODO for hackatons -================== - -Inconcrete things to do -======================= - -* Compile radare2 on many OS and platforms as possible - - Windows? 32/64 bits (mingw32, cygwin) - - OSX? - - Solaris? (-lsocket ..) - -* Test w32 bins with rabin2, r2, .. - -* Implement process launcher wrapper // anybody - - opens xterm and redirects stdin/stdout/stderr - - Allows to change chroot - - Allows to setup chroot - - Define uid/gid - - sleep before exec - - show pid before exec - -* Write Vala applications - - Test the current .vapi files - - Add missing methods/classes in vapi files - - Examples can be found in swig/vapi/t - - Propose new APIs and usage - - Vala is a good way to express code - -* Clean warnings - - Find missing function signatures in libr/include/.h - - R_APIfy those APIs (sync with vapi) - - -Concrete TODO points -==================== - -* r_io - - We need a way to get the underlying file which responds - to the read call (this way we can know which library - lives at a specified offset. (is this already done?) - -* r_bin - - Find why objdump can find stripped symbols with objcopy (see /TODO) - -* radare2 - - Use r_bin with r_io to get symbols - - The offset to read will define the module to analyze and retrieve syms - - Import msdn doc as comments - -* r_db - - Implement iterators r_db_next() and r_db_prev() (HIGH PRIO) - - Write test programs to ensure the data is stored correctly - -* r_search - - The pattern finding functions are not following the design - of the rest of the library, it needs a redesign and code cleanup - (see bytepat.c) - - Implement radare/src/xrefs.c into r_search - - Add support to change the case sensitive of searchs (ignore case) - - This must be keyword-based. Not globally - - Sync vapi (r_search_regexp not implemented) - - Enable/disable nested hits? (discuss+ implement in parent app?) - - Just skip bytes until end of keyword diff --git a/TODO.poll b/TODO.poll deleted file mode 100644 index 48653a2839..0000000000 --- a/TODO.poll +++ /dev/null @@ -1,42 +0,0 @@ -Current development fronts -========================== -33 decompilation -- we need better code analysis, but basic decompilation will be in 0.5 - we will provide at some point a decompiler as a plugin (more news soon) - many enhacements and fixes are being done in the code analysis backend - -29 bindiffing (graph) -- - basicblock tree diffing should be implemented for 0.5 - we need to fix ired's bdiff in order to have binary diffing - -26 better code analysis -- pancake and nibble are working on this now, it's advancing - -18 code emulation -- some work has been done in r_vm, but needs much more refactoring - do we need code emulation? how ? anal ? vm? eval? - -13 radare scripting like in r1 -- please, report issues in mailing list or privmail -8 signature support -- formatstring not yet implemented, this will be helpful for code analysis -6 web interface -- r2w, somebody interested? -3 osx support -- more prio? x86-32 and x86-64 hardware required, volunteers? read doc/osx fmi - -Full poll -========= -33 decompilation -- we need better code analysis, but basic decompilation will be in 0.5 -29 bindiffing (graph) -- nibble is working on this too, pancake has some binary diffing in C -26 better code analysis -- nibble is mainly working on this now -25 windows support -- please report bugs, pancake will -22 gdb remote support -- not prioritary atm (volunteers?) linked to bochs/qemu -20 hardware breakpoints -- no plans for next release..will probably be in 0.6 -18 code emulation -- some work has been done in r_vm, but needs much more refactoring -18 Debug programs in isolated environment -- this is simple issue, any volunteer? -14 threaded debugger -- some work will be done, but dont expect big changes -13 radare scripting like in r1 -- please, report issues in mailing list or privmail -13 dalvik (android) -- no plans, no hw, any volunteer? please ask for things to be done if you want to help on this -11 write support for RBin -- nibble will work on this, but code analysis is prioritary atm -11 bochs and qemu support -- very low priority, this depends on gdb support -9 pdb support -- any volunteer to convert pdb into radare script -9 RLine with autocompletion -- no plans atm, but this feature will come eventually -8 signature support -- DONE (volunteers to generate database -6 web interface -- r2w -5 floating point debugger -- very low priority at this point -3 osx support -- x86-32 and x86-64 hardware required, volunteers? read doc/osx fmi -3 extended dwarf support -- zero priority for next release :) diff --git a/binr/blob/Makefile b/binr/blob/Makefile index 217b180d86..bb96e0d534 100644 --- a/binr/blob/Makefile +++ b/binr/blob/Makefile @@ -26,7 +26,6 @@ LDFLAGS+=../../libr/cmd/libr_cmd.a LDFLAGS+=../../libr/fs/libr_fs.a LDFLAGS+=../../libr/sign/libr_sign.a LDFLAGS+=../../libr/magic/libr_magic.a -LDFLAGS+=../../libr/line/libr_line.a LDFLAGS+=../../libr/cons/libr_cons.a LDFLAGS+=../../libr/diff/libr_diff.a LDFLAGS+=../../libr/syscall/libr_syscall.a diff --git a/binr/rabin2/Makefile b/binr/rabin2/Makefile index 1de0dda208..fe3d8c05df 100644 --- a/binr/rabin2/Makefile +++ b/binr/rabin2/Makefile @@ -1,6 +1,6 @@ BIN=rabin2 BINDEPS=r_lib r_magic r_core r_db r_bin r_egg r_cons -BINDEPS+=r_config r_line r_io r_cmd r_print r_flags r_asm +BINDEPS+=r_config r_io r_cmd r_print r_flags r_asm BINDEPS+=r_debug r_hash r_lang r_anal r_parse r_bp r_reg BINDEPS+=r_search r_syscall r_sign r_diff r_socket r_fs r_magic r_util diff --git a/binr/radare2/Makefile b/binr/radare2/Makefile index c5ad4bc71e..e34f31cd35 100644 --- a/binr/radare2/Makefile +++ b/binr/radare2/Makefile @@ -1,7 +1,7 @@ BIN=radare2 BINDEPS=r_core r_parse r_search r_cons r_lib r_config BINDEPS+=r_bin r_debug r_anal r_diff r_reg r_bp r_io r_cmd r_fs -BINDEPS+=r_sign r_print r_lang r_asm r_syscall r_db r_hash r_line +BINDEPS+=r_sign r_print r_lang r_asm r_syscall r_db r_hash BINDEPS+=r_magic r_socket r_flags r_util r_th r_egg CFLAGS+=-DR2_BIRTH=\"`date +%Y-%m-%d`\" -DR2_GITTIP=\"$(GIT_TIP)\" diff --git a/binr/radiff2/Makefile b/binr/radiff2/Makefile index f068cbb506..064e4854b1 100644 --- a/binr/radiff2/Makefile +++ b/binr/radiff2/Makefile @@ -2,7 +2,7 @@ BIN=radiff2 BINDEPS=r_core r_diff r_config r_lib r_cons r_search r_anal BINDEPS+=r_bin r_debug r_io r_print r_asm r_hash r_fs BINDEPS+=r_socket r_flags r_lang r_reg r_bp r_cmd r_sign r_parse -BINDEPS+=r_line r_syscall r_db r_magic r_util r_parse r_egg +BINDEPS+=r_syscall r_db r_magic r_util r_parse r_egg include ../rules.mk diff --git a/binr/rafind2/Makefile b/binr/rafind2/Makefile index affdb639a6..b0af13e925 100644 --- a/binr/rafind2/Makefile +++ b/binr/rafind2/Makefile @@ -1,6 +1,6 @@ BIN=rafind2 -BINDEPS=r_search r_io r_print r_lib r_asm r_anal r_reg r_cons r_util r_syscall r_diff -BINDEPS+=r_socket r_db r_parse +BINDEPS=r_search r_io r_print r_lib r_asm r_anal r_reg r_cons +BINDEPS+=r_socket r_db r_parse r_util r_syscall r_diff include ../rules.mk diff --git a/binr/rahash2/Makefile b/binr/rahash2/Makefile index 10302ed7d3..2be0bf0f08 100644 --- a/binr/rahash2/Makefile +++ b/binr/rahash2/Makefile @@ -1,5 +1,6 @@ BIN=rahash2 -BINDEPS=r_io r_hash r_util r_print r_socket r_asm r_cons r_anal r_lib r_syscall r_reg r_diff r_db r_parse +BINDEPS=r_io r_hash r_util r_print r_socket r_asm r_cons +BINDEPS+=r_anal r_lib r_syscall r_reg r_diff r_db r_parse include ../rules.mk diff --git a/configure b/configure index 499a7bf20f..e24a319e0c 100755 --- a/configure +++ b/configure @@ -475,7 +475,7 @@ for A in ${ENVWORDS} ; do SEDFLAGS="${SEDFLAGS}s,@${A}@,${VAR},g;" done SEDFLAGS="${SEDFLAGS}'" -for A in ./config-user.mk libr/include/r_userconf.h pkgcfg/r_io.pc pkgcfg/r_db.pc pkgcfg/r_magic.pc pkgcfg/r_asm.pc pkgcfg/r_bin.pc pkgcfg/r_anal.pc pkgcfg/r_hash.pc pkgcfg/r_cons.pc pkgcfg/r_diff.pc pkgcfg/r_core.pc pkgcfg/r_lang.pc pkgcfg/r_socket.pc pkgcfg/r_debug.pc pkgcfg/r_reg.pc pkgcfg/r_cmd.pc pkgcfg/r_config.pc pkgcfg/r_flags.pc pkgcfg/r_line.pc pkgcfg/r_syscall.pc pkgcfg/r_sign.pc pkgcfg/r_util.pc pkgcfg/r_search.pc pkgcfg/r_bp.pc pkgcfg/r_lib.pc pkgcfg/r_parse.pc pkgcfg/r_print.pc pkgcfg/r_th.pc pkgcfg/r_fs.pc ; do # SUBDIRS +for A in ./config-user.mk libr/include/r_userconf.h pkgcfg/r_io.pc pkgcfg/r_db.pc pkgcfg/r_magic.pc pkgcfg/r_asm.pc pkgcfg/r_bin.pc pkgcfg/r_anal.pc pkgcfg/r_hash.pc pkgcfg/r_cons.pc pkgcfg/r_diff.pc pkgcfg/r_core.pc pkgcfg/r_lang.pc pkgcfg/r_socket.pc pkgcfg/r_debug.pc pkgcfg/r_reg.pc pkgcfg/r_cmd.pc pkgcfg/r_config.pc pkgcfg/r_flags.pc pkgcfg/r_syscall.pc pkgcfg/r_sign.pc pkgcfg/r_util.pc pkgcfg/r_search.pc pkgcfg/r_bp.pc pkgcfg/r_lib.pc pkgcfg/r_parse.pc pkgcfg/r_print.pc pkgcfg/r_th.pc pkgcfg/r_fs.pc ; do # SUBDIRS if [ -f "${VPATH}/${A}.acr" ]; then SD_TARGET=${A} else diff --git a/configure.acr b/configure.acr index 994ed0e835..c704b5c3dc 100644 --- a/configure.acr +++ b/configure.acr @@ -124,7 +124,6 @@ SUBDIRS ./config-user.mk pkgcfg/r_cmd.pc pkgcfg/r_config.pc pkgcfg/r_flags.pc - pkgcfg/r_line.pc pkgcfg/r_syscall.pc pkgcfg/r_sign.pc pkgcfg/r_util.pc diff --git a/global.mk b/global.mk index 4bc5d78dad..6a6f2060e6 100644 --- a/global.mk +++ b/global.mk @@ -38,7 +38,7 @@ endif .c.o: ifneq ($(SILENT),) - @echo CC $< + @echo CC $(shell basename $<) endif $(CC) -c $(CFLAGS) -o $@ $< diff --git a/libr/Makefile b/libr/Makefile index c53fa9f7d2..615cf3c7b1 100644 --- a/libr/Makefile +++ b/libr/Makefile @@ -7,14 +7,31 @@ LFX=${DESTDIR}/${LIBDIR} IFX=${DESTDIR}/${INCLUDEDIR} PWD=$(shell pwd) -LIBS=util magic socket db cons line lib io lang flags bin hash config syscall -LIBS+=cmd reg diff anal parse asm print search egg bp sign debug fs th core -#DEPRECATED APIS : LIBS+=th crypto +LIBS0=util socket hash +LIBS1=reg cons db magic lib diff bp search +LIBS2=syscall cmd lang io crypto flags bin +LIBS3=fs anal +LIBS4=parse sign +LIBS5=asm +LIBS6=print egg +LIBS7=core + +LIBS=$(LIBS0) $(LIBS1) $(LIBS2) $(LIBS3) $(LIBS4) $(LIBS5) $(LIBS6) $(LIBS7) +.PHONY: $(LIBS) all: - @for lib in ${LIBS}; do \ - cd $${lib} && ${MAKE} || exit 1 ; cd .. ; done - @echo Build done for: ${LIBS} + ${MAKE} $(LIBS0) + ${MAKE} $(LIBS1) + ${MAKE} $(LIBS2) + ${MAKE} $(LIBS3) + ${MAKE} $(LIBS4) + ${MAKE} $(LIBS5) + ${MAKE} $(LIBS6) + ${MAKE} $(LIBS7) + +$(LIBS): + @echo "DIR $@" + cd $@ ; ${MAKE} pkgcfg: @for lib in ${LIBS}; do ( cd $${lib} && ${MAKE} pkgcfg ); done diff --git a/libr/anal/Makefile b/libr/anal/Makefile index cb0a437c4b..38ee5262a8 100644 --- a/libr/anal/Makefile +++ b/libr/anal/Makefile @@ -1,4 +1,4 @@ -include ../../global.mk +include ../config.mk NAME=r_anal EXTRA_CLEAN=clean2 @@ -7,12 +7,17 @@ DEPS=r_util r_db r_lib r_reg r_syscall r_diff CFLAGS*=HAVE_CPARSE=$(HAVE_CPARSE) CFLAGS+=-DCORELIB -Iarch -I$(TOP)/shlr -include $(LTOP)/config.mk LDFLAGS+=${BN_LIBS} -foo: - for a in pre libr_anal.${EXT_SO} libr_anal.${EXT_AR} plugins ; do ${MAKE} $$a ; done +.PHONY: pre libs ${EXTRA_CLEAN} + +all: plugins + +plugins: libr_anal.${EXT_SO} libr_anal.${EXT_AR} + @${MAKE} -C p all + +libr_anal.${EXT_SO} libr_anal.${EXT_AR}: pre include ${STATIC_ANAL_PLUGINS} STATIC_OBJS=$(addprefix $(LTOP)/anal/p/,$(STATIC_OBJ)) @@ -28,12 +33,7 @@ pre: @cd cparse && ${MAKE} all @cd $(TOP)/shlr && ${MAKE} -#@if [ ! -e libr_anal.${EXT_SO} ]; then rm -f ${STATIC_OBJS} ; fi - clean2: @cd cparse && ${MAKE} clean -plugins: - @${MAKE} -C p all - include $(LTOP)/rules.mk diff --git a/libr/anal/fcn.c b/libr/anal/fcn.c index a436200335..8c4fa19c13 100644 --- a/libr/anal/fcn.c +++ b/libr/anal/fcn.c @@ -451,7 +451,7 @@ R_API char *r_anal_fcn_to_string(RAnal *a, RAnalFunction* fs) { // TODO: This function is not fully implemented /* set function signature from string */ R_API int r_anal_str_to_fcn(RAnal *a, RAnalFunction *f, const char *sig) { - char *p, *q, *r, *str; + char *str; //*p, *q, *r RAnalType *t; if (!a || !f || !sig) { diff --git a/libr/anal/p/Makefile b/libr/anal/p/Makefile index b5603db4e8..5843164f12 100644 --- a/libr/anal/p/Makefile +++ b/libr/anal/p/Makefile @@ -6,15 +6,13 @@ CFLAGS+=-L../../util -lr_util -L../../anal -lr_anal -L../../reg -lr_reg LDFLAGS+=${LINK} ifeq ($(WITHPIC),1) -all: ${ALL_TARGETS} - @true +all: ${ALL_TARGETS} ; ALL_TARGETS= # TODO: rename to enabled plugins ARCHS=x86.mk x86_udis86.mk x86_simple.mk ppc.mk arm.mk avr.mk csr.mk dalvik.mk sh.mk include $(ARCHS) - clean: -rm -f *.${EXT_SO} *.o ${STATIC_OBJ} diff --git a/libr/anal/p/arc.mk b/libr/anal/p/arc.mk index d34599e271..b26dd58413 100644 --- a/libr/anal/p/arc.mk +++ b/libr/anal/p/arc.mk @@ -4,9 +4,9 @@ STATIC_OBJ+=${OBJ_ARC} TARGET_ARC=anal_arc.${EXT_SO} ALL_TARGETS+=${TARGET_ARC} -LDFLAGS+=-L$(TOP)/libr/lib -lr_lib -LDFLAGS+=-L$(TOP)/libr/syscall -lr_syscall -LDFLAGS+=-L$(TOP)/libr/diff -lr_diff +#LDFLAGS+=-L$(TOP)/libr/lib -lr_lib +#LDFLAGS+=-L$(TOP)/libr/syscall -lr_syscall +#LDFLAGS+=-L$(TOP)/libr/diff -lr_diff ${TARGET_ARC}: ${OBJ_ARC} ${CC} $(call libname,anal_arc) ${LDFLAGS} ${CFLAGS} -o anal_arc.${EXT_SO} ${OBJ_ARC} diff --git a/libr/anal/p/arm.mk b/libr/anal/p/arm.mk index f5cde50d91..5029b83c7d 100644 --- a/libr/anal/p/arm.mk +++ b/libr/anal/p/arm.mk @@ -4,9 +4,9 @@ STATIC_OBJ+=${OBJ_ARM} TARGET_ARM=anal_arm.${EXT_SO} ALL_TARGETS+=${TARGET_ARM} -LDFLAGS+=-L$(TOP)/libr/lib -lr_lib -LDFLAGS+=-L$(TOP)/libr/syscall -lr_syscall -LDFLAGS+=-L$(TOP)/libr/diff -lr_diff +#LDFLAGS+=-L$(TOP)/libr/lib -lr_lib +#LDFLAGS+=-L$(TOP)/libr/syscall -lr_syscall +#LDFLAGS+=-L$(TOP)/libr/diff -lr_diff ${TARGET_ARM}: ${OBJ_ARM} ${CC} $(call libname,anal_arm) ${LDFLAGS} ${CFLAGS} -o anal_arm.${EXT_SO} ${OBJ_ARM} diff --git a/libr/anal/p/bf.mk b/libr/anal/p/bf.mk index 0b15734ae6..fde946374d 100644 --- a/libr/anal/p/bf.mk +++ b/libr/anal/p/bf.mk @@ -4,9 +4,9 @@ STATIC_OBJ+=${OBJ_BF} TARGET_BF=anal_bf.${EXT_SO} ALL_TARGETS+=${TARGET_BF} -LDFLAGS+=-L$(TOP)/libr/lib -lr_lib -LDFLAGS+=-L$(TOP)/libr/syscall -lr_syscall -LDFLAGS+=-L$(TOP)/libr/diff -lr_diff +#LDFLAGS+=-L$(TOP)/libr/lib -lr_lib +#LDFLAGS+=-L$(TOP)/libr/syscall -lr_syscall +#LDFLAGS+=-L$(TOP)/libr/diff -lr_diff ${TARGET_BF}: ${OBJ_BF} ${CC} $(call libname,anal_bf) ${LDFLAGS} ${CFLAGS} -o anal_bf.${EXT_SO} ${OBJ_BF} diff --git a/libr/anal/p/m68k.mk b/libr/anal/p/m68k.mk index 74fcac3f04..ff9aa10129 100644 --- a/libr/anal/p/m68k.mk +++ b/libr/anal/p/m68k.mk @@ -4,9 +4,9 @@ STATIC_OBJ+=${OBJ_M68K} TARGET_M68K=anal_m68k.${EXT_SO} ALL_TARGETS+=${TARGET_M68K} -LDFLAGS+=-L../../lib -lr_lib -LDFLAGS+=-L../../syscall -lr_syscall -LDFLAGS+=-L../../diff -lr_diff +#LDFLAGS+=-L../../lib -lr_lib +#LDFLAGS+=-L../../syscall -lr_syscall +#LDFLAGS+=-L../../diff -lr_diff ${TARGET_M68K}: ${OBJ_M68K} ${CC} $(call libname,anal_m68k) ${LDFLAGS} ${CFLAGS} -o anal_m68k.${EXT_SO} ${OBJ_M68K} diff --git a/libr/anal/p/z80.mk b/libr/anal/p/z80.mk index d90c773385..3401e4576a 100644 --- a/libr/anal/p/z80.mk +++ b/libr/anal/p/z80.mk @@ -4,9 +4,9 @@ STATIC_OBJ+=${OBJ_Z80} TARGET_Z80=anal_z80.${EXT_SO} ALL_TARGETS+=${TARGET_Z80} -LDFLAGS+=-L../../lib -lr_lib -LDFLAGS+=-L../../syscall -lr_syscall -LDFLAGS+=-L../../diff -lr_diff +#LDFLAGS+=-L../../lib -lr_lib +#LDFLAGS+=-L../../syscall -lr_syscall +#LDFLAGS+=-L../../diff -lr_diff ${TARGET_Z80}: ${OBJ_Z80} ${CC} $(call libname,anal_z80) ${LDFLAGS} ${CFLAGS} -o anal_z80.${EXT_SO} ${OBJ_Z80} diff --git a/libr/anal/var.c b/libr/anal/var.c index a7b78b425e..cbf014f005 100644 --- a/libr/anal/var.c +++ b/libr/anal/var.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2010-2011 */ +/* radare - LGPL - Copyright 2010-2012 */ /* nibble<.ds@gmail.com> + pancake */ #include @@ -169,7 +169,7 @@ R_API void r_anal_var_list_show(RAnal *anal, RAnalFunction *fcn, ut64 addr) { v->name, (int)v->type->custom.a->count); else eprintf ("%s %s %s = ", r_anal_var_scope_to_str (anal, v->scope), - r_anal_type_to_str (anal, v->type, ""), v->name, ""); + r_anal_type_to_str (anal, v->type, ""), v->name); // TODO: implement r_var_dbg_read using r_vm or r_num maybe?? sounds dupped // XXX: not fully implemented eprintf ("0x%"PFMT64x, 0LL); diff --git a/libr/bin/Makefile b/libr/bin/Makefile index d0a7c090c7..00fdfb1f72 100644 --- a/libr/bin/Makefile +++ b/libr/bin/Makefile @@ -1,14 +1,16 @@ +include ../config.mk include ../../global.mk NAME=r_bin DEPS=r_lib r_util -foo: - @for a in $(LIBSO) ${LIBAR} plugins ; do ${MAKE} $$a ; done +.PHONY: pre + +pre: $(LIBSO) $(LIBAR) + @${MAKE} -C p all CFLAGS+=-DCORELIB -Iformat -Imangling -include $(TOP)/libr/config.mk include ${STATIC_BIN_PLUGINS} include ${STATIC_BIN_XTR_PLUGINS} @@ -16,7 +18,4 @@ STATIC_OBJS=$(addprefix $(LTOP)/bin/p/, $(STATIC_OBJ)) OBJS=bin.o bin_meta.o bin_write.o demangle.o dwarf.o OBJS+=mangling/cxx/cp-demangle.o ${STATIC_OBJS} -plugins: - cd p && ${MAKE} all - include $(TOP)/libr/rules.mk diff --git a/libr/bp/Makefile b/libr/bp/Makefile index 7ef769dc84..4c390fb8cb 100644 --- a/libr/bp/Makefile +++ b/libr/bp/Makefile @@ -1,20 +1,16 @@ +include ../config.mk + NAME=r_bp DEPS+=r_util CFLAGS+=-DCORELIB -include ../config.mk -foo: - for a in libr_bp.${EXT_SO} libr_bp.${EXT_AR} plugins ; do ${MAKE} $$a ; done +.PHONY: pre +pre: libr_bp.${EXT_SO} libr_bp.${EXT_AR} + ${MAKE} -C p include ${STATIC_BP_PLUGINS} STATIC_OBJS=$(subst ..,p/..,$(subst bp_,p/bp_,$(STATIC_OBJ))) OBJS=bp.o watch.o io.o plugin.o traptrace.o ${STATIC_OBJS} -#pre: -# if [ ! -e libr_bp.so ]; then rm -f ${STATIC_OBJS} ; fi - -plugins: - cd p && ${MAKE} all - include ../rules.mk diff --git a/libr/cons/Makefile b/libr/cons/Makefile index f708703c8d..c37de94be5 100644 --- a/libr/cons/Makefile +++ b/libr/cons/Makefile @@ -2,6 +2,9 @@ include ../config.mk NAME=r_cons OBJS=cons.o pipe.o output.o grep.o input.o hud.o +OBJS+=line.o DEPS=r_util include ../rules.mk + +line.o: dietline.c diff --git a/libr/line/TODO b/libr/cons/TODO similarity index 100% rename from libr/line/TODO rename to libr/cons/TODO diff --git a/libr/line/dietline.c b/libr/cons/dietline.c similarity index 99% rename from libr/line/dietline.c rename to libr/cons/dietline.c index ff3597a147..3f216963fa 100644 --- a/libr/line/dietline.c +++ b/libr/cons/dietline.c @@ -1,8 +1,7 @@ /* radare - LGPL - Copyright 2007-2012 pancake */ /* dietline is a lightweight and portable library similar to GNU readline */ -#include - +#include #include #include diff --git a/libr/line/line.c b/libr/cons/line.c similarity index 89% rename from libr/line/line.c rename to libr/cons/line.c index bd0e726c8b..75ecf61161 100644 --- a/libr/line/line.c +++ b/libr/cons/line.c @@ -1,6 +1,6 @@ -/* radare - LGPL - Copyright 2007-2011 pancake */ +/* radare - LGPL - Copyright 2007-2012 pancake */ -#include +#include static RLine r_line_instance; #define I r_line_instance diff --git a/libr/core/Makefile b/libr/core/Makefile index aed6e9cf6b..c1afc779c6 100644 --- a/libr/core/Makefile +++ b/libr/core/Makefile @@ -2,7 +2,7 @@ include ../config.mk NAME=r_core -DEPS=r_config r_cons r_line r_io r_cmd r_util r_print r_flags r_asm r_lib +DEPS=r_config r_cons r_io r_cmd r_util r_print r_flags r_asm r_lib DEPS+=r_debug r_hash r_bin r_lang r_io r_anal r_parse r_print r_bp r_egg DEPS+=r_reg r_search r_syscall r_sign r_diff r_socket r_fs r_magic r_db diff --git a/libr/db/Makefile b/libr/db/Makefile index e12a49eb22..955e4d2a40 100644 --- a/libr/db/Makefile +++ b/libr/db/Makefile @@ -5,41 +5,38 @@ DEPS=r_util OBJS=db.o table.o pair.o -PRE=sdb/src/libsdb.a +SDBLIB=sdb/src/libsdb.a EXTRA_CLEAN=sdbclean -EXTRA_TARGETS+=${PRE} +EXTRA_TARGETS+=${SDBLIB} CFLAGS+=-Isdb/src -VC=git URL=git://github.com/radare/sdb F=README.md config.mk src Makefile -SYNCFILES=$(addprefix sdb.${VC}/,${F}) +SYNCFILES=$(addprefix sdb.vc/,${F}) include ../rules.mk # link against sdb -LINK+=${PRE} +LINK+=${SDBLIB} sdbclean: cd sdb/src ; ${MAKE} clean -sdb/src/libsdb.a: - #cd sdb/src ; ${MAKE} CFLAGS=-fPIC libsdb.a +$(SDBLIB): cd sdb ; ${MAKE} src/sdb-version.h cd sdb/src ; ${MAKE} ARCH=xxx \ RANLIB="${RANLIB}" \ CC="${CC}" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" libsdb.a -.PHONY: sdb-sync sync-sdb +.PHONY: sdb-sync sync-sdb sdbclean sdb-sync sync-sdb: - rm -rf sdb sdb.${VC} - ${VC} clone ${URL} sdb.${VC} - mkdir sdb + rm -rf sdb sdb.vc + git clone ${URL} sdb.vc + mkdir -p sdb cp -rf ${SYNCFILES} sdb - rm -rf sdb.${VC} - rm -rf ../include/sdb + rm -rf sdb.vc ../include/sdb mkdir -p ../include/sdb cd sdb ; ${MAKE} src/sdb-version.h cp -f sdb/src/*.h ../include/sdb diff --git a/libr/db/sdb/Makefile b/libr/db/sdb/Makefile index 59bdbac48c..40ae559e87 100644 --- a/libr/db/sdb/Makefile +++ b/libr/db/sdb/Makefile @@ -19,8 +19,6 @@ src/sdb-version.h: clean: rm -f src/sdb-version.h cd src && ${MAKE} clean - cd memcache && ${MAKE} clean - cd test && ${MAKE} clean cd ${VALADIR} && ${MAKE} clean dist: diff --git a/libr/egg/Makefile b/libr/egg/Makefile index a326e5de5e..c7daf07221 100644 --- a/libr/egg/Makefile +++ b/libr/egg/Makefile @@ -1,23 +1,18 @@ +include ../config.mk + NAME=r_egg DEPS=r_util r_asm r_syscall r_db -include ../config.mk - -#OBJS+=p/x86_osx_binsh.o OBJS=egg.o lang.o OBJS+=emit_x86.o OBJS+=emit_arm.o OBJS+=emit_x64.o OBJS+=emit_trace.o -foo: - for a in ${LIBSO} ${LIBAR} all ; do ${MAKE} $$a ; done +all: ${LIBSO} ${LIBAR} P=p/ include ${STATIC_EGG_PLUGINS} -OBJS+=$(subst ..,p/..,$(subst egg_,p/egg_,$(STATIC_OBJ))) - -#plugins plugins: -# Do not build plugins. all are static @cd p && ${MAKE} all +OBJS+=$(subst ..,${P}..,$(subst egg_,${P}egg_,$(STATIC_OBJ))) include ../rules.mk diff --git a/libr/include/r_cons.h b/libr/include/r_cons.h index 590df8a69c..04ca8f1f90 100644 --- a/libr/include/r_cons.h +++ b/libr/include/r_cons.h @@ -1,7 +1,7 @@ #ifndef _INCLUDE_CONS_R_ #define _INCLUDE_CONS_R_ -#define HAVE_DIETLINE 0 +#define HAVE_DIETLINE 1 #include #include @@ -243,4 +243,64 @@ R_API int r_cons_get_column(); R_API char *r_cons_message(const char *msg); #endif + +/* r_line */ +#define R_LINE_BUFSIZE 4096 +#define R_LINE_HISTSIZE 256 + +typedef struct r_line_hist_t { + char **data; + int size; + int index; + int top; + int autosave; +} RLineHistory; + +typedef struct r_line_buffer_t { + char data[R_LINE_BUFSIZE]; + int index; + int length; +} RLineBuffer; + +typedef struct r_line_t RLine; // forward declaration + +typedef int (*RLineCallback)(RLine *line); + +typedef struct r_line_comp_t { + int argc; + const char **argv; + RLineCallback run; +} RLineCompletion; + +struct r_line_t { + RLineCompletion completion; + RLineHistory history; + RLineBuffer buffer; + int echo; + int has_echo; + char *prompt; + char *clipboard; + int disable; + void *user; +}; /* RLine */ + +#ifdef R_API + +R_API RLine *r_line_new(); +R_API RLine *r_line_singleton(); +R_API void r_line_free(); +R_API char *r_line_get_prompt (); +R_API void r_line_set_prompt(const char *prompt); + +R_API int r_line_hist_load(const char *file); +R_API char *r_line_readline(); +/* label ?! */ +R_API int r_line_hist_add(const char *line); +R_API int r_line_hist_save(const char *file); +R_API int r_line_hist_label(const char *label, void (*cb)(const char*)); +R_API void r_line_label_show(); + +#endif + + #endif diff --git a/libr/include/r_core.h b/libr/include/r_core.h index a0c56b1217..074ef40131 100644 --- a/libr/include/r_core.h +++ b/libr/include/r_core.h @@ -15,7 +15,6 @@ #include "r_anal.h" #include "r_cmd.h" #include "r_cons.h" -#include "r_line.h" #include "r_print.h" #include "r_search.h" #include "r_sign.h" diff --git a/libr/include/r_line.h b/libr/include/r_line.h deleted file mode 100644 index 6eb90d37a5..0000000000 --- a/libr/include/r_line.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef _INCLUDE_R_LINE_H_ -#define _INCLUDE_R_LINE_H_ - -#include -#include -#include - -#define R_LINE_BUFSIZE 4096 -#define R_LINE_HISTSIZE 256 - -typedef struct r_line_hist_t { - char **data; - int size; - int index; - int top; - int autosave; -} RLineHistory; - -typedef struct r_line_buffer_t { - char data[R_LINE_BUFSIZE]; - int index; - int length; -} RLineBuffer; - -typedef struct r_line_t RLine; // forward declaration - -typedef int (*RLineCallback)(RLine *line); - -typedef struct r_line_comp_t { - int argc; - const char **argv; - RLineCallback run; -} RLineCompletion; - -struct r_line_t { - RLineCompletion completion; - RLineHistory history; - RLineBuffer buffer; - int echo; - int has_echo; - char *prompt; - char *clipboard; - int disable; - void *user; -}; /* RLine */ - -#ifdef R_API - -R_API RLine *r_line_new(); -R_API RLine *r_line_singleton(); -R_API void r_line_free(); -R_API char *r_line_get_prompt (); -R_API void r_line_set_prompt(const char *prompt); - -R_API int r_line_hist_load(const char *file); -R_API char *r_line_readline(); -/* label ?! */ -R_API int r_line_hist_add(const char *line); -R_API int r_line_hist_save(const char *file); -R_API int r_line_hist_label(const char *label, void (*cb)(const char*)); -R_API void r_line_label_show(); - -#endif -#endif diff --git a/libr/io/Makefile b/libr/io/Makefile index 15bf6bfa30..27c718eb8d 100644 --- a/libr/io/Makefile +++ b/libr/io/Makefile @@ -9,7 +9,8 @@ CFLAGS+=-Wall -DCORELIB include ../socket/deps.mk -all: libr_io.${EXT_SO} libr_io.${EXT_AR} +.PHONY: pre +pre: libr_io.${EXT_SO} libr_io.${EXT_AR} ${MAKE} -C p include ${STATIC_IO_PLUGINS} diff --git a/libr/lang/Makefile b/libr/lang/Makefile index e0e5437529..81c4463e08 100644 --- a/libr/lang/Makefile +++ b/libr/lang/Makefile @@ -2,6 +2,6 @@ include ../config.mk NAME=r_lang OBJS=lang.o -DEPS=r_util r_lib r_line +DEPS=r_util r_lib r_cons include ../rules.mk diff --git a/libr/line/Makefile b/libr/line/Makefile deleted file mode 100644 index dbe4a9b503..0000000000 --- a/libr/line/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -include ../config.mk - -NAME=r_line -DEPS=r_util r_cons -OBJS=line.o -#LINK=-L../cons -lr_cons -Wl,-R../cons ../util/*.a - -include ../rules.mk - -line.o: dietline.c diff --git a/libr/line/label.c b/libr/line/label.c deleted file mode 100644 index c27371520d..0000000000 --- a/libr/line/label.c +++ /dev/null @@ -1,147 +0,0 @@ -/* THIS FILE CONTAINS OLD FUNCTIONS TO BE DEPRECATED OR RETHINKED */ - -/* scripting */ - -/* TODO: remove label related stuff */ -#if 0 -#define BLOCK 4096 -static char *labels = NULL; -static ut32 size = 0; -static ut32 lsize = 0; - -static int label_get(char *name) -{ - int i, n; - for(i=0;icompletion.argc = 3; - line->completion.argv = (const char **)myargv; - return 0; -} - -int main() { - const char *str; - RLine *line = r_line_new (); - r_cons_new (); - line->completion.run = (RLineCallback) complete; -#if 0 - if (!r_line_init ()) { - printf ("Cannot initizalize r_line\n"); - return 0; - } -#endif - for (;;) { - str = r_line_readline (0, NULL); - if (str == NULL) // catch eof - break; - printf ("%s\n", str); - r_line_hist_add (str); - } - r_line_free (); - return 0; -} diff --git a/libr/rules.mk b/libr/rules.mk index 09c47574b1..72c9c9a7cd 100644 --- a/libr/rules.mk +++ b/libr/rules.mk @@ -5,7 +5,7 @@ include $(LTOP)/config.mk ALL?= CFLAGS+=-I$(LIBR)/include -LDFLAGS+=$(addprefix -L$(LTOP)/,$(subst r_,,$(BINDEPS))) +LDFLAGS+=$(addprefix -L../,$(subst r_,,$(BINDEPS))) LDFLAGS+=$(addprefix -l,$(BINDEPS)) SRC=$(subst .o,.c,$(OBJ)) MAGICSED=| sed -e 's,-lr_magic,@LIBMAGIC@,g' @@ -17,23 +17,17 @@ ifeq ($(USE_RPATH),1) LDFLAGS+=-Wl,-R${PREFIX}/lib endif -#---------------------# -# Rules for libraries # -#---------------------# - ifeq (${OSTYPE},gnulinux) LIBNAME=${LDFLAGS_SONAME}${LIBSO}.${LIBVERSION} else LIBNAME=${LDFLAGS_SONAME}${LIBSO} endif -all: - @echo "DIR ${NAME}" - ${MAKE} ${EXTRA_TARGETS} ${LIBSO} ${LIBAR} +all: ${LIBSO} ${LIBAR} ${EXTRA_TARGETS} ifneq ($(SILENT),) - @-if [ -e p/Makefile ]; then (cd p && ${MAKE} all) ; fi + @-if [ -f p/Makefile ]; then (cd p && ${MAKE} all) ; fi else - @-if [ -e p/Makefile ] ; then (echo "DIR ${NAME}/p"; cd p && ${MAKE} all) ; fi + @-if [ -f p/Makefile ] ; then (echo "DIR ${NAME}/p"; cd p && ${MAKE} all) ; fi endif ifeq ($(WITHPIC),1) @@ -50,8 +44,7 @@ ${LIBSO}: $(EXTRA_TARGETS) ${WFD} ${OBJS} ${SHARED_OBJ} break ; \ fi ; done else -${LIBSO}: - @: +${LIBSO}: ; endif ifeq ($(WITHNONPIC),1) @@ -61,8 +54,7 @@ ifneq ($(SILENT),) endif ${CC_AR} ${OBJS} ${SHARED_OBJ} else -$(LIBAR): - @: +$(LIBAR): ; endif pkgcfg: @@ -91,6 +83,9 @@ mrproper: clean -rm -f *.d @true -.PHONY: all install pkgcfg clean deinstall uninstall +.PHONY: all install pkgcfg clean deinstall uninstall echodir + +# autodetect dependencies object +-include $(OBJS:.o=.d) endif diff --git a/libr/vm/Makefile b/libr/vm/Makefile index e5123e9878..361311caa8 100644 --- a/libr/vm/Makefile +++ b/libr/vm/Makefile @@ -1,3 +1,5 @@ +include ../config.mk + NAME=r_vm DEPS=r_util diff --git a/pkgcfg/r_line.pc.acr b/pkgcfg/r_line.pc.acr deleted file mode 100644 index da11b095bc..0000000000 --- a/pkgcfg/r_line.pc.acr +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@PREFIX@ -exec_prefix=${prefix} -libdir=@LIBDIR@ -includedir=${prefix}/include - -Name: r_line -Description: radare foundation libraries -Version: @VERSION@ -Requires: -Libs: -L${libdir} -lr_line -lr_util -lr_cons -Cflags: -I${includedir}/libr diff --git a/r2-bindings/vapi/r_cons.vapi b/r2-bindings/vapi/r_cons.vapi index 94461fa4ca..6636edbb91 100644 --- a/r2-bindings/vapi/r_cons.vapi +++ b/r2-bindings/vapi/r_cons.vapi @@ -1,9 +1,7 @@ /* radare - LGPL - Copyright 2009-2012 pancake */ -[CCode (cheader_filename="r_cons.h", cprefix="r_cons", lower_case_cprefix="r_cons_")] namespace Radare { - [Compact] - [CCode (cname="RCons", free_function="", cprefix="r_cons_")] + [CCode (cheader_filename="r_cons.h", cname="RCons", free_function="", cprefix="r_cons_")] /* XXX: LEAK */ public class RCons { // public RCons (); @@ -72,4 +70,17 @@ namespace Radare { //public static int grepbuf (string str, int len); public static void invert (bool set, int color); } + [Compact] + [CCode (cname="RLine", cheader_filename="r_line.h", cprefix="r_line_", free_function="")] + public class RLine { + //public RLine(); + public static RLine singleton(); + public static bool readline (); //int argc, char **argv); + public static void set_prompt (string promp); + + public static bool hist_load (string file); + public static bool hist_add (string line); + public static bool hist_save (string file); + //public static bool hist_label (string file); + } } diff --git a/r2-bindings/vapi/r_line.vapi b/r2-bindings/vapi/r_line.vapi index d2478a338c..1834326913 100644 --- a/r2-bindings/vapi/r_line.vapi +++ b/r2-bindings/vapi/r_line.vapi @@ -1,7 +1,6 @@ /* radare - LGPL - Copyright 2009-2011 pancake */ namespace Radare { - [Compact] [CCode (cname="RLine", cheader_filename="r_line.h", cprefix="r_line_", free_function="")] public class RLine { //public RLine(); diff --git a/sys/README b/sys/README deleted file mode 100644 index 86b9bcbd72..0000000000 --- a/sys/README +++ /dev/null @@ -1,8 +0,0 @@ -This directory contains the scripts used to ease updates, -compilation, and dependency fixes required to maintain -a system wide installation of radare2. - -./install.sh : install r2 in /usr -./update.sh : update r2 installation (fail on abi changes) -./python.sh : install python bindings -./uninstall.sh : deinstall r2