From 9890c6e8b03780c07fbe58dca04c9a1266d5ed7e Mon Sep 17 00:00:00 2001 From: pancake/imac Date: Sun, 21 Feb 2010 20:21:36 +0100 Subject: [PATCH] * Fix build in OSX - env.sh now also uses DYLD_LIBRARY_PATH - Fixes in ollyasm/dis to link with no global variables - Remove double definition of global _state - Same for asm_java - Split -shared and -Wl,-R into LDFLAGS_{LIB|LINKPATH} - Fixes linkage in osx - anal_x86_bea plugin now links correctly against BeaEgine.o - dietline is now #include'd from line.c - no debugger support yet - Do not externalize any variable. Some linkage does not support it * Remove bininfo dependency .. aims to be merged into bin soon * Added r_str_case() method to change to lower/upper case a string --- Makefile | 6 +- config-user.mk.acr | 2 +- configure-plugins | 5 +- env.sh | 1 + libr/Makefile | 23 ++--- libr/anal/arch/x86/dislen.c | 28 +++--- libr/anal/p/Makefile | 4 +- libr/asm/arch/arm/gnu/arm-dis.c | 4 +- libr/asm/arch/csr/csr_disasm/dis.c | 2 + libr/asm/arch/csr/csr_disasm/dis.h | 2 +- libr/asm/arch/java/javasm/javasm.c | 4 +- libr/asm/arch/java/javasm/javasm.h | 4 +- libr/asm/arch/m68k/m68k_disasm/m68k_disasm.h | 1 + libr/asm/arch/x86/ollyasm/assembl.c | 3 + libr/asm/arch/x86/ollyasm/disasm.c | 21 ++++ libr/asm/arch/x86/ollyasm/disasm.h | 2 + libr/asm/p/Makefile | 2 +- libr/asm/p/asm_x86_olly.c | 2 +- libr/bin/p/Makefile | 4 +- libr/bp/p/Makefile | 5 +- libr/cons/cons.c | 2 +- libr/cons/filter.c | 100 +++++++++---------- libr/cons/input.c | 15 ++- libr/cons/pipe.c | 9 +- libr/core/Makefile | 2 +- libr/core/cmd.c | 7 +- libr/core/core.c | 2 +- libr/core/file.c | 4 +- libr/core/t/Makefile | 2 +- libr/crypto/p/Makefile | 2 +- libr/debug/p/Makefile | 2 +- libr/debug/p/debug_native.c | 12 ++- libr/debug/p/libgdbwrap/Makefile | 4 +- libr/debug/p/libgdbwrap/gdbwrapper.c | 2 +- libr/debug/p/libgdbwrap/include/revm.h | 7 +- libr/include/r_cons.h | 2 +- libr/include/r_line.h | 2 +- libr/include/r_util.h | 1 + libr/include/r_vm.h | 2 +- libr/io/p/Makefile | 4 +- libr/io/t/Makefile | 4 +- libr/lang/p/Makefile | 12 +-- libr/lib/lib.c | 2 +- libr/lib/t/Makefile | 2 +- libr/line/Makefile | 2 +- libr/line/dietline.c | 2 - libr/line/line.c | 4 +- libr/parse/Makefile | 2 +- libr/parse/p/Makefile | 2 +- libr/parse/p/parse_mreplace/mmemory.c | 3 +- libr/parse/p/parse_mreplace/mreplace.c | 3 +- libr/rules.mk | 2 + libr/socket/proc.c | 4 + libr/syscall/syscall.c | 2 +- libr/util/str.c | 14 ++- libr/util/t/Makefile | 4 +- libr/vm/reg.c | 13 +-- mk/gcc.mk | 12 ++- plugins.def.cfg | 2 +- 59 files changed, 235 insertions(+), 164 deletions(-) diff --git a/Makefile b/Makefile index 56d21f6d1f758..bd2d300dbc74a 100644 --- a/Makefile +++ b/Makefile @@ -45,14 +45,14 @@ pkgcfg: install: ${INSTALL_DIR} ${DESTDIR}${PREFIX}/share/doc/radare2 for a in doc/* ; do ${INSTALL_DATA} $$a ${DESTDIR}/${PREFIX}/share/doc/radare2 ; done - cd libr && ${MAKE} install PARENT=1 PREFIX=${DESTDIR}${PREFIX} - cd swig && ${MAKE} install + cd libr && ${MAKE} install PARENT=1 PREFIX=${PREFIX} DESTDIR=${DESTDIR} + cd swig && ${MAKE} install PREFIX=${PREFIX} DESTDIR=${DESTDIR} uninstall: rm -rf prefix deinstall: uninstall - cd libr && ${MAKE} uninstall PARENT=1 PREFIX=${DESTDIR}${PREFIX} + cd libr && ${MAKE} uninstall PARENT=1 PREFIX=${PREFIX} DESTDIR=${DESTDIR} rm -rf ${DESTDIR}${PREFIX}/share/doc/radare2 dist: diff --git a/config-user.mk.acr b/config-user.mk.acr index cf33fbdd2ede7..170531bcc3f21 100644 --- a/config-user.mk.acr +++ b/config-user.mk.acr @@ -17,7 +17,7 @@ INSTALL_PROGRAM=@INSTALL_PROGRAM@ VERSION=@VERSION@ # ./configure --with-ostype=[linux,osx,solaris,windows] # TODO: rename to w32, w64? -OSTYPE?=@USEROSTYPE@ +OSTYPE=@USEROSTYPE@ HOST_OS=@HOST_OS@ DL_LIBS=@DL_LIBS@ WITHPIC=@WITHPIC@ diff --git a/configure-plugins b/configure-plugins index b072003313ab0..ae24aef854654 100755 --- a/configure-plugins +++ b/configure-plugins @@ -53,7 +53,7 @@ generate_configh () { fi echo " &r_${lib}_plugin_${plg}, \\" done - echo " 0" + [ -n "$oldlib" ] && echo " 0" } generate_configmk () { @@ -93,7 +93,8 @@ sub () { } dosort () { - ( for a in $1 ; do echo $a ; done ) | sort -t. --key=1,1d + ( for a in $1 ; do echo $a ; done ) | sort -t. + #( for a in $1 ; do echo $a ; done ) | sort -t. --key=1,1d } sort_vars () { diff --git a/env.sh b/env.sh index aee5291f17dd5..79c8cef32df62 100644 --- a/env.sh +++ b/env.sh @@ -4,6 +4,7 @@ new_env=' LIBR_PLUGINS=$PWD/prefix/lib/radare2 PATH=$PATH:$PWD/prefix/bin LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/prefix/lib +DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/prefix/lib PKG_CONFIG_PATH=$PWD/libr/ ' diff --git a/libr/Makefile b/libr/Makefile index 84d9b2a947896..c96fcd236de20 100644 --- a/libr/Makefile +++ b/libr/Makefile @@ -6,7 +6,7 @@ PFX=${DESTDIR}${PREFIX} #PREFIX=${PFX} # Libraries -LIBLIST=util lib io meta lang flags bin bininfo macro hash line cons print config syscall range socket cmd asm anal parse search diff bp reg debug core var sign trace vm th db +LIBLIST=util lib io meta lang flags bin macro hash line cons print config syscall range socket cmd asm anal parse search diff bp reg debug core var sign trace vm th db # Under development #LIBLIST+=print @@ -27,11 +27,10 @@ libr: .objs libr2.${EXT_SO} libr2.${EXT_AR} ifeq ($(WITHPIC),1) libr2.${EXT_SO}: - ${CC} -shared ${PIC_CFLAGS} .objs/*.o -o libr2.${EXT_SO} + ${CC} ${LDFLAGS_LIB} ${PIC_CFLAGS} .objs/*.o -o libr2.${EXT_SO} libr2.${EXT_AR}: @echo No archive libr.a. Try --without-pic in configure - else libr2.${EXT_SO}: @@ -66,15 +65,15 @@ install-includes: install-bins: # programs @${INSTALL_DIR} ${PFX}/bin - @for a in `find */t -perm /u+x -type f | grep 2`; \ + @for a in `find */t -perm -u+x -type f | grep 2`; \ do echo "$$a ${PFX}/bin"; ${INSTALL_PROGRAM} $$a ${PFX}/bin ; done # shortcut - cp -f ${PFX}/bin/radare2 ${PFX}/bin/r2 + -cp -f ${PFX}/bin/radare2 ${PFX}/bin/r2 install-test-bins: # test programs @${INSTALL_DIR} ${PFX}/bin/libr-test - @for a in `find */t -perm /u+x -type f | grep -v 2`; \ + @for a in `find */t -perm -u+x -type f | grep -v 2`; \ do echo "$$a ${PFX}/bin/libr-test"; \ ${INSTALL_PROGRAM} $$a ${PFX}/bin/libr-test ; done @@ -82,7 +81,7 @@ install: install-includes install-vapi install-pkgconfig install-bins install-te # TODO :Use INSTALL_DATA_DIR instead of mkdir # libraries @${INSTALL_DIR} ${PFX}/lib - @for a in `find * | grep -e '\.so$$' | grep lib` ; do \ + @for a in `find * | grep -e '\.${EXT_SO}$$' | grep lib` ; do \ echo "$$a ${PFX}/lib"; ${INSTALL_DATA} $$a ${PFX}/lib ; done # object archives @for a in `find * | grep -e '\.a$$'` ; do \ @@ -90,7 +89,7 @@ install: install-includes install-vapi install-pkgconfig install-bins install-te # plugins #${INSTALL_DATA} libr.pc ${PFX}/lib/pkgconfig @${INSTALL_DIR} ${PFX}/lib/radare2 - @for a in `find */p -perm /u+x -type f`; \ + @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 @@ -98,7 +97,7 @@ install: install-includes install-vapi install-pkgconfig install-bins install-te deinstall uninstall: # libraries - -@for a in `find * | grep -e '\.so$$' | grep lib` ; do \ + -@for a in `find * | grep -e '\.${EXT_SO}$$' | grep lib` ; do \ a=`echo $$a | awk -F / '{ print $$NF; }'`; \ echo ${PREFIX}/lib/$$a ; rm -f ${PREFIX}/lib/$$a ; done ### object archives @@ -109,18 +108,18 @@ deinstall uninstall: -(cd include && for a in * ; do rm -f ${PREFIX}/libr/$$a ; done) cd vapi/ ; for a in *.vapi *.deps ; do rm -f ${PREFIX}/share/vala/vapi/$$a ; done ### programs - -@for a in `find */t -perm /u+x -type f | grep 2`; do \ + -@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 # plugins - -@for a in `find */p -perm /u+x -type f`; do \ + -@for a in `find */p -perm -u+x -type f`; do \ a="${PREFIX}/lib/radare2/`echo $$a|awk -F / '{ print $$NF; }'`"; \ echo $$a ; rm -f $$a ; done rm -rf ${PREFIX}/lib/radare2 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 \ + -@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 diff --git a/libr/anal/arch/x86/dislen.c b/libr/anal/arch/x86/dislen.c index 464dcacc6146c..22857b2999038 100644 --- a/libr/anal/arch/x86/dislen.c +++ b/libr/anal/arch/x86/dislen.c @@ -3,21 +3,21 @@ #include "dislen.h" -DWORD disasm_len; // 0 if error -DWORD disasm_flag; // C_xxx -DWORD disasm_memsize; // value = disasm_mem -DWORD disasm_datasize; // value = disasm_data -DWORD disasm_defdata; // == C_66 ? 2 : 4 -DWORD disasm_defmem; // == C_67 ? 2 : 4 +static DWORD disasm_len; // 0 if error +static DWORD disasm_flag; // C_xxx +static DWORD disasm_memsize; // value = disasm_mem +static DWORD disasm_datasize; // value = disasm_data +static DWORD disasm_defdata; // == C_66 ? 2 : 4 +static DWORD disasm_defmem; // == C_67 ? 2 : 4 -BYTE disasm_seg; // CS DS ES SS FS GS -BYTE disasm_rep; // REPZ/REPNZ -BYTE disasm_opcode; // opcode -BYTE disasm_opcode2; // used when opcode==0F -BYTE disasm_modrm; // modxxxrm -BYTE disasm_sib; // scale-index-base -BYTE disasm_mem[8]; // mem addr value -BYTE disasm_data[8]; // data value +static BYTE disasm_seg; // CS DS ES SS FS GS +static BYTE disasm_rep; // REPZ/REPNZ +static BYTE disasm_opcode; // opcode +static BYTE disasm_opcode2; // used when opcode==0F +static BYTE disasm_modrm; // modxxxrm +static BYTE disasm_sib; // scale-index-base +static BYTE disasm_mem[8]; // mem addr value +static BYTE disasm_data[8]; // data value // returns: 1 if success // 0 if error diff --git a/libr/anal/p/Makefile b/libr/anal/p/Makefile index 7efa29a9ccba0..3ab8a5fee0fff 100644 --- a/libr/anal/p/Makefile +++ b/libr/anal/p/Makefile @@ -1,7 +1,7 @@ BINDEPS=foo include ../../config.mk -CFLAGS=-I../../include -I../../asm/arch/ -I../arch/ -Wall -fPIC -shared -Wl,-R.. -L.. +CFLAGS=-I../../include -I../../asm/arch/ -I../arch/ -Wall -fPIC ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}.. -L.. CFLAGS+=-DR_DEBUG=1 ANAL_X86_OBJ=../arch/x86/dislen.o @@ -18,7 +18,7 @@ anal_x86.${EXT_SO}: anal_x86.o ${ANAL_X86_OBJ} @#strip -s anal_x86.so anal_x86_bea.${EXT_SO}: anal_x86_bea.o - ${CC} ${CFLAGS} -o anal_x86_bea.${EXT_SO} anal_x86_bea.o + ${CC} ${CFLAGS} -o anal_x86_bea.${EXT_SO} anal_x86_bea.o ../../asm/arch/x86/bea/BeaEngine.o @#strip -s anal_x86_bea.so clean: diff --git a/libr/asm/arch/arm/gnu/arm-dis.c b/libr/asm/arch/arm/gnu/arm-dis.c index 03ad56b7a2e8d..3a215f13e96f8 100644 --- a/libr/asm/arch/arm/gnu/arm-dis.c +++ b/libr/asm/arch/arm/gnu/arm-dis.c @@ -79,7 +79,7 @@ extern int arm_mode; #define FPU_VFP_EXT_V3 1 #define FPU_NEON_EXT_V1 1 -int floatformat_ieee_single_little; +static int floatformat_ieee_single_little; /* Assume host uses ieee float. */ static void floatformat_to_double (int *ignored, unsigned char *data, double *dest) @@ -1569,7 +1569,7 @@ enum map_type { MAP_DATA }; -enum map_type last_type; +static enum map_type last_type; int last_mapping_sym = -1; bfd_vma last_mapping_addr = 0; diff --git a/libr/asm/arch/csr/csr_disasm/dis.c b/libr/asm/arch/csr/csr_disasm/dis.c index 3cc6f28b2a9e9..6b8db0508a63d 100644 --- a/libr/asm/arch/csr/csr_disasm/dis.c +++ b/libr/asm/arch/csr/csr_disasm/dis.c @@ -12,6 +12,8 @@ #include #include "dis.h" +static struct state _state; + #include static inline struct state *get_state(void) diff --git a/libr/asm/arch/csr/csr_disasm/dis.h b/libr/asm/arch/csr/csr_disasm/dis.h index 6e451c857031b..b791016caa04c 100644 --- a/libr/asm/arch/csr/csr_disasm/dis.h +++ b/libr/asm/arch/csr/csr_disasm/dis.h @@ -55,7 +55,7 @@ struct state { int s_nop; struct directive *s_nopd; int s_ff_quirk; -} _state; +}; int arch_csr_disasm(char *str, unsigned char *b, ut64 seek); diff --git a/libr/asm/arch/java/javasm/javasm.c b/libr/asm/arch/java/javasm/javasm.c index 362c4eb2b6473..36487ad6f73ed 100644 --- a/libr/asm/arch/java/javasm/javasm.c +++ b/libr/asm/arch/java/javasm/javasm.c @@ -31,6 +31,8 @@ #include #endif +static struct cp_item *cp_items; +static struct cp_item cp_null_item; // NOTE: must be initialized for safe use static struct constant_t { char *name; @@ -269,7 +271,7 @@ static ut16 r_ntohs (ut16 foo) { #if BIGENDIAN /* do nothing */ #else - ut8 *p = &foo; + ut8 *p = (ut8 *)&foo; foo = p[1] | p[0]<<8; #endif return foo; diff --git a/libr/asm/arch/java/javasm/javasm.h b/libr/asm/arch/java/javasm/javasm.h index 1da17d8d00027..d2062f01fd20f 100644 --- a/libr/asm/arch/java/javasm/javasm.h +++ b/libr/asm/arch/java/javasm/javasm.h @@ -25,8 +25,8 @@ struct cp_item { ut64 off; }; -struct cp_item *cp_items; -struct cp_item cp_null_item; // NOTE: must be initialized for safe use +//extern struct cp_item *cp_items; +//extern struct cp_item cp_null_item; // NOTE: must be initialized for safe use int java_print_opcode(int idx, const ut8 *bytes, char *output); int java_disasm(const ut8 *bytes, char *output); diff --git a/libr/asm/arch/m68k/m68k_disasm/m68k_disasm.h b/libr/asm/arch/m68k/m68k_disasm/m68k_disasm.h index 429659a4108a6..04be15120e1ab 100644 --- a/libr/asm/arch/m68k/m68k_disasm/m68k_disasm.h +++ b/libr/asm/arch/m68k/m68k_disasm/m68k_disasm.h @@ -475,6 +475,7 @@ typedef struct dis_buffer dis_buffer_t; #define PRINT_DREG(dbuf, reg) addstr(dbuf, dregs[reg]) #define PRINT_AREG(dbuf, reg) addstr(dbuf, aregs[reg]) +#undef NBBY #define NBBY 256 /*@@@*/ #ifndef INT_MAX #define INT_MAX 0x7fffffff; diff --git a/libr/asm/arch/x86/ollyasm/assembl.c b/libr/asm/arch/x86/ollyasm/assembl.c index 04e9039905b2a..2f0d354d827de 100644 --- a/libr/asm/arch/x86/ollyasm/assembl.c +++ b/libr/asm/arch/x86/ollyasm/assembl.c @@ -32,6 +32,9 @@ #include "disasm.h" +static int ideal=0; // Force IDEAL decoding mode +static int sizesens=0; // How to decode size-sensitive mnemonics + //////////////////////////////////////////////////////////////////////////////// ///////////////////////////// ASSEMBLER FUNCTIONS ////////////////////////////// diff --git a/libr/asm/arch/x86/ollyasm/disasm.c b/libr/asm/arch/x86/ollyasm/disasm.c index fd652e9f1019b..f9d5588f4c9f5 100644 --- a/libr/asm/arch/x86/ollyasm/disasm.c +++ b/libr/asm/arch/x86/ollyasm/disasm.c @@ -27,7 +27,28 @@ #include //#pragma hdrstop +static int lowercase = 1; // Force lowercase display XXX remove it #include "disasm.h" +#if 1 +static int ideal; // Force IDEAL decoding mode +static int tabarguments; // Tab between mnemonic and arguments +static int extraspace; // Extra space between arguments +static int putdefseg; // Display default segments in listing +static int showmemsize; // Always show memory size +static int shownear; // Show NEAR modifiers +static int shortstringcmds; // Use short form of string commands +static int sizesens; // How to decode size-sensitive mnemonics +static int symbolic; // Show symbolic addresses in disasm +static int farcalls; // Accept far calls, returns & addresses +static int decodevxd; // Decode VxD calls (Win95/98) +static int privileged; // Accept privileged commands +static int iocommand; // Accept I/O commands +static int badshift; // Accept shift out of range 1..31 +static int extraprefix; // Accept superfluous prefixes +static int lockedbus; // Accept LOCK prefixes +static int stackalign; // Accept unaligned stack operations +static int iswindowsnt; // When checking for dangers, assume NT +#endif /* Helpers for non-w32 */ char * diff --git a/libr/asm/arch/x86/ollyasm/disasm.h b/libr/asm/arch/x86/ollyasm/disasm.h index e963c7b0ff119..1758d5a7e30d3 100644 --- a/libr/asm/arch/x86/ollyasm/disasm.h +++ b/libr/asm/arch/x86/ollyasm/disasm.h @@ -331,6 +331,7 @@ typedef struct t_asmmodel { // Model to search for assembler command int jmppos; // Position of jump offset in command } t_asmmodel; +#if 0 unique int ideal; // Force IDEAL decoding mode unique int lowercase; // Force lowercase display unique int tabarguments; // Tab between mnemonic and arguments @@ -350,6 +351,7 @@ unique int extraprefix; // Accept superfluous prefixes unique int lockedbus; // Accept LOCK prefixes unique int stackalign; // Accept unaligned stack operations unique int iswindowsnt; // When checking for dangers, assume NT +#endif int Assemble(char *cmd,ulong ip,t_asmmodel *model,int attempt, int constsize,char *errtext); diff --git a/libr/asm/p/Makefile b/libr/asm/p/Makefile index ad3fb695d8f06..610c76756a1eb 100644 --- a/libr/asm/p/Makefile +++ b/libr/asm/p/Makefile @@ -1,6 +1,6 @@ include ../../config.mk -CFLAGS=-I../../include -I../arch/ -I../arch/include -Wall -fPIC -shared -Wl,-R.. +CFLAGS=-I../../include -I../arch/ -I../arch/include -Wall -fPIC ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}.. # XXX CFLAGS+=-DLIL_ENDIAN=1 CFLAGS+=-L../../util -lr_util diff --git a/libr/asm/p/asm_x86_olly.c b/libr/asm/p/asm_x86_olly.c index 69e88573ff963..147dc04797de3 100644 --- a/libr/asm/p/asm_x86_olly.c +++ b/libr/asm/p/asm_x86_olly.c @@ -13,7 +13,7 @@ static int disassemble(struct r_asm_t *a, struct r_asm_aop_t *aop, ut8 *buf, ut64 len) { t_disasm disasm_obj; - lowercase=1; + //lowercase=1; aop->inst_len = Disasm_olly(buf, len, a->pc, &disasm_obj, DISASM_FILE); snprintf(aop->buf_asm, R_ASM_BUFSIZE, "%s", disasm_obj.result); diff --git a/libr/bin/p/Makefile b/libr/bin/p/Makefile index 014825caf623f..0dc31082be75c 100644 --- a/libr/bin/p/Makefile +++ b/libr/bin/p/Makefile @@ -1,7 +1,9 @@ include ../../config.mk #include ../../../config-user.mk -CFLAGS=-I../../include -I../format/ -Wall -fPIC -shared -Wl,-R.. +CFLAGS=-I../../include -I../format/ -Wall -fPIC +CFLAGS+=${LDFLAGS_LIB} +#CFLAGS=$CCLIB_SHARED CFLAGS+=-L../../util -lr_util # XXX CFLAGS+=-DLIL_ENDIAN=1 -D__UNIX__ -g -DR_DEBUG=0 diff --git a/libr/bp/p/Makefile b/libr/bp/p/Makefile index 28f0f690f380b..aa73585101ed8 100644 --- a/libr/bp/p/Makefile +++ b/libr/bp/p/Makefile @@ -1,5 +1,6 @@ -CFLAGS=-I../../include -I../arch/ -I../arch/include -Wall -fPIC -shared -Wl,-R.. -# XXX +include ../../config.mk + +CFLAGS=-I../../include -I../arch/ -I../arch/include -Wall -fPIC ${LDFLAGS_LIB} CFLAGS+=-DLIL_ENDIAN=1 -D__UNIX__ foo: all diff --git a/libr/cons/cons.c b/libr/cons/cons.c index c5df5eae67eeb..de12fbbbf26d5 100644 --- a/libr/cons/cons.c +++ b/libr/cons/cons.c @@ -22,7 +22,7 @@ // TODO: remove this flag static int r_cons_instance_initialized = R_FALSE; -RCons r_cons_instance; +static RCons r_cons_instance; #define I r_cons_instance static void break_signal(int sig) diff --git a/libr/cons/filter.c b/libr/cons/filter.c index 0b277bc01d96d..44a20196024f0 100644 --- a/libr/cons/filter.c +++ b/libr/cons/filter.c @@ -2,21 +2,20 @@ #include -#define I r_cons_instance - -R_API void r_cons_grep(const char *str) -{ +R_API void r_cons_grep(const char *str) { + RCons *cons; char *optr, *tptr; char *ptr, *ptr2, *ptr3; - I.grep.counter = 0; + cons = r_cons_singleton (); + cons->grep.counter = 0; /* set grep string */ if (str != NULL && *str) { if (*str == '!') { - I.grep.neg = 1; + cons->grep.neg = 1; str = str + 1; - } else I.grep.neg = 0; + } else cons->grep.neg = 0; if (*str == '?') { - I.grep.counter = 1; + cons->grep.counter = 1; str = str + 1; } ptr = alloca (strlen (str)+2); @@ -27,41 +26,41 @@ R_API void r_cons_grep(const char *str) if (ptr3) { ptr3[0]='\0'; - I.grep.token = atoi (ptr3+1); - if (I.grep.token<0) - I.grep.token--; + cons->grep.token = atoi (ptr3+1); + if (cons->grep.token<0) + cons->grep.token--; } if (ptr2) { ptr2[0]='\0'; - I.grep.line = atoi (ptr2+1); + cons->grep.line = atoi (ptr2+1); } - I.grep.nstrings = 0; + cons->grep.nstrings = 0; if (*ptr) { - free (I.grep.str); - I.grep.str = (char *)strdup (ptr); + free (cons->grep.str); + cons->grep.str = (char *)strdup (ptr); /* set the rest of words to grep */ - I.grep.nstrings = 0; + cons->grep.nstrings = 0; // TODO: refactor this ugly loop - optr = I.grep.str; + optr = cons->grep.str; tptr = strchr (optr, '!'); while (tptr) { tptr[0] = '\0'; // TODO: check if keyword > 64 - strncpy (I.grep.strings[I.grep.nstrings], optr, 63); - I.grep.nstrings++; + strncpy (cons->grep.strings[cons->grep.nstrings], optr, 63); + cons->grep.nstrings++; optr = tptr+1; tptr = strchr(optr, '!'); } - strncpy (I.grep.strings[I.grep.nstrings], optr, 63); - I.grep.nstrings++; + strncpy (cons->grep.strings[cons->grep.nstrings], optr, 63); + cons->grep.nstrings++; ptr = optr; } } else { - I.grep.token = -1; - I.grep.line = -1; - I.grep.str = NULL; - I.grep.nstrings = 0; + cons->grep.token = -1; + cons->grep.line = -1; + cons->grep.str = NULL; + cons->grep.nstrings = 0; } } @@ -69,72 +68,73 @@ R_API void r_cons_grep(const char *str) // TODO: this must be a filter like the html one R_API int r_cons_grepbuf(char *buf, int len) { + RCons *cons = r_cons_singleton (); const char delims[6][2] = {"|", "/", "\\", ",", ";", "\t"}; int donotline = 0; int i, j, hit = 0; char *n = memchr (buf, '\n', len); - if (I.grep.nstrings==0) { - if (n) I.lines++; + if (cons->grep.nstrings==0) { + if (n) cons->lines++; return len; } - if (I.lastline==NULL) - I.lastline = I.buffer; + if (cons->lastline==NULL) + cons->lastline = cons->buffer; if (!n) return len; - for(i=0;igrep.nstrings;i++) { + cons->grep.str = cons->grep.strings[i]; + if ( (!cons->grep.neg && strstr(buf, cons->grep.str)) + || (cons->grep.neg && !strstr(buf, cons->grep.str))) { hit = 1; break; } } if (hit) { - if (I.grep.line != -1) { - if (I.grep.line==I.lines) { - I.lastline = buf+len; + if (cons->grep.line != -1) { + if (cons->grep.line==cons->lines) { + cons->lastline = buf+len; //r_cons_lines++; } else { donotline = 1; - I.lines++; + cons->lines++; } } } else donotline = 1; if (donotline) { - I.buffer_len -= strlen (I.lastline)-len; - I.lastline[0]='\0'; + cons->buffer_len -= strlen (cons->lastline)-len; + cons->lastline[0]='\0'; len = 0; } else { - if (I.grep.token != -1) { - //ptr = alloca(strlen(I.lastline)); + if (cons->grep.token != -1) { + //ptr = alloca(strlen(cons->lastline)); char *tok = NULL; char *ptr = alloca(1024); // XXX - strcpy (ptr, I.lastline); + strcpy (ptr, cons->lastline); for (i=0; igrep.token;i++) { if (i==0) tok = (char *)strtok(ptr, " "); else tok = (char *)strtok(NULL, " "); } if (tok) { // XXX remove strlen here! - I.buffer_len -= strlen (I.lastline)-len; + cons->buffer_len -= strlen (cons->lastline)-len; len = strlen(tok); - memcpy (I.lastline, tok, len); - if (I.lastline[len-1]!='\n') - memcpy (I.lastline+len, "\n", 2); + memcpy (cons->lastline, tok, len); + if (cons->lastline[len-1]!='\n') + memcpy (cons->lastline+len, "\n", 2); len++; - I.lastline +=len; + cons->lastline +=len; } - } else I.lastline = buf+len; - I.lines++; + } else cons->lastline = buf+len; + cons->lines++; } return len; } diff --git a/libr/cons/input.c b/libr/cons/input.c index def9f2ddcc6f2..22f149ecd4a2e 100644 --- a/libr/cons/input.c +++ b/libr/cons/input.c @@ -8,8 +8,7 @@ extern char *dl_readline(int argc, const char **argv); #endif -R_API int r_cons_arrow_to_hjkl(int ch) -{ +R_API int r_cons_arrow_to_hjkl(int ch) { if (ch==0x1b) { ch = r_cons_readchar(); if (ch==0x5b) { @@ -31,10 +30,10 @@ R_API int r_cons_arrow_to_hjkl(int ch) } // XXX no control for max length here?!?! -R_API int r_cons_fgets(char *buf, int len, int argc, const char **argv) -{ - if (r_cons_instance.user_fgets) - return r_cons_instance.user_fgets (buf, 512); +R_API int r_cons_fgets(char *buf, int len, int argc, const char **argv) { + RCons *cons = r_cons_singleton (); + if (cons->user_fgets) + return cons->user_fgets (buf, 512); else { #if HAVE_DIETLINE char *ptr; @@ -45,9 +44,9 @@ R_API int r_cons_fgets(char *buf, int len, int argc, const char **argv) strncpy (buf, ptr, len); #else buf[0]='\0'; - if (fgets (buf, len, r_cons_instance.fdin) == NULL) + if (fgets (buf, len, cons->fdin) == NULL) return -1; - if (feof (r_cons_instance.fdin)) + if (feof (cons->fdin)) return -1; buf[strlen(buf)-1]='\0'; #endif diff --git a/libr/cons/pipe.c b/libr/cons/pipe.c index 6c18e9c92db6d..d5f1581a685a0 100644 --- a/libr/cons/pipe.c +++ b/libr/cons/pipe.c @@ -38,15 +38,16 @@ void r_cons_stdout_close(int fd) dup2(fd, 1); } -void r_cons_stdout_close_file() -{ - close(r_cons_instance.fdout); - dup2(r_cons_instance.fdout, 1); +void r_cons_stdout_close_file() { + RCons *cons = r_cons_instance (); + close(cons->fdout); + dup2(cons->fdout, 1); } void r_cons_stdout_open(const char *file, int append) { int fd; + RCons *cons = r_cons_instance (); if (r_cons_instance.fdout != 1) // XXX nested stdout dupping not supported return; diff --git a/libr/core/Makefile b/libr/core/Makefile index 0a443b8175c88..92bac73229f9b 100644 --- a/libr/core/Makefile +++ b/libr/core/Makefile @@ -1,5 +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_anal r_parse r_config r_macro r_print r_bininfo r_bp r_reg r_meta r_search +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_anal r_parse r_config r_macro r_print r_bp r_reg r_meta r_search OBJ=core.o cmd.o file.o config.o visual.o io.o yank.o libs.o diff --git a/libr/core/cmd.c b/libr/core/cmd.c index ccef78c166e46..06d8a36521eee 100644 --- a/libr/core/cmd.c +++ b/libr/core/cmd.c @@ -1410,18 +1410,21 @@ static int cmd_open(void *data, const char *input) static int cmd_meta(void *data, const char *input) { struct r_core_t *core = (struct r_core_t *)data; - int ret, line = 0; - char file[1024]; + //int ret, line = 0; + //char file[1024]; //struct r_core_t *core = (struct r_core_t *)data; switch(input[0]) { case '*': r_meta_list(&core->meta, R_META_ANY); break; case 'L': // debug information of current offset +#warning TODO: Implement new bininfo interface here +#if 0 ret = r_bininfo_get_line( &core->bininfo, core->offset, file, 1023, &line); if (ret) r_cons_printf("file %s\nline %d\n", file, line); +#endif break; case 'C': /* add comment */ // TODO: do we need to get the size? or the offset? diff --git a/libr/core/core.c b/libr/core/core.c index 06e94d5d7c7b8..b0da67a4967cd 100644 --- a/libr/core/core.c +++ b/libr/core/core.c @@ -128,7 +128,7 @@ R_API int r_core_init(struct r_core_t *core) r_parse_init (&core->parser); r_parse_set_user_ptr (&core->parser, core); r_bin_init (&core->bin); - r_bininfo_init (&core->bininfo); + //r_bininfo_init (&core->bininfo); r_bin_set_user_ptr (&core->bin, core); r_meta_init (&core->meta); r_cons_init (); diff --git a/libr/core/file.c b/libr/core/file.c index 0b5cc184e5b1c..da0b29c6157b9 100644 --- a/libr/core/file.c +++ b/libr/core/file.c @@ -33,8 +33,8 @@ R_API struct r_core_file_t *r_core_file_open(struct r_core_t *r, const char *fil list_add (&(fh->list), &r->files); r_bin_load (&r->bin, fh->filename, NULL); - // XXX: detect plugin automagically or set it in config.c - r_bininfo_open (&r->bininfo, fh->filename, 0, "addr2line"); + // DEPRECATED XXX: detect plugin automagically or set it in config.c + //r_bininfo_open (&r->bininfo, fh->filename, 0, "addr2line"); r_core_block_read (r, 0); diff --git a/libr/core/t/Makefile b/libr/core/t/Makefile index 8e1218ec43300..1f36efd53025e 100644 --- a/libr/core/t/Makefile +++ b/libr/core/t/Makefile @@ -3,7 +3,7 @@ include ../../config.mk OBJ=radare2.o BIN=radare2${EXT_EXE} BINDEPS=r_core r_cons r_macro r_util r_flags r_lib r_io r_hash r_cmd r_config r_asm r_anal -BINDEPS+=r_parse r_lang r_debug r_print r_line r_bin r_search r_meta r_bininfo r_reg r_bp r_util +BINDEPS+=r_parse r_lang r_debug r_print r_line r_bin r_search r_meta r_reg r_bp r_util CFLAGS+=-DVERSION=\"${VERSION}\" LIBS+=${DL_LIBS} diff --git a/libr/crypto/p/Makefile b/libr/crypto/p/Makefile index 461bb401fda83..0c5e9d03480bf 100644 --- a/libr/crypto/p/Makefile +++ b/libr/crypto/p/Makefile @@ -1,6 +1,6 @@ include ../../config.mk # XXX -CFLAGS=-I../../include -I../arch/ -I../arch/include -Wall -fPIC -shared -Wl,-R.. +CFLAGS=-I../../include -I../arch/ -I../arch/include -Wall -fPIC ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}.. foo: all diff --git a/libr/debug/p/Makefile b/libr/debug/p/Makefile index 047630e0b13ef..34d3252a86457 100644 --- a/libr/debug/p/Makefile +++ b/libr/debug/p/Makefile @@ -1,6 +1,6 @@ include ../../config.mk -CFLAGS=-I../../include -Wall -fPIC -shared -Wl,-R.. -DCORELIB +CFLAGS=-I../../include -Wall -fPIC ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}.. -DCORELIB foo: all diff --git a/libr/debug/p/debug_native.c b/libr/debug/p/debug_native.c index ab8f634b74d58..acbec6c6ab9f4 100644 --- a/libr/debug/p/debug_native.c +++ b/libr/debug/p/debug_native.c @@ -9,12 +9,22 @@ #if __WINDOWS__ #include #define R_DEBUG_REG_T CONTEXT + #elif __OpenBSD__ || __NetBSD__ || __FreeBSD__ #define R_DEBUG_REG_T struct reg + #elif __sun #define R_DEBUG_REG_T gregset_t +#undef DEBUGGER +#define DEBUGGER 0 +#warning No debugger support for OSX yet + +#elif __sun +#define R_DEBUG_REG_T gregset_t +#undef DEBUGGER #define DEBUGGER 0 #warning No debugger support for SunOS yet + #elif __linux__ #include #include @@ -27,7 +37,7 @@ #warning Unsupported debugging platform #endif -#if __WINDOWS__ || __sun +#if __WINDOWS__ || __sun || __APPLE__ struct r_debug_handle_t r_debug_plugin_native = { .name = "native", }; diff --git a/libr/debug/p/libgdbwrap/Makefile b/libr/debug/p/libgdbwrap/Makefile index 8bf9f5943106e..97b26e167fba0 100644 --- a/libr/debug/p/libgdbwrap/Makefile +++ b/libr/debug/p/libgdbwrap/Makefile @@ -1,10 +1,10 @@ include ../../../config.mk OBJ=interface.o gdbwrapper.o client.o -CFLAGS=-Iinclude +CFLAGS=-Iinclude -I../../../include ERESIPATH=${HOME}/prg/eresi BIN=client -all: ${BIN} ${LIB} +all: ${BIN} ${BIN}: ${OBJ} ${CC} ${OBJ} -o ${BIN} diff --git a/libr/debug/p/libgdbwrap/gdbwrapper.c b/libr/debug/p/libgdbwrap/gdbwrapper.c index ba61a4a768698..7be5c5f6219e5 100644 --- a/libr/debug/p/libgdbwrap/gdbwrapper.c +++ b/libr/debug/p/libgdbwrap/gdbwrapper.c @@ -20,7 +20,7 @@ #include "gdbwrapper-internals.h" #include "gdbwrapper.h" -gdbwrapworld_t gdbwrapworld; +static gdbwrapworld_t gdbwrapworld; /******************** Internal functions ********************/ diff --git a/libr/debug/p/libgdbwrap/include/revm.h b/libr/debug/p/libgdbwrap/include/revm.h index e71139083ada9..57c2c0f69509a 100644 --- a/libr/debug/p/libgdbwrap/include/revm.h +++ b/libr/debug/p/libgdbwrap/include/revm.h @@ -6,10 +6,12 @@ #include #include +#if 0 #define u_short unsigned short #define u_char unsigned char #define u_int unsigned int #define uint8_t unsigned char +#endif #define la32 unsigned int #define ptrdiff_t int @@ -23,12 +25,11 @@ #define FALSE 0 #define ASSERT(x) // #define assert(x) // -#define LOBYTE(_w) ((_w) & 0xff) -#define NEXT_CHAR(_x) _x + 1 +#define LOBYTE(_w) ((_w) & 0xff) +#define NEXT_CHAR(_x) (_x+1) #define PROFILER_IN(fd,fun,line) // #define PROFILER_OUT(fd,fun,line,str,ret) // #define PROFILER_ROUT(fd,fun,line,ret) return ret #define PROFILER_ERR(fd,fun,line,str,ret) { fprintf(stderr, str"\n"); return ret; } -#define u_char unsigned char #endif diff --git a/libr/include/r_cons.h b/libr/include/r_cons.h index 62c664c33746e..d6950b6434564 100644 --- a/libr/include/r_cons.h +++ b/libr/include/r_cons.h @@ -64,7 +64,7 @@ typedef struct r_cons_t { LPDWORD term_raw, term_buf; #endif } RCons; -extern RCons r_cons_instance; +//extern RCons r_cons_instance; // TODO: pass instance ? typedef void (*RConsBreakCallback)(void *user); diff --git a/libr/include/r_line.h b/libr/include/r_line.h index cc641b7d5c762..3e6e830f6eb0f 100644 --- a/libr/include/r_line.h +++ b/libr/include/r_line.h @@ -45,7 +45,7 @@ typedef struct r_line_t { #ifdef R_API // XXX : Kill extern variables -extern RLine r_line_instance; +//extern RLine r_line_instance; R_API RLine *r_line_new (); R_API RLine *r_line_singleton (); R_API RLine *r_line_init(); diff --git a/libr/include/r_util.h b/libr/include/r_util.h index 48df76ee3a9f0..83842249ed137 100644 --- a/libr/include/r_util.h +++ b/libr/include/r_util.h @@ -156,6 +156,7 @@ R_API char *r_str_home(const char *str); R_API char *r_str_concat(char *ptr, const char *string); R_API char *r_str_concatf(char *ptr, const char *fmt, ...); R_API void r_str_concatch(char *x, char y); +R_API void r_str_case(char *str, int up); /* hex */ R_API int r_hex_pair2bin(const char *arg); diff --git a/libr/include/r_vm.h b/libr/include/r_vm.h index e604a99050621..239bbc0cfd006 100644 --- a/libr/include/r_vm.h +++ b/libr/include/r_vm.h @@ -103,7 +103,7 @@ R_API int r_vm_reg_add(struct r_vm_t *vm, const char *name, int type, ut64 value R_API ut64 r_vm_reg_get(struct r_vm_t *vm, const char *name); R_API int r_vm_reg_alias_list(struct r_vm_t *vm); R_API const char *r_vm_reg_type(int type); -R_API const int r_vm_reg_type_i(const char *str); +R_API int r_vm_reg_type_i(const char *str); R_API int r_vm_reg_del(struct r_vm_t *vm, const char *name); R_API int r_vm_reg_set(struct r_vm_t *vm, const char *name, ut64 value); R_API int r_vm_reg_alias(struct r_vm_t *vm, const char *name, const char *get, const char *set); diff --git a/libr/io/p/Makefile b/libr/io/p/Makefile index 832442ab2308c..8e5966241dc67 100644 --- a/libr/io/p/Makefile +++ b/libr/io/p/Makefile @@ -1,4 +1,4 @@ -CFLAGS=-I../../include -Wall -DWORDSIZE=64 ${PIC_CFLAGS} -shared -Wl,-R.. -DCORELIB +CFLAGS=-I../../include -Wall -DWORDSIZE=64 ${PIC_CFLAGS} ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}.. -DCORELIB include ../../config.mk @@ -16,7 +16,7 @@ all: ${ALL_TARGETS} BINDEPS= io_ewf.${LIB_SO}: io_ewf.o - ${CC} ${CFLAGS} ${PIC_CFLAGS}˘-shared -o io_ewf.${LIB_SO} ewf.c -lr_io -L../../io -Wl,-R.. -lewf + ${CC} ${CFLAGS} ${PIC_CFLAGS} ${LDFLAGS_LIB} io_ewf.${LIB_SO} ewf.c -lr_io -L../../io ${LDFLAGS_LINKPTH}.. -lewf clean: -rm -f *.so *.o diff --git a/libr/io/t/Makefile b/libr/io/t/Makefile index 4782fd5ac86f8..1c8ab5410dd76 100644 --- a/libr/io/t/Makefile +++ b/libr/io/t/Makefile @@ -2,7 +2,7 @@ include ../../config.mk CFLAGS=-I ../../include -g ifeq ($(WITHPIC),1) -LDPATH=-L.. -Wl,-R.. -L../../util -L../../lib +LDPATH=-L.. ${LDFLAGS_LINKPATH}.. -L../../util -L../../lib LDPATH+=-lr_io -lr_util -lr_lib else LDPATH=../../io/libr_io.a @@ -13,7 +13,7 @@ endif all: map cat${EXT_EXE} read4${EXT_EXE} cat${EXT_EXE}: cat.o - ${CC} cat.o ${LDPATH} -Wl,-R.. -g -o cat${EXT_EXE} + ${CC} cat.o ${LDPATH} -g -o cat${EXT_EXE} map${EXT_EXE}: map.o ${CC} map.o ${LDPATH} -g -o map${EXT_EXE} diff --git a/libr/lang/p/Makefile b/libr/lang/p/Makefile index 249acf32bfd10..b05ecf5f9b5da 100644 --- a/libr/lang/p/Makefile +++ b/libr/lang/p/Makefile @@ -22,21 +22,21 @@ lang_python.${EXT_SO}: -gcc -lpython >/dev/null 2>&1 ; \ if [ $$? = 0 ]; then \ ${CC} ${CFLAGS} -I/usr/include/python2.5 \ - -fPIC -shared -o lang_python.${EXT_SO} python.c -lpython ; \ + -fPIC ${LDFLAGS_LIB} -o lang_python.${EXT_SO} python.c -lpython ; \ else \ ${CC} ${CFLAGS} -I/usr/include/python2.5 \ - -fPIC -shared -o lang_python.${EXT_SO} python.c \ + -fPIC ${LDFLAGS_LIB} -o lang_python.${EXT_SO} python.c \ -I/usr/include/python2.6/ -lpython2.6 ; \ fi ifeq ($(HAVE_LIB_TCC),1) lang_tcc.${EXT_SO}: tcc.o - -${CC} ${CFLAGS} -fPIC -shared -o lang_tcc.${EXT_SO} tcc.c -Wl,-R.. -ldl -ltcc + -${CC} ${CFLAGS} -fPIC ${LDFLAGS_LIB} -o lang_tcc.${EXT_SO} tcc.c ${LDFLAGS_LINKPATH}.. -ldl -ltcc endif ifeq ($(HAVE_LIB_LUA5_1),1) lang_lua.${EXT_SO}: lua.o - -${CC} ${CFLAGS} -fPIC -shared -o lang_lua.${EXT_SO} lua.c -Wl,-R.. -llua5.1 + -${CC} ${CFLAGS} -fPIC ${LDFLAGS_LIB} -o lang_lua.${EXT_SO} lua.c ${LDFLAGS_LINKPATH}.. -llua5.1 endif lang_ruby.${EXT_SO}: @@ -44,12 +44,12 @@ lang_ruby.${EXT_SO}: lang_perl.${EXT_SO}: -${CC} ${CFLAGS} -I/usr/lib/perl/5.10/CORE/ \ - -fPIC -shared -o lang_perl.${EXT_SO} perl.c -Wl,-R.. \ + -fPIC ${LDFLAGS_LIB} -o lang_perl.${EXT_SO} perl.c ${LDFLAGS_LINKPATH}.. \ `perl -MExtUtils::Embed -e ccopts` \ `perl -MExtUtils::Embed -e ldopts` -lncurses lang_dummy.${EXT_SO}: dummy.o - ${CC} ${CFLAGS} -fPIC -shared -o lang_dummy.${EXT_SO} dummy.c -Wl,-R.. -L.. + ${CC} ${CFLAGS} -fPIC ${LDFLAGS_LIB} -o lang_dummy.${EXT_SO} dummy.c ${LDFLAGS_LINKPATH}.. -L.. @#strip -s lua.so clean: diff --git a/libr/lib/lib.c b/libr/lib/lib.c index fbe9439dcb095..53fe9a7b018ea 100644 --- a/libr/lib/lib.c +++ b/libr/lib/lib.c @@ -26,7 +26,7 @@ /* XXX : this must be registered in runtime */ static const char *r_lib_types[] = { - "io", "dbg", "lang", "asm", "anal", "parse", "bin", "bininfo", + "io", "dbg", "lang", "asm", "anal", "parse", "bin", //"bininfo", "bp", "syscall", "fastcall", NULL }; diff --git a/libr/lib/t/Makefile b/libr/lib/t/Makefile index a27e1b2f14bd5..f9722c55eab5f 100644 --- a/libr/lib/t/Makefile +++ b/libr/lib/t/Makefile @@ -4,7 +4,7 @@ all: plugin.${EXT_SO} test-plugin${EXT_EXE} @true plugin.${EXT_SO}: - ${CC} -Wall -o plugin.${EXT_SO} -shared plugin.c -I../../include + ${CC} -Wall -o plugin.${EXT_SO} ${LDFLAGS_LIB} plugin.c -I../../include test-plugin${EXT_EXE}: ${CC} -Wall -o test-plugin${EXT_EXE} test-plugin.c -I ../../include ../../lib/*.o ${DL_LIBS} diff --git a/libr/line/Makefile b/libr/line/Makefile index 3ff55020e6b02..e89a616a8aa5b 100644 --- a/libr/line/Makefile +++ b/libr/line/Makefile @@ -1,6 +1,6 @@ NAME=r_line DEPS=r_util r_cons -OBJ=dietline.o line.o +OBJ=line.o #LINK=-L../cons -lr_cons -Wl,-R../cons ../util/*.a include ../rules.mk diff --git a/libr/line/dietline.c b/libr/line/dietline.c index ef84398fe2122..1bf9fcc7e95a9 100644 --- a/libr/line/dietline.c +++ b/libr/line/dietline.c @@ -14,8 +14,6 @@ #include #endif -#define I r_line_instance - static char *r_line_nullstr = ""; /* initialize history stuff */ diff --git a/libr/line/line.c b/libr/line/line.c index 0f7827fe44709..da3282802409b 100644 --- a/libr/line/line.c +++ b/libr/line/line.c @@ -2,7 +2,7 @@ #include -RLine r_line_instance; +static RLine r_line_instance; #define I r_line_instance /* definitions to be removed */ @@ -30,3 +30,5 @@ R_API void r_line_free () { I.prompt = NULL; r_line_hist_free (); } + +#include "dietline.c" diff --git a/libr/parse/Makefile b/libr/parse/Makefile index cff3e437ece1c..1118aaa502d6b 100644 --- a/libr/parse/Makefile +++ b/libr/parse/Makefile @@ -13,7 +13,7 @@ bins: cd t && ${MAKE} all pre: - @if [ ! -e libr_parse.so ]; then rm -f ${STATIC_OBJS} ; fi + @if [ ! -e libr_parse.${EXT_SO} ]; then rm -f ${STATIC_OBJS} ; fi plugins: cd p && ${MAKE} all diff --git a/libr/parse/p/Makefile b/libr/parse/p/Makefile index 23c456c66f9cc..b917e0c139871 100644 --- a/libr/parse/p/Makefile +++ b/libr/parse/p/Makefile @@ -1,6 +1,6 @@ include ../../config.mk -CFLAGS=-I../../include -Wall -fPIC -shared -Wl,-R.. +CFLAGS=-I../../include -Wall -fPIC ${LDFLAGS_LIB} ${LDFLAGS_LINKPATH}.. # XXX CFLAGS+=-DLIL_ENDIAN=1 # -D__UNIX__ diff --git a/libr/parse/p/parse_mreplace/mmemory.c b/libr/parse/p/parse_mreplace/mmemory.c index c39e686fd41e6..d333b77498547 100644 --- a/libr/parse/p/parse_mreplace/mmemory.c +++ b/libr/parse/p/parse_mreplace/mmemory.c @@ -6,11 +6,10 @@ #include #include #include -#include #include "mmemory.h" -memInfo *mInfo; +static memInfo *mInfo; void memStringRealloc(memChunk *chunk){ memCheckState(); diff --git a/libr/parse/p/parse_mreplace/mreplace.c b/libr/parse/p/parse_mreplace/mreplace.c index 26e026a3bfefd..01ad290ed0a90 100644 --- a/libr/parse/p/parse_mreplace/mreplace.c +++ b/libr/parse/p/parse_mreplace/mreplace.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include "mmemory.h" @@ -71,7 +70,7 @@ char *mreplace(char *string, char *se,char *rep) size_t nmatch = 16; regmatch_t pm[nmatch]; char *p; - ulong offset = 0; + unsigned long offset = 0; char field[16]; char *res; memChunk *search,*temp,*found,*ffound; diff --git a/libr/rules.mk b/libr/rules.mk index 1d0d5b9cd2bae..2cc3cd78da9c7 100644 --- a/libr/rules.mk +++ b/libr/rules.mk @@ -5,6 +5,8 @@ -include global.mk -include ../global.mk -include ../../global.mk +-include ../../mk/${COMPILER}.mk +-include ../../../mk/${COMPILER}.mk #-------------------------------------# # Rules for libraries diff --git a/libr/socket/proc.c b/libr/socket/proc.c index cdef4afd60ebb..ba99d4f282366 100644 --- a/libr/socket/proc.c +++ b/libr/socket/proc.c @@ -12,7 +12,11 @@ R_API struct r_socket_proc_t *r_socket_proc_open(char *const argv[]) { #if __UNIX__ struct r_socket_proc_t *sp = MALLOC_STRUCT(struct r_socket_proc_t); +#if __APPLE__ + const int flags = 0; //O_NONBLOCK|O_CLOEXEC; +#else const int flags = O_CLOEXEC; //O_NONBLOCK|O_CLOEXEC; +#endif if (pipe (sp->fd0)==-1) { perror("pipe"); diff --git a/libr/syscall/syscall.c b/libr/syscall/syscall.c index 0833b212d949d..0b8f038e9cebf 100644 --- a/libr/syscall/syscall.c +++ b/libr/syscall/syscall.c @@ -82,7 +82,7 @@ R_API RSyscallList *r_syscall_get_n(struct r_syscall_t *ctx, int n) return NULL; } -R_API char *r_syscall_get_i(struct r_syscall_t *ctx, int num, int swi) +R_API const char *r_syscall_get_i(struct r_syscall_t *ctx, int num, int swi) { int i; for (i=0;ctx->sysptr[i].num;i++) diff --git a/libr/util/str.c b/libr/util/str.c index 8863e7cc80b8e..25cd03bfa1ef5 100644 --- a/libr/util/str.c +++ b/libr/util/str.c @@ -3,6 +3,7 @@ #include "r_types.h" #include "r_util.h" #include +#include #include /* stable code */ @@ -19,12 +20,21 @@ static int hex2int (unsigned char *val, unsigned char c) return 0; } -R_API const char *r_str_bool(int b) -{ +R_API const char *r_str_bool(int b) { if (b) return "true"; return "false"; } +R_API void r_str_case(char *str, int up) { + if (up) { + while(*str) + *str = tolower (*str); + } else { + while(*str) + *str = toupper (*str); + } +} + /* TODO: port to w32 and move outside r_str namespace? */ R_API char *r_str_home(const char *str) { diff --git a/libr/util/t/Makefile b/libr/util/t/Makefile index 2ab26a6be90d4..274046b924985 100644 --- a/libr/util/t/Makefile +++ b/libr/util/t/Makefile @@ -1,7 +1,9 @@ BINDEPS=foo include ../../config.mk ifeq ($(WITHPIC),1) -FLAGS=-I../../include -Wl,-R.. -L.. -lr_util -g -DVERSION=\"${VERSION}\" +# OSX +FLAGS=-I../../include -L.. -lr_util -g -DVERSION=\"${VERSION}\" +#FLAGS=-I../../include -Wl,-R.. -L.. -lr_util -g -DVERSION=\"${VERSION}\" EFLAGS= else FLAGS=-I../../include -g -DVERSION=\"${VERSION}\" diff --git a/libr/vm/reg.c b/libr/vm/reg.c index 1ca0d36be5e7b..8466764ae5002 100644 --- a/libr/vm/reg.c +++ b/libr/vm/reg.c @@ -16,10 +16,9 @@ static struct r_vm_reg_type r_vm_reg_types[] = { { 0, NULL } }; -void r_vm_reg_type_list() -{ +R_API void r_vm_reg_type_list() { struct r_vm_reg_type *p = r_vm_reg_types; - while(p) { + while (p) { if (p->str==NULL) break; printf(" .%s\n", p->str); @@ -27,10 +26,9 @@ void r_vm_reg_type_list() } } -const char *r_vm_reg_type(int type) -{ +R_API const char *r_vm_reg_type(int type) { struct r_vm_reg_type *p = r_vm_reg_types; - while(p) { + while (p) { if (p->type == type) return p->str; p++; @@ -38,8 +36,7 @@ const char *r_vm_reg_type(int type) return unkreg; } -const int r_vm_reg_type_i(const char *str) -{ +R_API int r_vm_reg_type_i(const char *str) { struct r_vm_reg_type *p = r_vm_reg_types; while(p) { if (!strcmp(str, p->str)) diff --git a/mk/gcc.mk b/mk/gcc.mk index 3540e0f7ae3a0..eff61a72e23ac 100644 --- a/mk/gcc.mk +++ b/mk/gcc.mk @@ -3,12 +3,20 @@ LINK= CC_AR=ar -r ${LIBAR} PIC_CFLAGS=-fPIC CFLAGS+=-MD -CC_LIB=${CC} -shared -o ${LIBSO} CFLAGS_INCLUDE=-I LDFLAGS_LINK=-l -LDFLAGS_LINKPATH=-Wl,-R CFLAGS_OPT0=-O0 CFLAGS_OPT1=-O1 CFLAGS_OPT2=-O2 CFLAGS_OPT3=-O3 CFLAGS_DEBUG=-g + +ifeq ($(OSTYPE),osx) +LDFLAGS_LIB=-dynamiclib +LDFLAGS_LINKPATH=-L +else +LDFLAGS_LIB=-shared +LDFLAGS_LINKPATH=-Wl,-R +endif + +CC_LIB=${CC} ${LDFLAGS_LIB} -o ${LIBSO} diff --git a/plugins.def.cfg b/plugins.def.cfg index e34a89e95c7f1..14073a5f9519c 100644 --- a/plugins.def.cfg +++ b/plugins.def.cfg @@ -1,6 +1,7 @@ STATIC="asm.java asm.arm asm.mips +asm.ppc asm.x86 asm.x86_nasm asm.x86_olly @@ -27,7 +28,6 @@ asm.bf asm.csr asm.dummy asm.m68k -asm.ppc asm.psosvm asm.sparc debug.gdb