345 |
#define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1 |
#define ERROR2(msg,x,y) report_error_1 (new, msg, x, y); return -1 |
346 |
|
|
347 |
static |
static |
348 |
report_error_1 (fd, msg, a1, a2) |
report_error_1 (int fd, char *msg, int a1, int a2) |
|
int fd; |
|
|
char *msg; |
|
|
int a1, a2; |
|
349 |
{ |
{ |
350 |
close (fd); |
close (fd); |
351 |
#ifdef emacs |
#ifdef emacs |
356 |
#endif |
#endif |
357 |
} |
} |
358 |
|
|
359 |
static int make_hdr (); |
static int make_hdr (int new, int a_out, unsigned int data_start, unsigned int bss_start, unsigned int entry_address, char *a_name, char *new_name); |
360 |
static int copy_text_and_data (); |
static int copy_text_and_data (int new, int a_out); |
361 |
static int copy_sym (); |
static int copy_sym (int new, int a_out, char *a_name, char *new_name); |
362 |
static void mark_x (); |
static void mark_x (char *name); |
363 |
|
|
364 |
/* **************************************************************** |
/* **************************************************************** |
365 |
* unexec |
* unexec |
366 |
* |
* |
367 |
* driving logic. |
* driving logic. |
368 |
*/ |
*/ |
369 |
unexec (new_name, a_name, data_start, bss_start, entry_address) |
unexec (char *new_name, char *a_name, unsigned int data_start, unsigned int bss_start, unsigned int entry_address) |
|
char *new_name, *a_name; |
|
|
unsigned data_start, bss_start, entry_address; |
|
370 |
{ |
{ |
371 |
int new, a_out = -1; |
int new, a_out = -1; |
372 |
|
|
408 |
* Modify the text and data sizes. |
* Modify the text and data sizes. |
409 |
*/ |
*/ |
410 |
static int |
static int |
411 |
make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) |
make_hdr (int new, int a_out, unsigned int data_start, unsigned int bss_start, unsigned int entry_address, char *a_name, char *new_name) |
|
int new, a_out; |
|
|
unsigned data_start, bss_start, entry_address; |
|
|
char *a_name; |
|
|
char *new_name; |
|
412 |
{ |
{ |
413 |
int tem; |
int tem; |
414 |
#ifdef COFF |
#ifdef COFF |
806 |
* Copy the text and data segments from memory to the new a.out |
* Copy the text and data segments from memory to the new a.out |
807 |
*/ |
*/ |
808 |
static int |
static int |
809 |
copy_text_and_data (new, a_out) |
copy_text_and_data (int new, int a_out) |
|
int new, a_out; |
|
810 |
{ |
{ |
811 |
register char *end; |
register char *end; |
812 |
register char *ptr; |
register char *ptr; |
1002 |
return 0; |
return 0; |
1003 |
} |
} |
1004 |
|
|
1005 |
write_segment (new, ptr, end) |
write_segment (int new, register char *ptr, register char *end) |
|
int new; |
|
|
register char *ptr, *end; |
|
1006 |
{ |
{ |
1007 |
register int i, nwrite, ret; |
register int i, nwrite, ret; |
1008 |
char buf[80]; |
char buf[80]; |
1053 |
* Copy the relocation information and symbol table from the a.out to the new |
* Copy the relocation information and symbol table from the a.out to the new |
1054 |
*/ |
*/ |
1055 |
static int |
static int |
1056 |
copy_sym (new, a_out, a_name, new_name) |
copy_sym (int new, int a_out, char *a_name, char *new_name) |
|
int new, a_out; |
|
|
char *a_name, *new_name; |
|
1057 |
{ |
{ |
1058 |
char page[1024]; |
char page[1024]; |
1059 |
int n; |
int n; |
1093 |
* After successfully building the new a.out, mark it executable |
* After successfully building the new a.out, mark it executable |
1094 |
*/ |
*/ |
1095 |
static void |
static void |
1096 |
mark_x (name) |
mark_x (char *name) |
|
char *name; |
|
1097 |
{ |
{ |
1098 |
struct stat sbuf; |
struct stat sbuf; |
1099 |
int um; |
int um; |