Skip to content

Commit

Permalink
initial build test
Browse files Browse the repository at this point in the history
  • Loading branch information
AnwarMohamed committed Jun 27, 2014
1 parent 76ce9db commit 88c597f
Show file tree
Hide file tree
Showing 230 changed files with 100,758 additions and 0 deletions.
56 changes: 56 additions & 0 deletions osx/common/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.SUFFIXES: .S .c

SOURCEPATH=.
SSL_PATH=../openssl/include
XOR_PATH=./crypto
ZLIB_PATH=./zlib
DARWIN_PATH=../../include
GCC_PATH=../../include/gcc

CFLAGS=-nostdinc -nostdlib
#CFLAGS+= -I ../../test/source/bionic/libc/include
#CFLAGS+= -I ../../test/source/bionic/libc/kernel/common/linux/
#CFLAGS+= -I ../../test/source/bionic/libc/kernel/common/
#CFLAGS+= -I ../../test/source/bionic/libc/arch-x86/include/
#CFLAGS+= -I ../../test/source/bionic/libc/kernel/arch-x86/

CFLAGS+= -I$(SSL_PATH)
CFLAGS+= -D_BYTE_ORDER=_LITTLE_ENDIAN -D_SIZE_T_DECLARED
#CFLAGS+= -Dwchar_t="char"
CFLAGS+= -fno-builtin
#-DElf_Size="u_int32_t"
CFLAGS+= -I$(SOURCEPATH) -I$(XOR_PATH) -I$(ZLIB_PATH) -I$(SSL_PATH) -I$(DARWIN_PATH)
#CFLAGS+= -D__linux__ -D__DARWIN__ -DMALLOC_PRODUCTION
CFLAGS+= -I.
CFLAGS+= -march=i386 -m32 -g -fPIC -Os -DPIC

#CC=gcc
CC=i686-apple-darwin10-gcc
AR=i686-apple-darwin10-ar
LD=i686-apple-darwin10-ld
RM=rm

objects = args.o base.o base_dispatch.o base_dispatch_common.o buffer.o \
channel.o common.o core.o list.o remote.o thread.o xor.o zlib.o

CFLAGS+= -fno-stack-protector


BASEVPATH=.:./crypto:./arch/posix:./zlib:
OSVPATH=./arch/posix
ARCHVPATH=./arch/posix
VPATH=$(BASEVPATH):$(OSVPATH):$(ARCHVPATH)

CFLAGS+= -I$(ARCHVPATH)


all: libsupport.dylib

libsupport.dylib: $(objects)
$(CC) $(CFLAGS) -dynamiclib $(objects) -lc -lssl -lcrypto -o $@

clean:
$(RM) -f *.o *.a *.dylib zlib/zlib.o

.PHONY: clean

8 changes: 8 additions & 0 deletions osx/common/arch/posix/base_dispatch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "common.h"

DWORD
remote_request_core_migrate(Remote *remote, Packet *packet)
{
return (EOPNOTSUPP);
}

64 changes: 64 additions & 0 deletions osx/common/arch/posix/buffer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include <fcntl.h>
#include "common.h"

//#define errno 0

DWORD
buffer_from_file(LPCSTR filePath, PUCHAR *buffer, PULONG length)
{
int fd, res = 0;
off_t size;
char *buf = NULL;

if ((fd = open(filePath, O_RDONLY)) < 0) {
res = errno;
return (res);
}
/*
* find the end
*/
if ((size = lseek(fd, 0, SEEK_END)) < 0) {
res = errno;
goto done;
}
if ((res = lseek(fd, 0, SEEK_SET)) < 0) {
res = errno;
goto done;
}
if ((buf = malloc(size)) == NULL) {
res = ENOMEM;
goto done;
}
if (read(fd, buf, size) < size) {
res = errno;
free(buf);
}
done:
close(fd);
if (res == 0) {
if (buffer)
*buffer = buf;
else
free(buf);
if (length)
*length = size;
}
return (res);
}

DWORD
buffer_to_file(LPCSTR filePath, PUCHAR buffer, ULONG length)
{
int fd, res = 0;
off_t size;

if ((fd = open(filePath, O_CREAT|O_TRUNC|O_WRONLY, 0777)) < 0) {
res = errno;
return (res);
}
if (write(fd, buffer, length) < length)
res = errno;

close(fd);
return (res);
}
Loading

0 comments on commit 88c597f

Please sign in to comment.