iPhone Honeypot Project

June 17, 2010

GCC on iPhone – Progress? (Continued)

Filed under: bash,Darwin,gcc,libpcap,scripe,SDK — abnev @ 2:05 pm
Tags: , , , , , ,

I EVENTUALLY managed to get back to where I was yesterday after I hit a bump in the road where I stepped back and could no longer compile simple applications on my Mac OSX destined for the iPhone arch. This time, I have created a simple script called ‘gcc2’ which sets all the appropriate options.

#!/bin/sh

GCC=”/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc”

ISYSROOT=”/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk”      #3.1.3

EXPECTED_ARGS=3

# check num of args supplied

if [ $# -ne $EXPECTED_ARGS ]

then

#print usage

echo “Usage: `basename $0`: no input files”

exit -1      #exit on error

fi

# e.g. gcc -arch armv6 -isysroot $ISYSROOT -o test test.c

$GCC -arch armv6 -isysroot $ISYSROOT $1 $2 $3

Additionally, I have attached my bash_history file for setting up the environment etc.
abnev-lpt2:iphone-gcc abnev$ cat test.c
#include <stdio.h>
int main() {
printf(“Hello, World!\n”);
return(0);
}
abnev-lpt2:iphone-gcc abnev$ /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk/
abnev-lpt2:iphone-gcc abnev$ /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk -o test test.c
abnev-lpt2:iphone-gcc abnev$ cd ~
abnev-lpt2:~ abnev$ mkdir bin
abnev-lpt2:~ abnev$ cd bin
abnev-lpt2:bin abnev$ pico gcc2
abnev-lpt2:bin abnev$ PATH=$PATH:/Users/abnev/bin
abnev-lpt2:bin abnev$ chmod 755 gcc2
abnev-lpt2:bin abnev$ gcc2
arm-apple-darwin10-gcc-4.2.1: no input files
abnev-lpt2:bin abnev$ cp ~/test.c .
abnev-lpt2:bin abnev$ gcc2 -o test test.c
abnev-lpt2:bin abnev$ ./test
-bash: ./test: Bad CPU type in executable
abnev-lpt2:bin abnev$

Just an extra note, to make sure the environment would be set up after reboots etc I modified my ~/.profile to include the correct PATH environment variables pointing towards ~/bin where gcc2 now resides. This was done by adding/changing the line:

export PATH=/opt/bin:/opt/local/bin:/opt/local/sbin:$PATH

to

export PATH=/Users/abnev/bin:/opt/bin:/opt/local/bin:/opt/local/sbin:$PATH

I’ll continue trying to get it to compile using libpcap.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: