* More work for 'binr'. Hopefully everything is done now :)

This commit is contained in:
pancake 2010-05-29 13:24:47 +02:00
parent eb05e6a6b2
commit 64c329d297
9 changed files with 12 additions and 285 deletions

View File

@ -9,6 +9,8 @@ all:
install:
for a in ${BINS} ; do ${INSTALL_PROGRAM} $$a/$$a ${DESTDIR}/${PREFIX}/bin ; done
# shortcut
-cd ${PFX}/bin && rm -f r2 ; ln -fs radare2 r2
clean:
@for a in ${BINS} ; do (cd $$a && ${MAKE} clean); done

View File

@ -1,50 +0,0 @@
rafind2.o: rafind2.c /usr/include/stdio.h /usr/include/features.h \
/usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \
/usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \
/usr/lib/gcc/i686-pc-linux-gnu/4.5.0/include/stddef.h \
/usr/include/bits/types.h /usr/include/bits/typesizes.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/i686-pc-linux-gnu/4.5.0/include/stdarg.h \
/usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
/usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \
/usr/include/endian.h /usr/include/bits/endian.h \
/usr/include/bits/byteswap.h /usr/include/sys/select.h \
/usr/include/bits/select.h /usr/include/bits/sigset.h \
/usr/include/bits/time.h /usr/include/sys/sysmacros.h \
/usr/include/bits/pthreadtypes.h /usr/include/alloca.h \
/usr/include/getopt.h ../../libr/include/r_types.h \
../../libr/include/r_userconf.h ../../libr/include/r_types_base.h \
/usr/include/string.h /usr/include/xlocale.h /usr/include/sys/time.h \
/usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/fcntl.h \
/usr/include/bits/fcntl.h /usr/include/dirent.h \
/usr/include/bits/dirent.h /usr/include/bits/posix1_lim.h \
/usr/include/bits/local_lim.h /usr/include/linux/limits.h \
/usr/include/unistd.h /usr/include/bits/posix_opt.h \
/usr/include/bits/confname.h ../../libr/include/r_print.h \
../../libr/include/r_types.h ../../libr/include/r_util.h \
../../libr/include/btree.h ../../libr/include/r_list.h \
../../libr/include/r_flist.h ../../libr/include/list.h \
../../libr/include/r_search.h ../../libr/include/r_util.h \
../../libr/include/r_cons.h /usr/include/termios.h \
/usr/include/bits/termios.h /usr/include/sys/ttydefaults.h \
/usr/include/sys/ioctl.h /usr/include/bits/ioctls.h \
/usr/include/asm/ioctls.h /usr/include/asm-generic/ioctls.h \
/usr/include/linux/ioctl.h /usr/include/asm/ioctl.h \
/usr/include/asm-generic/ioctl.h /usr/include/bits/ioctl-types.h \
/usr/include/sys/wait.h /usr/include/signal.h /usr/include/bits/signum.h \
/usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \
/usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \
/usr/include/linux/types.h /usr/include/asm/types.h \
/usr/include/asm-generic/types.h /usr/include/asm-generic/int-ll64.h \
/usr/include/asm/bitsperlong.h /usr/include/asm-generic/bitsperlong.h \
/usr/include/linux/posix_types.h /usr/include/linux/stddef.h \
/usr/include/asm/posix_types.h /usr/include/asm/posix_types_32.h \
/usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \
/usr/include/sys/resource.h /usr/include/bits/resource.h \
/usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \
/usr/include/sys/socket.h /usr/include/sys/uio.h /usr/include/bits/uio.h \
/usr/include/bits/socket.h /usr/include/bits/sockaddr.h \
/usr/include/asm/socket.h /usr/include/asm-generic/socket.h \
/usr/include/asm/sockios.h /usr/include/asm-generic/sockios.h \
../../libr/include/r_lib.h ../../libr/include/list.h \
../../libr/include/r_io.h

Binary file not shown.

View File

