comparison src/unexalpha.c @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents de805c49cfc1
children
comparison
equal deleted inserted replaced
411:12e008d41344 412:697ef44129c6
29 #include <sys/types.h> 29 #include <sys/types.h>
30 #include <sys/file.h> 30 #include <sys/file.h>
31 #include <sys/stat.h> 31 #include <sys/stat.h>
32 #include <sys/mman.h> 32 #include <sys/mman.h>
33 #include <stdio.h> 33 #include <stdio.h>
34 #include <errno.h>
35 #include <varargs.h> 34 #include <varargs.h>
36 #include <filehdr.h> 35 #include <filehdr.h>
37 #include <aouthdr.h> 36 #include <aouthdr.h>
38 #include <scnhdr.h> 37 #include <scnhdr.h>
39 #include <syms.h> 38 #include <syms.h>
52 51
53 #define SEEK(_fd, _position, _error_message, _error_arg) \ 52 #define SEEK(_fd, _position, _error_message, _error_arg) \
54 errno = EEOF; \ 53 errno = EEOF; \
55 if (lseek (_fd, _position, L_SET) != _position) \ 54 if (lseek (_fd, _position, L_SET) != _position) \
56 fatal_unexec (_error_message, _error_arg); 55 fatal_unexec (_error_message, _error_arg);
56
57 extern int errno;
58 extern char *strerror ();
59
60 void *sbrk();
57 61
58 #define EEOF -1 62 #define EEOF -1
59 63
60 static struct scnhdr *text_section; 64 static struct scnhdr *text_section;
61 static struct scnhdr *init_section; 65 static struct scnhdr *init_section;
79 struct aouthdr aout; 83 struct aouthdr aout;
80 struct scnhdr section[_MIPS_NSCNS_MAX]; 84 struct scnhdr section[_MIPS_NSCNS_MAX];
81 }; 85 };
82 86
83 87
88
84 /* Define name of label for entry point for the dumped executable. */ 89 /* Define name of label for entry point for the dumped executable. */
85 90
86 #ifndef DEFAULT_ENTRY_ADDRESS 91 #ifndef DEFAULT_ENTRY_ADDRESS
87 #define DEFAULT_ENTRY_ADDRESS __start 92 #define DEFAULT_ENTRY_ADDRESS __start
88 #endif 93 #endif
89 EXTERN_C int DEFAULT_ENTRY_ADDRESS (void);
90
91 94
92 int 95 int
93 unexec (char *new_name, char *a_name, 96 unexec (char *new_name, char *a_name,
94 unsigned long data_start, 97 unsigned long data_start,
95 unsigned long bss_start, 98 unsigned long bss_start,
205 208
206 nhdr.aout.dsize = brk - DATA_START; 209 nhdr.aout.dsize = brk - DATA_START;
207 nhdr.aout.bsize = 0; 210 nhdr.aout.bsize = 0;
208 if (entry_address == 0) 211 if (entry_address == 0)
209 { 212 {
213 extern int DEFAULT_ENTRY_ADDRESS (void);
210 nhdr.aout.entry = (unsigned long)DEFAULT_ENTRY_ADDRESS; 214 nhdr.aout.entry = (unsigned long)DEFAULT_ENTRY_ADDRESS;
211 } 215 }
212 else 216 else
213 nhdr.aout.entry = entry_address; 217 nhdr.aout.entry = entry_address;
214 218