diff --git a/core/cpu/arm/architecture/architecture.factor b/core/cpu/arm/architecture/architecture.factor index 0784b3af60..4e693bbe34 100755 --- a/core/cpu/arm/architecture/architecture.factor +++ b/core/cpu/arm/architecture/architecture.factor @@ -113,7 +113,7 @@ M: arm-backend %jump-label ( label -- ) B ; : %prepare-primitive ( -- ) #! Save stack pointer to stack_chain->callstack_top, load XT - R1 SP MOV ; + R1 SP 4 SUB ; M: arm-backend %call-primitive ( word -- ) %prepare-primitive diff --git a/vm/image.c b/vm/image.c index e1398eed81..c90f0ae5b0 100755 --- a/vm/image.c +++ b/vm/image.c @@ -92,8 +92,7 @@ void save_image(const F_CHAR *filename) file = OPEN_WRITE(filename); if(file == NULL) { - FPRINTF(stderr,"Cannot open image file: %s\n",filename); - fprintf(stderr,"%s\n",strerror(errno)); + fprintf(stderr,"Cannot open image file: %s\n",strerror(errno)); return; } @@ -122,10 +121,23 @@ void save_image(const F_CHAR *filename) fwrite(&h,sizeof(F_HEADER),1,file); - fwrite((void*)tenured->start,h.data_size,1,file); - fwrite(first_block(&code_heap),h.code_size,1,file); + if(fwrite((void*)tenured->start,h.data_size,1,file) != 1) + { + fprintf(stderr,"Save data heap failed: %s\n",strerror(errno)); + return; + } - fclose(file); + if(fwrite(first_block(&code_heap),h.code_size,1,file) != 1) + { + fprintf(stderr,"Save code heap failed: %s\n",strerror(errno)); + return; + } + + if(fclose(file)) + { + fprintf(stderr,"Failed to close image file: %s\n",strerror(errno)); + return; + } } DEFINE_PRIMITIVE(save_image)