diff --git a/Makefile b/Makefile index aa2f80198..0a6df2947 100644 --- a/Makefile +++ b/Makefile @@ -89,7 +89,8 @@ parasite-util-net.o: util-net.c $(HEAD-BIN): $(PIE-LDS) $(OBJS-BLOB) parasite-util-net.o $(E) " GEN " $@ - $(Q) $(LD) -T $(PIE-LDS) $(OBJS-BLOB) parasite-util-net.o -o $@ + $(Q) $(LD) --oformat=binary -T $(PIE-LDS) $(OBJS-BLOB) parasite-util-net.o -o $@ + $(Q) $(LD) --oformat=elf64-x86-64 -T $(PIE-LDS) $(OBJS-BLOB) parasite-util-net.o -o $@.o $(HEAD-BLOB-GEN): $(HEAD-BIN) $(GEN-OFFSETS) $(E) " GEN " $@ @@ -102,7 +103,8 @@ $(ROBJS): $(RSRCS-BLOB) $(RHEAD-BIN): $(ROBJS) $(PIE-LDS) $(E) " GEN " $@ - $(Q) $(LD) -T $(PIE-LDS) $(ROBJS) -o $@ + $(Q) $(LD) --oformat=binary -T $(PIE-LDS) $(ROBJS) -o $@ + $(Q) $(LD) --oformat=elf64-x86-64 -T $(PIE-LDS) $(ROBJS) -o $@.o $(RHEAD-BLOB-GEN): $(RHEAD-BIN) $(GEN-OFFSETS) $(E) " GEN " $@ diff --git a/cr-restore.c b/cr-restore.c index d9aba7cf8..5c337d37c 100644 --- a/cr-restore.c +++ b/cr-restore.c @@ -1233,8 +1233,8 @@ static int sigreturn_restore(pid_t pid, struct list_head *tgt_vmas, int nr_vmas) * might be completely unused so it's here just for convenience. */ restore_code_start = mem; - restore_thread_exec_start = restore_code_start + restorer_blob_offset__restore_thread; - restore_task_exec_start = restore_code_start + restorer_blob_offset__restore_task; + restore_thread_exec_start = restore_code_start + restorer_blob_offset____export_restore_thread; + restore_task_exec_start = restore_code_start + restorer_blob_offset____export_restore_task; task_args = restore_code_start + restore_code_len; thread_args = (void *)((long)task_args + sizeof(*task_args)); diff --git a/gen-offsets.sh b/gen-offsets.sh index 545b6d7d5..cc5c6fde5 100644 --- a/gen-offsets.sh +++ b/gen-offsets.sh @@ -7,7 +7,7 @@ NAME=$1 INC_GUARD=__${NAME}_h__ PREFIX=${NAME}_blob_offset__ BLOB=${NAME}_blob -OBJNAME=${NAME}.o +OBJNAME=${NAME}.bin.o BINARY=${NAME}.bin AWK_CMD='$2 ~ /^[tT]$/ { print "#define '$PREFIX'" $3 " 0x" $1; }' @@ -19,7 +19,7 @@ cat << EOF EOF -nm $OBJNAME | tr . _ | awk "$AWK_CMD" +nm $OBJNAME | grep "__export_" | tr . _ | awk "$AWK_CMD" cat << EOF diff --git a/include/parasite.h b/include/parasite.h index 0bd01b5d5..038fb5c49 100644 --- a/include/parasite.h +++ b/include/parasite.h @@ -96,10 +96,10 @@ struct parasite_drain_fd { */ #define PARASITE_ARGS_ADDR(start) \ - ((start) + parasite_blob_offset__parasite_args) + ((start) + parasite_blob_offset____export_parasite_args) #define PARASITE_CMD_ADDR(start) \ - ((start) + parasite_blob_offset__parasite_cmd) + ((start) + parasite_blob_offset____export_parasite_cmd) #define PARASITE_HEAD_ADDR(start) \ - ((start) + parasite_blob_offset__parasite_head_start) + ((start) + parasite_blob_offset____export_parasite_head_start) #endif /* CR_PARASITE_H_ */ diff --git a/include/restorer.h b/include/restorer.h index cbb6a28f5..4a757634a 100644 --- a/include/restorer.h +++ b/include/restorer.h @@ -18,8 +18,8 @@ struct task_restore_core_args; struct thread_restore_args; -extern long restore_task(struct task_restore_core_args *args); -extern long restore_thread(struct thread_restore_args *args); +extern long __export_restore_task(struct task_restore_core_args *args); +extern long __export_restore_thread(struct thread_restore_args *args); typedef long (*task_restore_fcall_t) (struct task_restore_core_args *args); typedef long (*thread_restore_fcall_t) (struct thread_restore_args *args); diff --git a/parasite.c b/parasite.c index 60169ee69..1af4c9879 100644 --- a/parasite.c +++ b/parasite.c @@ -487,29 +487,29 @@ static int __used parasite_service(unsigned long cmd, void *args) return -1; } -static void __head parasite_head(void) +static void __head __export_parasite_head(void) { /* * The linker will handle the stack allocation. */ - asm volatile("parasite_head_start: \n" - "leaq parasite_stack(%rip), %rsp \n" + asm volatile("__export_parasite_head_start: \n" + "leaq __export_parasite_stack(%rip), %rsp \n" "subq $16, %rsp \n" "andq $~15, %rsp \n" "pushq $0 \n" "movq %rsp, %rbp \n" - "movl parasite_cmd(%rip), %edi \n" - "leaq parasite_args(%rip), %rsi \n" + "movl __export_parasite_cmd(%rip), %edi \n" + "leaq __export_parasite_args(%rip), %rsi \n" "call parasite_service \n" "int $0x03 \n" ".align 8 \n" - "parasite_cmd: \n" + "__export_parasite_cmd: \n" ".long 0 \n" - "parasite_args: \n" + "__export_parasite_args: \n" ".long 0 \n" ".space "__stringify(PARASITE_ARG_SIZE)",0 \n" ".space "__stringify(PARASITE_STACK_SIZE)", 0 \n" - "parasite_stack: \n" + "__export_parasite_stack: \n" ".long 0 \n"); } diff --git a/pie.lds.S b/pie.lds.S index 3cd9840d8..4055af7aa 100644 --- a/pie.lds.S +++ b/pie.lds.S @@ -1,4 +1,3 @@ -OUTPUT_FORMAT("binary") OUTPUT_ARCH(i386:x86-64) SECTIONS @@ -13,8 +12,6 @@ SECTIONS . = ALIGN(32); *(.bss*) . = ALIGN(32); - *(.export) - . = ALIGN(32); } =0x00000000 /DISCARD/ : { diff --git a/restorer.c b/restorer.c index b4085747e..7af708df1 100644 --- a/restorer.c +++ b/restorer.c @@ -128,7 +128,7 @@ static void restore_creds(struct creds_entry *ce) * Threads restoration via sigreturn. Note it's locked * routine and calls for unlock at the end. */ -long restore_thread(struct thread_restore_args *args) +long __export_restore_thread(struct thread_restore_args *args) { long ret = -1; struct core_entry *core_entry; @@ -335,7 +335,7 @@ static u64 restore_mapping(const struct vma_entry *vma_entry) * and jump execution to some predefined ip read from * core file. */ -long restore_task(struct task_restore_core_args *args) +long __export_restore_task(struct task_restore_core_args *args) { long ret = -1; struct task_entry *task_entry;