Skip to content

Commit

Permalink
* Fix build in OSX
Browse files Browse the repository at this point in the history
  - 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
  • Loading branch information
radare committed Feb 21, 2010
1 parent 8d41729 commit 9890c6e
Show file tree
Hide file tree
Showing 59 changed files with 235 additions and 164 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion config-user.mk.acr
Original file line number Diff line number Diff line change
Expand Up @@ -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@
Expand Down
5 changes: 3 additions & 2 deletions configure-plugins
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ generate_configh () {
fi
echo " &r_${lib}_plugin_${plg}, \\"
done
echo " 0"
[ -n "$oldlib" ] && echo " 0"
}

generate_configmk () {
Expand Down Expand Up @@ -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 () {
Expand Down
1 change: 1 addition & 0 deletions env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
'

Expand Down
23 changes: 11 additions & 12 deletions libr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}:

Expand Down Expand Up @@ -66,39 +65,39 @@ 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

install: install-includes install-vapi install-pkgconfig install-bins install-test-bins
# 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 \
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`; \
@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"

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
Expand All @@ -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
Expand Down
28 changes: 14 additions & 14 deletions libr/anal/arch/x86/dislen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libr/anal/p/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions libr/asm/arch/arm/gnu/arm-dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions libr/asm/arch/csr/csr_disasm/dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <stdint.h>
#include "dis.h"

static struct state _state;

#include <r_types.h>

static inline struct state *get_state(void)
Expand Down
2 changes: 1 addition & 1 deletion libr/asm/arch/csr/csr_disasm/dis.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion libr/asm/arch/java/javasm/javasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <arpa/inet.h>
#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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions libr/asm/arch/java/javasm/javasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions libr/asm/arch/m68k/m68k_disasm/m68k_disasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions libr/asm/arch/x86/ollyasm/assembl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 //////////////////////////////

Expand Down
21 changes: 21 additions & 0 deletions libr/asm/arch/x86/ollyasm/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,28 @@
#include <float.h>
//#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 *
Expand Down
2 changes: 2 additions & 0 deletions libr/asm/arch/x86/ollyasm/disasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libr/asm/p/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion libr/asm/p/asm_x86_olly.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion libr/bin/p/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions libr/bp/p/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion libr/cons/cons.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 9890c6e

Please sign in to comment.