Skip to content

Commit 8f25a9b

Browse files
committedJun 20, 2015
Fix iOS build, crashes in reflines, analysis issues on OSX debugger and more!
1 parent fa75461 commit 8f25a9b

File tree

11 files changed

+51
-19
lines changed

11 files changed

+51
-19
lines changed
 

‎libr/anal/reflines.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ R_API struct r_anal_refline_t *r_anal_reflines_get(RAnal *anal,
7272
goto __next;
7373
list2 = R_NEW (RAnalRefline);
7474
if (!list2) {
75-
eprintf ("not enough memory in %s - %s", __FILE__, __LINE__);
75+
eprintf ("not enough memory in %s - %d", __FILE__, __LINE__);
7676
free_refline_list (&(list->list));
7777
return NULL;
7878
}
@@ -97,7 +97,7 @@ R_API struct r_anal_refline_t *r_anal_reflines_get(RAnal *anal,
9797
continue;
9898
list2 = R_NEW (RAnalRefline);
9999
if (!list2) {
100-
eprintf ("not enough memory in %s - %s", __FILE__, __LINE__);
100+
eprintf ("not enough memory in %s - %d", __FILE__, __LINE__);
101101
free_refline_list (&(list->list));
102102
return NULL;
103103
}
@@ -170,7 +170,7 @@ R_API struct r_anal_refline_t *r_anal_reflines_fcn_get( struct r_anal_t *anal, R
170170

171171
list2 = R_NEW0 (RAnalRefline);
172172
if (!list2) {
173-
eprintf ("not enough memory in %s - %s", __FILE__, __LINE__);
173+
eprintf ("not enough memory in %s - %d", __FILE__, __LINE__);
174174
free_refline_list (&(list->list));
175175
return NULL;
176176
}
@@ -192,7 +192,7 @@ R_API struct r_anal_refline_t *r_anal_reflines_fcn_get( struct r_anal_t *anal, R
192192
continue;
193193
list2 = R_NEW (RAnalRefline);
194194
if (!list2){
195-
eprintf ("not enough memory in %s - %s", __FILE__, __LINE__);
195+
eprintf ("not enough memory in %s - %d", __FILE__, __LINE__);
196196
free_refline_list (&(list->list));
197197
return NULL;
198198
}

‎libr/bin/mangling/microsoft_demangle.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ int get_namespace_and_name( char *buf, STypeCodeStr *type_code_str,
410410
r_list_append(names_l, str_info);
411411

412412
read_len += len;
413-
if ((len == 1)) {
413+
if (len == 1) {
414414
if (*(prev_pos + 1) == '@') {
415415
prev_pos = curr_pos;
416416
} else {

‎libr/cons/utf8.c

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define UTF8_DETECT_LOCALE 0
1818
#define UTF8_DETECT_CURSOR 0
1919

20+
#if UTF8_DETECT_CURSOR
2021
static inline int rd(const int fd) {
2122
unsigned char buffer[4];
2223
ssize_t n;
@@ -61,6 +62,7 @@ static inline int wr(const int fd, const char *const data, const size_t bytes) {
6162

6263
return 0;
6364
}
65+
#endif
6466

6567
/* Return a new file descriptor to the current TTY.
6668
*/

‎libr/core/core.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ R_API int r_core_serve(RCore *core, RIODesc *file) {
14431443
strcpy ((char*)buf, "/tmp/.out");
14441444
pipefd = r_cons_pipe_open ((const char *)buf, 1, 0);
14451445
//eprintf("SYSTEM(%s)\n", ptr+6);
1446-
system ((const char*)ptr+6);
1446+
r_sandbox_system ((const char*)ptr+6, 1);
14471447
r_cons_pipe_close (pipefd);
14481448
{
14491449
FILE *fd = r_sandbox_fopen((char*)buf, "r");

‎libr/debug/p/debug_native.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,11 @@ static int r_debug_native_continue(RDebug *dbg, int pid, int tid, int sig) {
489489
return tid;
490490
#elif __APPLE__
491491
#if __arm__
492-
int i, ret, status;
493-
thread_array_t inferior_threads = NULL;
494-
unsigned int inferior_thread_count = 0;
492+
return 1;
493+
#if 0
494+
//int i, ret, status;
495+
//thread_array_t inferior_threads = NULL;
496+
//unsigned int inferior_thread_count = 0;
495497

496498
// XXX: detach is noncontrollable continue
497499
ptrace (PT_DETACH, pid, 0, 0);
@@ -513,7 +515,7 @@ static int r_debug_native_continue(RDebug *dbg, int pid, int tid, int sig) {
513515
for (i = 0; i < inferior_thread_count; i++)
514516
thread_resume (inferior_threads[i]);
515517
*/
516-
return 1;
518+
#endif
517519
#else
518520
//ut64 rip = r_debug_reg_get (dbg, "pc");
519521
void *data = (void*)(size_t)((sig != -1)?sig: dbg->signum);
@@ -1472,7 +1474,7 @@ static int r_debug_native_reg_write(RDebug *dbg, int type, const ut8* buf, int s
14721474
thread_array_t inferior_threads = NULL;
14731475
unsigned int inferior_thread_count = 0;
14741476
R_DEBUG_REG_T *regs = (R_DEBUG_REG_T*)buf;
1475-
unsigned int gp_count = R_DEBUG_STATE_SZ;
1477+
mach_msg_type_number_t gp_count = R_DEBUG_STATE_SZ;
14761478

14771479
ret = task_threads (pid_to_task (pid),
14781480
&inferior_threads, &inferior_thread_count);
@@ -1510,7 +1512,8 @@ static int r_debug_native_reg_write(RDebug *dbg, int type, const ut8* buf, int s
15101512
}
15111513
#else
15121514
ret = thread_set_state (inferior_threads[tid],
1513-
R_DEBUG_STATE_T, (thread_state_t) regs, &gp_count);
1515+
R_DEBUG_STATE_T, (thread_state_t) regs,
1516+
gp_count);
15141517
#endif
15151518
//if (thread_set_state (inferior_threads[0], R_DEBUG_STATE_T, (thread_state_t) regs, gp_count) != KERN_SUCCESS)
15161519
if (ret != KERN_SUCCESS) {

‎libr/io/p/io_debug.c

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ static void my_io_redirect (RIO *io, const char *ref, const char *file) {
3434

3535
#if __APPLE__
3636
#include <spawn.h>
37-
#include <sys/ptrace.h>
3837
#include <sys/types.h>
3938
#include <sys/wait.h>
4039
#include <mach/exception_types.h>

‎libr/io/p/io_mach.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
#define EXCEPTION_PORT 0
1212

13-
#include <sys/ptrace.h>
14-
#include <sys/types.h>
15-
#include <sys/wait.h>
1613
#include <mach/exception_types.h>
1714
#include <mach/mach_vm.h>
1815
#include <mach/mach_init.h>
@@ -28,6 +25,8 @@
2825
#include <mach-o/nlist.h>
2926
#include <sys/ptrace.h>
3027
#include <sys/types.h>
28+
#include <sys/types.h>
29+
#include <sys/wait.h>
3130
#include <sys/wait.h>
3231
#include <errno.h>
3332

‎libr/util/sandbox.c

+22
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,29 @@ R_API int r_sandbox_enable (int e) {
6868

6969
R_API int r_sandbox_system (const char *x, int n) {
7070
if (!enabled) {
71+
#if __IPHONE_8_0
72+
#include <spawn.h>
73+
if (n) {
74+
int pid, argc;
75+
char **argv = r_str_argv (x, &argc);
76+
if (argv) {
77+
char *argv0 = r_file_path (argv[0]);
78+
if (!argv0) {
79+
eprintf ("Cannot find '%s'\n", argv[0]);
80+
return -1;
81+
}
82+
posix_spawn(&pid, argv0, NULL, NULL, argv, NULL);
83+
waitpid(pid, NULL, 0);
84+
r_str_argv_free (argv);
85+
free (argv0);
86+
} else {
87+
eprintf ("Error parsing command arguments\n");
88+
return -1;
89+
}
90+
}
91+
#else
7192
if (n) return system (x);
93+
#endif
7294
return execl ("/bin/sh", "sh", "-c", x, (const char*)NULL);
7395
}
7496
eprintf ("sandbox: system call disabled\n");

‎shlr/Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,5 @@ CAPSTONE_CFLAGS=-g
187187
capstone-build: capstone
188188
cd capstone && CFLAGS="-Dmips=mips ${CAPSTONE_CFLAGS} $(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
189189
$(MAKE) CC="$(CC)" AR_EXT=a IS_CYGWIN=0 CAPSTONE_STATIC=yes CAPSTONE_SHARED=no \
190-
RANLIB="$(RANLIB)" AR="$(AR)" IS_MINGW=0 \
191-
./libcapstone.a
190+
RANLIB="$(RANLIB)" AR="$(AR)" IS_MINGW=0 ./libcapstone.a
192191
endif

‎shlr/gdb/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ MINOR=1
1414
LD=$(CC)
1515
LDFLAGS+=-L${LIBR}/socket -lr_socket
1616
LDFLAGS+=-L${LIBR}/util -lr_util
17+
LDFLAGS+=../zip/librz.a
1718
#OSTYPE=windows
1819
include ../../libr/socket/deps.mk
1920

‎sys/ios-sdk-gcc

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
#!/bin/sh
2-
export PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH
32

43
CWD="$(dirname "$0")"
4+
CC="xcrun --sdk iphoneos gcc -arch armv7 -I${CWD}/ios-include"
5+
#echo ${CC} "${CFLAGS}" "${LDFLAGS}" $*
6+
#exec ${CC} ${CFLAGS} ${LDFLAGS} $*
7+
exec ${CC} $*
8+
exit 1
9+
10+
export PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH
11+
512
#CPU="armv7 arm64"
613
if [ -z "${CPU}" ]; then
714
CPU=armv7

0 commit comments

Comments
 (0)
Please sign in to comment.