# HG changeset patch # User taiki # Date 1359810935 -32400 # Node ID 075d70197fc2a87701b24aba62dac22e45041366 add written files. diff -r 000000000000 -r 075d70197fc2 Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Sat Feb 02 22:15:35 2013 +0900 @@ -0,0 +1,11 @@ +CC = cbc-gcc-4.6.0 + +TARGET = loader + +CFLAGES = -Wall -O2 -g -o + +$(TARGET): loader.c + $(CC) $(CFLAGES) $(TARGET) loader.c + +clean: + rm $(TARGET) diff -r 000000000000 -r 075d70197fc2 loader.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loader.c Sat Feb 02 22:15:35 2013 +0900 @@ -0,0 +1,74 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#define NAME_MAX_LENGTH 128 +#define MAX_SEGMENT_NUM 128 + + +void option_reader(int argc, char *argv[], char *filename) +{ + int i; + for (i=0; imagic) { + fprintf(stderr, "This is not mach header 64.\n"); + return 0; + } + + printf("%s is 64bit Mach-O file.\n", filename); + + if (MH_EXECUTE != mh64->filetype) { + fprintf(stderr, "This is not executable file.\n"); + return 0; + } + + printf("%s is executable file.\n", filename); + + if (CPU_TYPE_X86_64 == mh64->cputype) printf("CPU : x86_64\n"); + + int i = 0; + int mh64_size = sizeof(struct mach_header_64); + int lc_size = sizeof(struct load_command); + for (;i < mh64->ncmds; i++) { + struct load_command * lc = (struct load_command*)head + lc_size * i; + } + + close(fp); + + return 0; +} diff -r 000000000000 -r 075d70197fc2 sample/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sample/Makefile Sat Feb 02 22:15:35 2013 +0900 @@ -0,0 +1,15 @@ +CC = cbc-gcc-4.6.0 +CFLAGS = -O2 \ + -Wall \ + -g \ + -c + +TARGET = sample + +$(TARGET) : sample.o + +sample.o: sample.c + $(CC) $(CFLAGS) -o $@ $^ + +clean: + rm -r *.o $(TARGET) diff -r 000000000000 -r 075d70197fc2 sample/sample.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sample/sample.c Sat Feb 02 22:15:35 2013 +0900 @@ -0,0 +1,8 @@ +int main() +{ + int a = 0; + int b = 2; + int c = 3; + + a = b + c; +}