diff options
| author | Richard M. Stallman | 1994-10-25 10:52:58 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-10-25 10:52:58 +0000 |
| commit | 866fc66add404962ae163b06dcdf3ce342a4a536 (patch) | |
| tree | 89ab962e72e7dfba10c9d6a6b6a5368c82d1c01d | |
| parent | e964ed223e77e85cb77e3ff374a1b3ec5c02847d (diff) | |
| download | emacs-866fc66add404962ae163b06dcdf3ce342a4a536.tar.gz emacs-866fc66add404962ae163b06dcdf3ce342a4a536.zip | |
(Brk): Declare as unsigned long.
(unexec): Do CHECH_SCNHDR on _RCONST if that's defined.
Ignore rdata_section if there is none.
(update_dynamic_symbols): New arg new_name. Call changed.
Fix some calls to WRITE.
(fatal_unexec): Declare all arguments.
| -rw-r--r-- | src/unexalpha.c | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/src/unexalpha.c b/src/unexalpha.c index 6260288d0bc..100cf0aee52 100644 --- a/src/unexalpha.c +++ b/src/unexalpha.c | |||
| @@ -59,6 +59,7 @@ static struct scnhdr *text_section; | |||
| 59 | static struct scnhdr *init_section; | 59 | static struct scnhdr *init_section; |
| 60 | static struct scnhdr *finit_section; | 60 | static struct scnhdr *finit_section; |
| 61 | static struct scnhdr *rdata_section; | 61 | static struct scnhdr *rdata_section; |
| 62 | static struct scnhdr *rconst_section; | ||
| 62 | static struct scnhdr *data_section; | 63 | static struct scnhdr *data_section; |
| 63 | static struct scnhdr *pdata_section; | 64 | static struct scnhdr *pdata_section; |
| 64 | static struct scnhdr *xdata_section; | 65 | static struct scnhdr *xdata_section; |
| @@ -69,7 +70,7 @@ static struct scnhdr *sdata_section; | |||
| 69 | static struct scnhdr *sbss_section; | 70 | static struct scnhdr *sbss_section; |
| 70 | static struct scnhdr *bss_section; | 71 | static struct scnhdr *bss_section; |
| 71 | 72 | ||
| 72 | static unsigned int Brk; | 73 | static unsigned long Brk; |
| 73 | 74 | ||
| 74 | struct headers { | 75 | struct headers { |
| 75 | struct filehdr fhdr; | 76 | struct filehdr fhdr; |
| @@ -169,6 +170,9 @@ unexec (new_name, a_name, data_start, bss_start, entry_address) | |||
| 169 | CHECK_SCNHDR (finit_section, _FINI, STYP_FINI); | 170 | CHECK_SCNHDR (finit_section, _FINI, STYP_FINI); |
| 170 | #endif /* _FINI */ | 171 | #endif /* _FINI */ |
| 171 | CHECK_SCNHDR (rdata_section, _RDATA, STYP_RDATA); | 172 | CHECK_SCNHDR (rdata_section, _RDATA, STYP_RDATA); |
| 173 | #ifdef _RCONST | ||
| 174 | CHECK_SCNHDR (rconst_section, _RCONST, STYP_RCONST); | ||
| 175 | #endif | ||
| 172 | #ifdef _PDATA | 176 | #ifdef _PDATA |
| 173 | CHECK_SCNHDR (pdata_section, _PDATA, STYP_PDATA); | 177 | CHECK_SCNHDR (pdata_section, _PDATA, STYP_PDATA); |
| 174 | #endif _PDATA | 178 | #endif _PDATA |
| @@ -186,12 +190,6 @@ unexec (new_name, a_name, data_start, bss_start, entry_address) | |||
| 186 | CHECK_SCNHDR (sdata_section, _SDATA, STYP_SDATA); | 190 | CHECK_SCNHDR (sdata_section, _SDATA, STYP_SDATA); |
| 187 | CHECK_SCNHDR (sbss_section, _SBSS, STYP_SBSS); | 191 | CHECK_SCNHDR (sbss_section, _SBSS, STYP_SBSS); |
| 188 | CHECK_SCNHDR (bss_section, _BSS, STYP_BSS); | 192 | CHECK_SCNHDR (bss_section, _BSS, STYP_BSS); |
| 189 | #if 0 /* Apparently this error check goes off on irix 3.3, | ||
| 190 | but it doesn't indicate a real problem. */ | ||
| 191 | if (i != nhdr.fhdr.f_nscns) | ||
| 192 | fprintf (stderr, "unexec: %d sections found instead of %d.\n", | ||
| 193 | i, nhdr.fhdr.f_nscns); | ||
| 194 | #endif | ||
| 195 | 193 | ||
| 196 | 194 | ||
| 197 | pagesize = getpagesize (); | 195 | pagesize = getpagesize (); |
| @@ -212,17 +210,26 @@ unexec (new_name, a_name, data_start, bss_start, entry_address) | |||
| 212 | nhdr.aout.entry = entry_address; | 210 | nhdr.aout.entry = entry_address; |
| 213 | 211 | ||
| 214 | nhdr.aout.bss_start = nhdr.aout.data_start + nhdr.aout.dsize; | 212 | nhdr.aout.bss_start = nhdr.aout.data_start + nhdr.aout.dsize; |
| 215 | rdata_section->s_size = data_start - DATA_START; | ||
| 216 | 213 | ||
| 217 | /* Adjust start and virtual addresses of rdata_section, too. */ | 214 | if (rdata_section != NULL) |
| 218 | rdata_section->s_vaddr = DATA_START; | 215 | { |
| 219 | rdata_section->s_paddr = DATA_START; | 216 | rdata_section->s_size = data_start - DATA_START; |
| 220 | rdata_section->s_scnptr = text_section->s_scnptr + nhdr.aout.tsize; | 217 | |
| 218 | /* Adjust start and virtual addresses of rdata_section, too. */ | ||
| 219 | rdata_section->s_vaddr = DATA_START; | ||
| 220 | rdata_section->s_paddr = DATA_START; | ||
| 221 | rdata_section->s_scnptr = text_section->s_scnptr + nhdr.aout.tsize; | ||
| 222 | } | ||
| 221 | 223 | ||
| 222 | data_section->s_vaddr = data_start; | 224 | data_section->s_vaddr = data_start; |
| 223 | data_section->s_paddr = data_start; | 225 | data_section->s_paddr = data_start; |
| 224 | data_section->s_size = brk - data_start; | 226 | data_section->s_size = brk - data_start; |
| 225 | data_section->s_scnptr = rdata_section->s_scnptr + rdata_section->s_size; | 227 | |
| 228 | if (rdata_section != NULL) | ||
| 229 | { | ||
| 230 | data_section->s_scnptr = rdata_section->s_scnptr + rdata_section->s_size; | ||
| 231 | } | ||
| 232 | |||
| 226 | vaddr = data_section->s_vaddr + data_section->s_size; | 233 | vaddr = data_section->s_vaddr + data_section->s_size; |
| 227 | scnptr = data_section->s_scnptr + data_section->s_size; | 234 | scnptr = data_section->s_scnptr + data_section->s_size; |
| 228 | if (lit8_section != NULL) | 235 | if (lit8_section != NULL) |
| @@ -320,7 +327,7 @@ unexec (new_name, a_name, data_start, bss_start, entry_address) | |||
| 320 | 327 | ||
| 321 | /* Not needed for now */ | 328 | /* Not needed for now */ |
| 322 | 329 | ||
| 323 | update_dynamic_symbols (oldptr, new, newsyms, | 330 | update_dynamic_symbols (oldptr, new_name, new, newsyms, |
| 324 | ((pHDRR) (oldptr + ohdr.fhdr.f_symptr))->issExtMax, | 331 | ((pHDRR) (oldptr + ohdr.fhdr.f_symptr))->issExtMax, |
| 325 | ((pHDRR) (oldptr + ohdr.fhdr.f_symptr))->cbExtOffset, | 332 | ((pHDRR) (oldptr + ohdr.fhdr.f_symptr))->cbExtOffset, |
| 326 | ((pHDRR) (oldptr + ohdr.fhdr.f_symptr))->cbSsExtOffset); | 333 | ((pHDRR) (oldptr + ohdr.fhdr.f_symptr))->cbSsExtOffset); |
| @@ -352,13 +359,14 @@ unexec (new_name, a_name, data_start, bss_start, entry_address) | |||
| 352 | */ | 359 | */ |
| 353 | 360 | ||
| 354 | 361 | ||
| 355 | update_dynamic_symbols (old, new, newsyms, nsyms, symoff, stroff) | 362 | update_dynamic_symbols (old, new_name, new, newsyms, nsyms, symoff, stroff) |
| 356 | char *old; /* Pointer to old executable */ | 363 | char *old; /* Pointer to old executable */ |
| 357 | int new; /* File descriptor for new executable */ | 364 | char *new_name; /* Name of new executable */ |
| 358 | long newsyms; /* Offset of Symbol table in new executable */ | 365 | int new; /* File descriptor for new executable */ |
| 359 | int nsyms; /* Number of symbol table entries */ | 366 | long newsyms; /* Offset of Symbol table in new executable */ |
| 360 | long symoff; /* Offset of External Symbols in old file */ | 367 | int nsyms; /* Number of symbol table entries */ |
| 361 | long stroff; /* Offset of string table in old file */ | 368 | long symoff; /* Offset of External Symbols in old file */ |
| 369 | long stroff; /* Offset of string table in old file */ | ||
| 362 | { | 370 | { |
| 363 | long i; | 371 | long i; |
| 364 | int found = 0; | 372 | int found = 0; |
| @@ -383,7 +391,7 @@ long stroff; /* Offset of string table in old file */ | |||
| 383 | n_edata.asym.value = Brk; | 391 | n_edata.asym.value = Brk; |
| 384 | SEEK (new, newsyms + cbHDRR + i, | 392 | SEEK (new, newsyms + cbHDRR + i, |
| 385 | "seeking to symbol _edata in %s", new_name); | 393 | "seeking to symbol _edata in %s", new_name); |
| 386 | WRITE (new, n_edata, cbEXTR, | 394 | WRITE (new, &n_edata, cbEXTR, |
| 387 | "writing symbol table entry for _edata into %s", new_name); | 395 | "writing symbol table entry for _edata into %s", new_name); |
| 388 | } | 396 | } |
| 389 | else if (!strcmp(s,"_end")) | 397 | else if (!strcmp(s,"_end")) |
| @@ -393,7 +401,7 @@ long stroff; /* Offset of string table in old file */ | |||
| 393 | n_end.asym.value = Brk; | 401 | n_end.asym.value = Brk; |
| 394 | SEEK (new, newsyms + cbHDRR + i, | 402 | SEEK (new, newsyms + cbHDRR + i, |
| 395 | "seeking to symbol _end in %s", new_name); | 403 | "seeking to symbol _end in %s", new_name); |
| 396 | WRITE (new, n_end, cbEXTR, | 404 | WRITE (new, &n_end, cbEXTR, |
| 397 | "writing symbol table entry for _end into %s", new_name); | 405 | "writing symbol table entry for _end into %s", new_name); |
| 398 | } | 406 | } |
| 399 | } | 407 | } |
| @@ -425,6 +433,7 @@ mark_x (name) | |||
| 425 | 433 | ||
| 426 | static void | 434 | static void |
| 427 | fatal_unexec (s, va_alist) | 435 | fatal_unexec (s, va_alist) |
| 436 | char *s; | ||
| 428 | va_dcl | 437 | va_dcl |
| 429 | { | 438 | { |
| 430 | va_list ap; | 439 | va_list ap; |
| @@ -437,4 +446,3 @@ fatal_unexec (s, va_alist) | |||
| 437 | fputs (".\n", stderr); | 446 | fputs (".\n", stderr); |
| 438 | exit (1); | 447 | exit (1); |
| 439 | } | 448 | } |
| 440 | |||