--- cryopid-0.5.9.1.orig/src/Makefile +++ cryopid-0.5.9.1/src/Makefile @@ -1,8 +1,8 @@ # Disabling tcpcp support saves a few KB in the binary. -USE_TCPCP=y +USE_TCPCP=n USE_GTK=n -ARCH=$(shell arch) +ARCH=$(shell uname -m) # Test if this gcc supports stack protection (and if so, turn it off). ifeq ($(shell $(CC) -E -fno-stack-protector - < /dev/null > /dev/null 2>&1 && echo 1),1) @@ -20,6 +20,7 @@ ifeq ($(ARCH), x86_64) ARCH_OFORMAT=elf64-x86-64 LD_FORMAT=elf_x86_64 +LIBCOMPAT=/usr/diet/lib-x86_64/libcompat.a USE_TCPCP=y USE_GTK=n endif @@ -39,7 +40,7 @@ R_CHUNK_OBJS = cpimage_r.o cp_r_fd.o cp_r_fd_console.o cp_r_fd_file.o cp_r_fd_fifo.o cp_r_fd_socket.o cp_r_misc.o cp_r_sighand.o cp_r_vma.o cp_r_header.o arch/arch_r_objs.o fork2.o W_CHUNK_OBJS = cpimage_w.o cp_w_fd.o cp_w_fd_console.o cp_w_fd_file.o cp_w_fd_fifo.o cp_w_fd_socket.o cp_w_misc.o cp_w_sighand.o cp_w_vma.o cp_w_header.o arch/arch_w_objs.o list.o -COMMON_OBJS = common.c arch/asmfuncs.o +COMMON_OBJS = common.c STUB_TYPES = gzip # raw buffered lzo STUBS = $(patsubst %,stub-%,$(STUB_TYPES)) TARGETS = freeze fork2_helper @@ -46,7 +47,7 @@ TARGETS = freeze fork2_helper # How do we get our libc linked into the stub? -LIBC = -DPROVIDE_MALLOC -nostdlib -nostartfiles ../dietlibc-$(ARCH)/dietlibc.a -lgcc +LIBC = -DPROVIDE_MALLOC -nostdlib -nostartfiles /usr/diet/lib-x86_64/libc.a $(LIBCOMPAT) -lgcc #LIBC = -nostdlib -nostartfiles -lc # Compile in tcpcp if wanted/needed @@ -60,7 +61,7 @@ R_CHUNK_OBJS += gtk_support.o DEFINES += -DUSE_GTK endif - +DEFINES += -DFORK2HELPER=\"$(PREFIX)/lib/cryopid/fork2_helper\" CFLAGS += $(DEFINES) # Utilities @@ -74,7 +75,7 @@ ! test -h arch && rm -f arch && ln -s arch-$(ARCH) arch || true make -C arch 'CFLAGS+=$(DEFINES) $(CFLAGS_GCC_SP)' -clean: +distclean clean: rm -f *.o arch/*.o $(TARGETS) rm -f arch @@ -95,7 +96,17 @@ gtk_support.o: gtk_support.c $(CC) $(CFLAGS) -I/usr/include/gtk-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pango-1.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -c $< +DESTDIR=/ +PREFIX=/usr + fork2_helper: fork2_helper.c + echo "Fork2 extra rule is executed." $(CC) $(CFLAGS) $< -o $@ -.PHONY: arch +install: freeze fork2_helper + [ -d $(DESTDIR)/$(PREFIX)/bin/ ] || mkdir -p $(DESTDIR)/$(PREFIX)/bin/ + cp freeze $(DESTDIR)/$(PREFIX)/bin/ + [ -d $(DESTDIR)/$(PREFIX)/lib/cryopid/ ] || mkdir -p $(DESTDIR)/$(PREFIX)/lib/cryopid/ + cp fork2_helper $(DESTDIR)/$(PREFIX)/lib/cryopid/ + +.PHONY: arch clean distclean --- cryopid-0.5.9.1.orig/src/arch-x86_64/arch.h +++ cryopid-0.5.9.1/src/arch-x86_64/arch.h @@ -1,6 +1,7 @@ #ifndef _ARCH_H_ #define _ARCH_H_ +#include #include #include @@ -11,6 +12,41 @@ #define _ARCH_NSIG_BPW 64 #define _ARCH_NSIG_WORDS (_ARCH_NSIG / _ARCH_NSIG_BPW) +/* import some definitions */ +#if 1 +#ifndef __syscall +#define __syscall "syscall" +#endif + +#ifndef __syscall_clobber +#define __syscall_clobber "r11","rcx","memory" +#endif + +#ifndef __syscall_return +#define __syscall_return(type, res) \ +do { \ + if ((unsigned long)(res) >= (unsigned long)(-127)) { \ + errno = -(res); \ + res = -1; \ + } \ + return (type) (res); \ +} while (0) +#endif + +#ifndef _syscall2 +#define _syscall2(type,name,type1,arg1,type2,arg2) \ +type name(type1 arg1,type2 arg2) \ +{ \ +long __res; \ +__asm__ volatile (__syscall \ + : "=a" (__res) \ + : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)) : __syscall_clobber ); \ +__syscall_return(type,__res); \ +} +#endif + +#endif + typedef struct { unsigned long sig[_ARCH_NSIG_WORDS]; } arch_sigset_t; --- cryopid-0.5.9.1.orig/src/arch-x86_64/stub.c +++ cryopid-0.5.9.1/src/arch-x86_64/stub.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "cryopid.h" #include "cpimage.h" --- cryopid-0.5.9.1.orig/src/fork2.c +++ cryopid-0.5.9.1/src/fork2.c @@ -44,7 +44,11 @@ { char *argv[] = {"farewell", "kitty", "XXXXXXXXXX", NULL}; snprintf(argv[2], 10, "%d", pid); - execve("fork2_helper", argv, environ); +#ifndef FORK2HELPER +#define FORK2HELPER "fork2_helper" +#endif + execve(FORK2HELPER, argv, environ); +#undef FORK2HELPER perror("execve"); _exit(50); } --- cryopid-0.5.9.1.orig/src/cpimage.h 2009-03-02 22:59:56.000000000 -0500 +++ cryopid-0.5.9.1/src/cpimage.h 2009-03-02 23:00:07.000000000 -0500 @@ -10,7 +10,7 @@ #include #include "list.h" -#include "cplayout.h" +#include "arch/cplayout.h" #define IMAGE_VERSION 0x03