* QNX/arm port (this is bb10 and playbook devices)

- no debugger support yet
This commit is contained in:
pancake 2012-06-01 14:50:24 +02:00
parent fee1dfda07
commit bc572ce3df
29 changed files with 208 additions and 24 deletions

View file

@ -5,3 +5,6 @@ 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
include ../binr.mk
ifeq ($(OSTYPE),qnx)
LDFLAGS+=-lsocket
endif

View file

@ -8,7 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <getopt.c>
#include <r_core.h>

View file

@ -20,3 +20,6 @@ osxsign:
ifeq ($(OSTYPE),android)
LDFLAGS+=${DL_LIBS} -lm
endif
ifeq ($(OSTYPE),qnx)
LDFLAGS+=-lsocket
endif

View file

@ -5,7 +5,7 @@
#include <r_core.h>
#include <r_io.h>
#include <stdio.h>
#include <getopt.h>
#include <getopt.c>
#if USE_THREADS
#include <r_th.h>

View file

@ -9,3 +9,7 @@ include ../binr.mk
ifeq ($(OSTYPE),android)
LDFLAGS+=${DL_LIBS} -lm
endif
ifeq ($(OSTYPE),qnx)
LDFLAGS+=-lsocket
endif

View file

@ -3,3 +3,7 @@ BINDEPS=r_search r_io r_print r_lib r_asm r_anal r_reg r_cons r_util r_syscall r
BINDEPS+=r_socket r_db r_parse
include ../binr.mk
ifeq ($(OSTYPE),qnx)
LDFLAGS+=-lsocket
endif

View file

@ -1,8 +1,8 @@
/* radare - LGPL - Copyright 2009-2011 pancake<nopcode.org> */
/* radare - LGPL - Copyright 2009-2012 pancake<nopcode.org> */
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <getopt.c>
#include <r_types.h>
#include <r_print.h>

View file