@ -6,13 +6,8 @@ PFX=${DESTDIR}${PREFIX}
#PREFIX=${PFX}
# Libraries
LIBLIST=util line cons line lib io meta lang flags bin hash config syscall socket
LIBLIST+=cmd asm anal print parse search diff bp reg sign vm th db debug core diff
# Under development
#LIBLIST+=print
#LIBLIST+=util
#LIBLIST+=search
LIBLIST=util line cons lib io meta lang flags bin hash config syscall socket
LIBLIST+=cmd asm anal print parse search diff bp reg sign vm th db debug core
# TODO : generate single library linking against the rest
#LIBSO=libr.so
@ -67,24 +62,6 @@ install-includes:
@${INSTALL_DIR} ${PFX}/include/libr
(cd include && ${INSTALL_DATA} * ${PFX}/include/libr)
install-bins:
# programs
@${INSTALL_DIR} ${PFX}/bin
@for a in `find */t -perm -u+x -type f | grep 2`; \
do echo "$$a ${PFX}/bin"; \
${INSTALL_PROGRAM} $$a ${PFX}/bin ; \
done
# shortcut
-cd ${PFX}/bin && rm -f r2 ; ln -fs radare2 r2
install-test-bins:
# test programs
@${INSTALL_DIR} ${PFX}/lib/radare2/test
@for a in `find */t -perm -u+x -type f | grep -v 2`; \
do echo "$$a ${PFX}/lib/radare2/test" ; \
${INSTALL_PROGRAM} $$a ${PFX}/lib/radare2/test ; \
done
install-symlink:
mkdir -p ${PFX}/bin
mkdir -p ${PFX}/include
@ -104,7 +81,7 @@ install-symlink:
done ; \
done
install: install-includes install-pkgconfig install-bins install-test-bins
install: install-includes install-pkgconfig
# TODO :Use INSTALL_DATA_DIR instead of mkdir
# libraries
@${INSTALL_DIR} ${PFX}/lib
@ -116,28 +93,27 @@ install: install-includes install-pkgconfig install-bins install-test-bins
@for a in `find * | grep -e '\.a$$'` ; do \
echo "$$a ${PFX}/lib"; ${INSTALL_DATA} $$a ${PFX}/lib ; done
# plugins
#${INSTALL_DATA} libr.pc ${PFX}/lib/pkgconfig
@${INSTALL_DIR} ${PFX}/lib/radare2
@for a in `find */p -perm -u+x -type f`; \
do echo "$$a ${PFX}/lib/radare2"; \
${INSTALL_DATA} $$a ${PFX}/lib/radare2 ; done
${INSTALL_DATA} lang/p/radare.* ${PFX}/lib/radare2
echo "lang/p/radare.* ${PFX}/lib/radare2"
# strip rpath from ALL bins
./rpathstrip.sh ${PFX}
# strip rpath from ALL bins ONLY in Linux
[ "`uname`" = Linux ] && ./rpathstrip.sh ${PFX}
deinstall uninstall:
# libraries
-@for a in `find * | grep -e '\.${EXT_SO}$$' | grep -v 'lib/t' | grep lib` ; do \
a=`echo $$a | awk -F / '{ print $$NF; }'`; \
echo ${PREFIX}/lib/$$a ; rm -f ${PREFIX}/lib/$$a ; done
### object archives
# object archives
-@for a in `find * | grep -e '\.a$$'` ; do \
a=`echo $$a | awk -F / '{ print $$NF; }'`; \
echo ${PREFIX}/lib/$$a ; rm -f ${PREFIX}/lib/$$a ; done
### includes
# includes
-(cd include && for a in * ; do rm -f ${PREFIX}/libr/$$a ; done)
### programs
# programs
-@for a in `find */t -perm -u+x -type f | grep 2`; do \
a=`echo $$a|awk -F / '{ print $$NF; }'`; \
echo ${PREFIX}/bin/$$a ; rm -f ${PREFIX}/bin/$$a ; done
@ -149,15 +125,9 @@ deinstall uninstall:
rm -f ${PREFIX}/lib/pkgconfig/libr.pc
rm -f ${PREFIX}/lib/pkgconfig/r_*.pc
# test programs
-@for a in `find */t -perm -u+x -type f | grep -v 2`; do \
a="${PREFIX}/bin/libr-test/`echo $$a|awk -F / '{ print $$NF; }'`"; \
echo $$a ; rm -f $$a ; done
rm -rf ${PREFIX}/bin/libr-test
@echo libr aka radare2 has been uninstalled from PREFIX=${PREFIX}
todo:
grep -re TODO -e XXX *
clean:
for lib in ${LIBLIST}; do ( cd $${lib} && ${MAKE} clean ); done
rm -rf .objs
@ -168,4 +138,4 @@ mrproper: clean
sloc:
${MAKE} -C .. sloc SLOCDIR=libr
.PHONY: sloc mrproper clean todo all pkgcfg install deinstall uninstall libr
.PHONY: sloc mrproper clean all pkgcfg install deinstall uninstall libr

View File

@ -11,7 +11,6 @@ all: fastcall${EXT_EXE}
fastcall${EXT_EXE}: fastcall.o
${CC} fastcall.o ${LDPATH} ${LDFLAGS} -o fastcall${EXT_EXE}
@#-Wl,-R.. -L.. -lr_asm -o fastcall
myclean:
rm -f fastcall fastcall.o

View File

@ -1,6 +1,4 @@
include ../../config.mk
#include ../../../config-user.mk
#include ../../../mk/${COMPILER}.mk
all: test${EXT_EXE}
@ -8,4 +6,4 @@ test${EXT_EXE}:
${CC} -g -I ../../include test.c ../*.o -lr_util -L../../util -L../../cons -lr_cons -o test${EXT_EXE}
clean:
rm -f test
rm -f test${EXT_EXE}

View File

@ -2,15 +2,6 @@ include ../../config.mk
OBJ=test.o
BIN=regtest
#${EXT_EXE}
BINDEPS=r_reg r_util
#all: reg${EXT_EXE}
#regtest${EXT_EXE}:
# ${CC} -L../../util -I ../../include -Wl,-R.. -L.. test.c -lr_util -lr_reg -o regtest${EXT_EXE}
#clean:
# rm -f test a.out
include ../../rules.mk

View File

@ -1,182 +0,0 @@
/* radare - LGPL - Copyright 2009 pancake<nopcode.org> */
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <r_types.h>
#include <r_print.h>
#include <r_search.h>
#include <r_util.h>
#include <r_cons.h>
#include <r_lib.h>
#include <r_io.h>
static struct r_io_t *io;
static int fd = -1;
static int rad = 0;
struct r_search_t *rs;
static ut64 from = 0LL, to = -1;
static char *mask = "";
static int nonstop = 0;
static int mode = R_SEARCH_STRING;
static ut64 cur = 0;
static ut8 *buffer = NULL;
static char *curfile = NULL;
static ut64 bsize = 4096;
static int hexstr = 0;
static struct r_print_t *pr = NULL;
LIST_HEAD(kws_head);
typedef struct {
char *str;
struct list_head list;
} BoxedString;
static int hit(RSearchKeyword *kw, void *user, ut64 addr) {
//const ut8 *buf = (ut8*)user;
int delta = addr-cur;
if (rad) {
printf("f hit%d_%d 0x%08"PFMT64x" ; %s\n", 0, kw->count, addr, curfile);
} else {
if (!kw->count) printf("; %s\n", kw->keyword);
printf("%s: %03d @ 0x%"PFMT64x"\n", curfile, kw->count, addr);
if (pr) {
r_print_hexdump(pr, addr, (ut8*)buffer+delta, 78, 16, R_TRUE);
r_cons_flush();
}
}
return 1;
}
static int show_help(char *argv0, int line) {
printf("Usage: %s [-Xnzh] [-f from] [-t to] [-z] [-s str] [-x hex] file ...\n", argv0);
if (line) return 0;
printf(
" -z search for zero-terminated strings\n"
" -s [str] search for zero-terminated strings (can be used multiple times)\n"
" -m [str] set a mask\n"
" -x [hex] search for hexpair string (909090) (can be used multiple times)\n"
" -f [from] start searching from address 'from'\n"
" -f [to] stop search at address 'to'\n"
" -X show hexdump of search results\n"
" -n do not stop on read errors\n"
" -r print using radare commands\n"
" -b set block size\n"
" -h show this help\n"
" -V print version and exit\n"
);
return 0;
}
static int rafind_open(char *file) {
int ret, last = 0;
struct list_head *pos;
io = r_io_new();
fd = r_io_open(io, file, R_IO_READ, 0);
if (fd == -1) {
fprintf (stderr, "Cannot open file '%s'\n", file);
return 1;
}
r_cons_new();
rs = r_search_new(mode);
buffer = malloc(bsize);
r_search_set_callback(rs, &hit, buffer);
if (to == -1) {
to = r_io_size(io, fd);
}
if (mode == R_SEARCH_KEYWORD) {
list_for_each(pos, &(kws_head)) {
BoxedString *kw = list_entry(pos, BoxedString, list);
r_search_kw_add (rs, (hexstr)?
r_search_keyword_new_hex (kw->str, mask, NULL) :
r_search_keyword_new_str (kw->str, mask, NULL));
free(kw);
}
}
curfile = file;
r_search_begin(rs);
r_io_seek(io, from, R_IO_SEEK_SET);
//printf("; %s 0x%08"PFMT64x"-0x%08"PFMT64x"\n", file, from, to);
for(cur=from; !last && cur<to;cur+=bsize) {
if ((cur+bsize)>to) {
bsize = to-cur;
last=1;
}
ret = r_io_read(io, buffer, bsize);
if (ret == 0) {
if (nonstop) continue;
// fprintf(stderr, "Error reading at 0x%08"PFMT64x"\n", cur);
return 1;
}
if (ret != bsize)
bsize = ret;
r_search_update_i(rs, cur, buffer, bsize);
}
rs = r_search_free(rs);
return 0;
}
int main(int argc, char **argv) {
int c;
while ((c = getopt(argc, argv, "b:m:s:x:Xzf:t:rnhV")) != -1) {
BoxedString *kw = R_NEW(BoxedString);
INIT_LIST_HEAD(&(kw->list));
switch(c) {
case 'r':
rad = 1;
break;
case 'n':
nonstop = 1;
break;
case 's':
mode = R_SEARCH_KEYWORD;
hexstr = 0;
kw->str = optarg;
list_add(&(kw->list), &(kws_head));
break;
case 'b':
bsize = r_num_math(NULL, optarg);
break;
case 'z':
mode = R_SEARCH_STRING;
break;
case 'x':
mode = R_SEARCH_KEYWORD;
hexstr = 1;
kw->str = optarg;
list_add(&(kw->list), &(kws_head));
break;
case 'm':
// XXX should be from hexbin
mask = optarg;
break;
case 'f':
from = r_num_math(NULL, optarg);
break;
case 't':
to = r_num_math(NULL, optarg);
break;
case 'X':
pr = r_print_new();
break;
case 'V':
printf("rafind2 v"VERSION"\n");
return 0;
case 'h':
return show_help(argv[0], 0);
}
}
if (optind == argc)
return show_help(argv[0], 1);
for (;optind < argc;optind++)
rafind_open(argv[optind]);
return 0;
}

View File

@ -3,7 +3,6 @@ include ../../config.mk
ifeq ($(WITHPIC),1)
# OSX
FLAGS=-I../../include -L.. -lr_util -g -DVERSION=\"${VERSION}\"
#FLAGS=-I../../include -Wl,-R.. -L.. -lr_util -g -DVERSION=\"${VERSION}\"
EFLAGS=-L.. -lr_util
else
FLAGS=-I../../include -g -DVERSION=\"${VERSION}\"