Cleanups for the iOS target of io.mach plugin

This commit is contained in:
pancake
2025-11-23 09:33:15 +01:00
committed by pancake
parent 805ddee6be
commit d8b96050fc
7 changed files with 24 additions and 68 deletions

View File

@@ -20,23 +20,23 @@
#include <mach/mach_init.h>
#include <mach/mach_port.h>
#include <mach/vm_map.h>
#include <mach/mach_error.h>
#include <mach/thread_info.h>
#include <mach/thread_act.h>
static int __get_pid(RIODesc *desc);
#if APPLE_SDK_IPHONEOS
// missing includes
// iPhoneOS have some missing includes
#else
#define EXCEPTION_PORT 0
// NOTE: mach/mach_vm is not available for iOS
#include <mach/mach_traps.h>
#include <mach/mach_error.h>
#include <mach/thread_act.h>
#include <mach/thread_info.h>
#include <mach-o/loader.h>
#include <mach-o/nlist.h>
#include <sys/ptrace.h>
#endif
#include <mach/task.h>
#include <mach/task_info.h>
#if defined(__x86_64__)
@@ -60,19 +60,9 @@ typedef struct r_io_mach_data_t {
typedef struct {
task_t task;
} RIOMach;
/*
#define RIOMACH_PID(x) (x? ((RIOMach*) (x))->pid: -1)
#define RIOMACH_TASK(x) (x? ((RIOMach*) (x))->task: -1)
*/
int RIOMACH_TASK(RIOMachData *x) {
// TODO
return -1;
}
#undef R_IO_NFDS
#define R_IO_NFDS 2
extern int errno;
static task_t task_for_pid_workaround(int pid) {
host_t myhost = mach_host_self ();
@@ -174,6 +164,19 @@ static bool task_is_dead(RIODesc *fd, int pid) {
return (kr != KERN_SUCCESS || !count);
}
static int __get_pid(RIODesc *desc) {
// dupe for? r_io_desc_get_pid (desc);
if (desc) {
RIOMachData *iodd = desc->data;
if (iodd) {
if (iodd->magic == R_MACH_MAGIC) {
return iodd->pid;
}
}
}
return -1;
}
static R_TH_LOCAL ut64 the_lower = UT64_MAX;
static ut64 getNextValid(RIO *io, RIODesc *fd, ut64 addr) {
@@ -244,10 +247,8 @@ static int __read(RIO *io, RIODesc *desc, ut8 *buf, int len) {
if (task_is_dead (desc, pid)) {
return -1;
}
if (pid == 0) {
if (io->off < 4096) {
return len;
}
if (pid == 0 && io->off < 4096) {
return len;
}
copied = getNextValid (io, desc, io->off) - io->off;
if (copied < 0) {
@@ -615,20 +616,6 @@ static char *__system(RIO *io, RIODesc *fd, const char *cmd) {
return NULL;
}
static int __get_pid(RIODesc *desc) {
// dupe for? r_io_desc_get_pid (desc);
if (desc) {
RIOMachData *iodd = desc->data;
if (iodd) {
if (iodd->magic != R_MACH_MAGIC) {
return -1;
}
return iodd->pid;
}
}
return -1;
}
RIOPlugin r_io_plugin_mach = {
.meta = {
.name = "mach",

View File

@@ -21,15 +21,6 @@ fi
export BUILD=1
if [ ! -d sys/ios-include/mach/vm_behavior.h ]; then
#(
# cd sys && \
# wget -c https://lolcathost.org/b/ios-include.tar.gz && \
# tar xzvf ios-include.tar.gz
#)
echo je
fi
. sys/ios-env.sh
if [ "${STOW}" = 1 ]; then
PREFIX=/private/var/radare2

View File

@@ -6,5 +6,4 @@ export CC=$(pwd)/sys/ios-sdk-gcc
# set only for arm64, otherwise it is armv7
# select ios sdk version
export IOSVER=11.0
export IOSINC=$(pwd)/sys/ios-include
export CFLAGS=-O2

View File

@@ -2,7 +2,6 @@
[ -z "${CPU}" ] && CPU="arm64"
CWD="$(dirname "$0")"
[ -z "${IOSINC}" ] && IOSINC="${CWD}/ios-include"
CPUS=""
CPU=`echo $CPU | sed -e 's,+, ,g'`
for a in `IFS=+ echo ${CPU}` ; do
@@ -15,7 +14,7 @@ BITCODE_FLAG=""
if [ "${EMBED_BITCODE}" = "1" ]; then
BITCODE_FLAG="-fembed-bitcode"
fi
CC="xcrun --sdk ${SDK} clang ${CPUS} ${BITCODE_FLAG} -DAPPLE_SDK_${APPLE_SDK}=1 -I${IOSINC} -miphoneos-version-min=10.0"
CC="xcrun --sdk ${SDK} clang ${CPUS} ${BITCODE_FLAG} -DAPPLE_SDK_${APPLE_SDK}=1 -miphoneos-version-min=10.0"
echo $CC $*
${CC} $*
r=$?

View File

@@ -2,7 +2,6 @@
[ -z "${CPU}" ] && CPU="arm64"
CWD="$(dirname "$0")"
[ -z "${IOSINC}" ] && IOSINC="${CWD}/ios-include"
CPUS=""
CPU=`echo $CPU | sed -e 's,+, ,g'`
for a in `IFS=+ echo ${CPU}` ; do

View File

@@ -43,28 +43,18 @@ export BUILD=1
PREFIX="/usr"
# PREFIX=/var/mobile
if [ ! -d sys/ios-include ]; then
(
cd sys && \
wget -c https://lolcathost.org/b/ios-include.tar.gz && \
tar xzvf ios-include.tar.gz
)
fi
export PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH
export PATH=$(pwd)/sys:${PATH}
export CC="$(pwd)/sys/ios-sdk-gcc"
# set only for arm64, otherwise it is armv7
# select ios sdk version
export IOSVER=10.2
export IOSINC=/
#$(pwd)/sys/ios-include
export CFLAGS="${CFLAGS} -O2"
export USE_SIMULATOR=1
export RANLIB="xcrun --sdk iphoneos ranlib"
if [ "$1" = "-s" ]; then
sh
sh
exit $?
fi

View File

@@ -35,21 +35,12 @@ export BUILD=1
PREFIX="/usr"
# PREFIX=/var/mobile
if [ ! -f sys/ios-include/mach/mach_vm.h ]; then
(
cd sys && \
wget -c https://lolcathost.org/b/ios-include.tar.gz && \
tar xzvf ios-include.tar.gz
)
fi
export PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH
export PATH=$(pwd)/sys:${PATH}
export CC=$(pwd)/sys/ios-sdk-gcc
# set only for arm64, otherwise it is armv7
# select ios sdk version
export IOSVER=9.3
export IOSINC=$(pwd)/sys/ios-include
#export CFLAGS=-O2
export CFLAGS="-Os -flto"
export LDFLAGS="-flto"