@ -1,7 +1,7 @@
/* radare - LGPL - Copyright 2011 pancake<@nopcode.org> */
/* radare - LGPL - Copyright 2011-2012 pancake<@nopcode.org> */
#include <r_egg.h>
#include <r_bin.h>
#include <getopt.h>
#include <getopt.c>
static int usage () {
printf ("ragg2 [options] [file|-]\n"

View file

@ -6,3 +6,6 @@ include ../binr.mk
ifeq ($(OSTYPE),android)
LDFLAGS+=-lm
endif
ifeq ($(OSTYPE),qnx)
LDFLAGS+=-lsocket
endif

View file

@ -1,8 +1,8 @@
/* radare - LGPL - Copyright 2009-2011 pancake<nopcode.org> */
/* radare - LGPL - Copyright 2009-2012 pancake<nopcode.org> */
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <getopt.c>
/* r2 api */
#include <r_io.h>
#include <r_hash.h>

View file

@ -2,7 +2,7 @@
#include <r_anal.h>
#include <r_lib.h>
#include <r_util.h>
#include <getopt.h>
#include <getopt.c>
/* anal callback */
static int __lib_anal_cb(struct r_lib_plugin_t *pl, void *user, void *data) {

View file

@ -1,9 +1,8 @@
/* radare - LGPL - Copyright 2009-2011 nibble<.ds@gmail.com> */
/* radare - LGPL - Copyright 2009-2012 nibble<.ds@gmail.com> */
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <getopt.c> /* getopt.h is not portable :D */
#include <r_types.h>
#include <r_asm.h>
#include <r_util.h>

View file

@ -35,6 +35,9 @@ HOST_OS=@HOST_OS@
ifneq ($(OSTYPE),darwin)
DL_LIBS=@DL_LIBS@
endif
ifneq ($(OSTYPE),qnx)
DL_LIBS=
endif
WITHPIC=@WITHPIC@
WITHNONPIC=@WITHNONPIC@

View file

@ -7,7 +7,7 @@ Install NDK in archlinux x86-64
To build r2 for android you need to install the NDK:
sys/android-shell.sh
./configure --with-compiler=android --with-ostype=android --without-ssl --prefix=/data/radare2 --without-pic --with-nonpic
./configure --with-compiler=android --with-ostype=android --without-ssl --prefix=/data/radare2 --without-pic --with-nonpic --without-gmp
make -j 4
To compile for android-x86

9
doc/qnx Normal file
View file

@ -0,0 +1,9 @@
r2 on android
=============
. ./bbndk-env.sh
cd ~/radare2
rm -f plugins.cfg
./configure --with-compiler=qnx --with-ostype=qnx --without-ssl --prefix=/accounts/devuser/radare2 --without-pic --with-nonpic --without-gmp
make -j 4

View file

@ -8,6 +8,7 @@
// x86 32/64bit GPI|FPU|MMX|3DN|SSE|SSE2|SSE3
# include <r_types.h>
#if __WINDOWS__
# include <windows.h>
#elif __UNIX__

View file

@ -10,13 +10,13 @@
#define __X86IM_H__
#if __UNIX__
# define __stdcall
# define WORD unsigned short
# define DWORD unsigned int
# define BOOL int
# define TRUE 1
# define FALSE 0
#endif
# define __stdcall
# define __inout
# define __in
# define __out

View file

@ -25,7 +25,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>
//#include <getopt.h>
#include <stdarg.h>
#include "javasm.h"
#if __UNIX__

View file

@ -29,7 +29,7 @@
#include <errno.h>
#include <ctype.h>
#include <stdarg.h>
#include <getopt.h>
//#include <getopt.h>
#include <unistd.h>
/* defines which are not function-specific */

View file

@ -7,7 +7,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>
//#include <getopt.h>
#include <stdarg.h>
#include <unistd.h>
#include "java.h"

View file

@ -1490,11 +1490,11 @@ struct nlist {
#ifndef __LP64__
char *n_name; /* for use when in-core */
#endif
int32_t n_strx; /* index into the string table */
st32 n_strx; /* index into the string table */
} n_un;
ut8 n_type; /* type flag, see below */
ut8 n_sect; /* section number or NO_SECT */
int16_t n_desc; /* see <mach-o/stab.h> */
st16 n_desc; /* see <mach-o/stab.h> */
ut32 n_value; /* value of this symbol (or stab offset) */
};

View file

@ -87,6 +87,13 @@ EXT_SO=dll
EXT_EXE=.exe
TH_LIBS=
endif
ifeq (${OSTYPE},qnx)
CFLAGS+=-D__UNIX__=1
EXT_AR=a
EXT_SO=so
EXT_EXE=
TH_LIBS=
endif
ifeq (${OSTYPE},gnulinux)
CFLAGS+=-D__UNIX__=1
EXT_AR=a

125
libr/include/getopt.c Normal file
View file

@ -0,0 +1,125 @@
#if defined (__QNX__)
#include <unistd.h>
#if 0
/*
* Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
/* static char sccsid[] = "from: @(#)getopt.c 8.2 (Berkeley) 4/2/94"; */
static char *rcsid = "$Id: getopt.c,v 1.2 1998/01/21 22:27:05 billm Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */
optopt, /* character checked for validity */
optreset; /* reset getopt */
char *optarg; /* argument associated with option */
#define BADCH (int)'?'
#define BADARG (int)':'
#define EMSG ""
/*
* getopt --
* Parse argc/argv argument vector.
*/
int
getopt(nargc, nargv, ostr)
int nargc;
char * const *nargv;
const char *ostr;
{
static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
if (optind >= nargc || *(place = nargv[optind]) != '-') {
place = EMSG;
return (-1);
}
if (place[1] && *++place == '-') { /* found "--" */
++optind;
place = EMSG;
return (-1);
}
} /* option letter okay? */
if ((optopt = (int)*place++) == (int)':' ||
!(oli = strchr(ostr, optopt))) {
/*
* if the user didn't specify '-' as an option,
* assume it means -1.
*/
if (optopt == (int)'-')
return (-1);
if (!*place)
++optind;
if (opterr && *ostr != ':')
(void)fprintf(stderr,
"%s: illegal option -- %c\n", nargv[0], optopt);
return (BADCH);
}
if (*++oli != ':') { /* don't need argument */
optarg = NULL;
if (!*place)
++optind;
}
else { /* need an argument */
if (*place) /* no white space */
optarg = place;
else if (nargc <= ++optind) { /* no arg */
place = EMSG;
if (*ostr == ':')
return (BADARG);
if (opterr)
(void)fprintf(stderr,
"%s: option requires an argument -- %c\n",
nargv[0], optopt);
return (BADCH);
}
else /* white space */
optarg = nargv[optind];
place = EMSG;
++optind;
}
return (optopt); /* dump back option letter */
}
#endif
#else
#include <getopt.h>
#endif

View file

@ -14,7 +14,7 @@
#define __KFBSD__ 0
#endif
#if defined(__linux__) || defined(__APPLE__) || defined(__GNU__) || defined(__ANDROID__)
#if defined(__linux__) || defined(__APPLE__) || defined(__GNU__) || defined(__ANDROID__) || defined(__QNX__)
#define __BSD__ 0
#define __UNIX__ 1
#endif
@ -209,7 +209,9 @@ enum {
};
/* os */
#if defined (__APPLE__)
#if defined (__QNX__)
#define R_SYS_OS "qnx"
#elif defined (__APPLE__)
#define R_SYS_OS "darwin"
#elif defined (__linux__)
#define R_SYS_OS "linux"

View file

@ -6,6 +6,7 @@
#define ut32 unsigned int
#define st32 int
#define ut16 unsigned short
#define st16 short
#define ut8 unsigned char
#define st8 char
typedef int boolt;

View file

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2008-2011 pancake<nopcode.org> */
/* radare - LGPL - Copyright 2008-2012 pancake<nopcode.org> */
#include "r_io.h"
#include "r_lib.h"
@ -9,7 +9,7 @@
#define __UNIX__ 0
#endif
#if __UNIX__
#if __UNIX__ && !defined (__QNX__)
#include <sys/ipc.h>
#include <sys/shm.h>

View file

@ -16,6 +16,9 @@ endif
ifeq (${OSTYPE},solaris)
LDFLAGS+=-lsocket
endif
ifeq (${OSTYPE},qnx)
LDFLAGS+=-lsocket
endif
# windows
ifeq (${OSTYPE},windows)
LDFLAGS=-lwsock32

View file

@ -878,7 +878,7 @@ R_API const char *r_str_lastbut (const char *s, char ch, const char *but) {
// TODO: if unix.. move to .h? static inline
R_API const char *r_str_casestr(const char *a, const char *b) {
#if __WINDOWS__
#if __WINDOWS__ || defined(__QNX__)
size_t hay_len = strlen(a);
size_t needle_len = strlen(b);
while (hay_len >= needle_len) {

17
mk/qnx.mk Normal file
View file

@ -0,0 +1,17 @@
CC=arm-unknown-nto-qnx6.5.0eabi-gcc
RANLIB=arm-unknown-nto-qnx6.5.0eabi-ranlib
ONELIB=0
OSTYPE=qnx
LINK=
CC_AR=arm-unknown-nto-qnx6.5.0eabi-ar -r ${LIBAR}
PICFLAGS=
CFLAGS+=${PICFLAGS}
CC_LIB=${CC} -shared -o
CFLAGS_INCLUDE=-I
LDFLAGS_LINK=-l
LDFLAGS_LINKPATH=-L
CFLAGS_OPT0=-O0
CFLAGS_OPT1=-O1
CFLAGS_OPT2=-O2
CFLAGS_OPT3=-O3
CFLAGS_DEBUG=-g