2
Copyright (C) 1994 M. Hagiya, W. Schelter, T. Yuasa
4
This file is part of GNU Common Lisp, herein referred to as GCL
6
GCL is free software; you can redistribute it and/or modify it under
7
the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE as published by
8
the Free Software Foundation; either version 2, or (at your option)
11
GCL is distributed in the hope that it will be useful, but WITHOUT
12
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14
License for more details.
16
You should have received a copy of the GNU Library General Public License
17
along with GCL; see the file COPYING. If not, write to the Free Software
18
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
42
fread(buffer, BUFSIZ, 1, from);
43
fwrite(buffer, BUFSIZ, 1, to);
46
fread(buffer, 1, n, from);
47
fwrite(buffer, 1, n, to);
54
memory_save(original_file, save_file)
55
char *original_file, *save_file;
57
struct scnhdr shdrs[15];
58
char *data_begin, *data_end;
60
FILE *original, *save;
67
original = fopen(original_file, "r");
68
if (stdin != original || original->_file != 0) {
69
fprintf(stderr, "Can't open the original file.\n");
72
setbuf(original, stdin_buf);
75
n = open(save_file, O_CREAT|O_WRONLY, 0777);
76
if (n != 1 || (save = fdopen(n, "w")) != stdout) {
77
fprintf(stderr, "Can't open the save file.\n");
80
setbuf(save, stdout_buf);
83
fread(&fileheader, sizeof(fileheader), 1, original);
84
fread(&header, fileheader.f_opthdr, 1, original);
85
fread(&shdrs[1],sizeof(sectionheader),fileheader.f_nscns,original);
86
data_begin = (char *) shdrs[2].s_paddr;
88
original_data = header.a_data;
89
header.a_data = data_end - data_begin;
90
diff = header.a_data - original_data;
91
header.a_bss = sbrk(0) - core_end;
92
fileheader.f_symptr += diff;
93
fwrite(&fileheader, sizeof(fileheader), 1, save);
94
fwrite(&header,fileheader.f_opthdr , 1, save);
97
#define INC_IF(x) if(x) x = x+diff;
100
INC_IF(shdrs[2].s_size);
103
shdrs[3].s_paddr += diff;
104
shdrs[3].s_vaddr += diff;
105
shdrs[3].s_size = header.a_bss;
107
for (n = 1; n <= fileheader.f_nscns; n++) {
108
INC_IF(shdrs[n].s_lnnoptr);
109
if(n>=3) {INC_IF(shdrs[n].s_scnptr);}
112
fwrite(&shdrs[1],sizeof(sectionheader),fileheader.f_nscns,save);
114
filecpy(save,original,shdrs[2].s_scnptr - ftell(save));
116
for (n = header.a_data, p = data_begin; ; n -= BUFSIZ, p += BUFSIZ)
118
fwrite(p, BUFSIZ, 1, save);
120
fwrite(p, 1, n, save);
125
fseek(original, original_data, 1);
138
check_type_or_pathname_string_symbol_stream(&vs_base[0]);
139
coerce_to_filename(vs_base[0], filename);
148
nfile = NUMBER_OPEN_FILES;
150
for (p = &_iob[3]; p < &_iob[nfile]; p++)
154
memory_save(kcl_self, filename);
171
/* printf("Calling sbrk(0x%08x),[cur,rently sbrk(0)=0x%08x,core_end=0x%08x,"
175
if (core_end && m1!= m)
177
((int)m1 % PAGESIZE))
178
{ error("unexpected sbrk");
181
{type_map[page(m)] = t_other;
185
/* printf("Returning 0x%08x\n",m); */