comparison src/unexelfsgi.c @ 253:157b30c96d03 r20-5b25

Import from CVS: tag r20-5b25
author cvs
date Mon, 13 Aug 2007 10:20:27 +0200
parents 85ec50267440
children ca9a9ec9c1c1
comparison
equal deleted inserted replaced
252:afb15df44434 253:157b30c96d03
496 #include <fcntl.h> 496 #include <fcntl.h>
497 #include <elf.h> 497 #include <elf.h>
498 #include <sym.h> /* for HDRR declaration */ 498 #include <sym.h> /* for HDRR declaration */
499 #include <sys/mman.h> 499 #include <sys/mman.h>
500 #include <config.h> 500 #include <config.h>
501 #include "sysdep.h" 501 #include "lisp.h"
502 502
503 /* in 64bits mode, use 64bits elf */ 503 /* in 64bits mode, use 64bits elf */
504 #ifdef _ABI64 504 #ifdef _ABI64
505 typedef Elf64_Shdr l_Elf_Shdr; 505 typedef Elf64_Shdr l_Elf_Shdr;
506 typedef Elf64_Phdr l_Elf_Phdr; 506 typedef Elf64_Phdr l_Elf_Phdr;
518 typedef Elf32_Off l_Elf_Off; 518 typedef Elf32_Off l_Elf_Off;
519 typedef Elf32_Sym l_Elf_Sym; 519 typedef Elf32_Sym l_Elf_Sym;
520 #endif 520 #endif
521 521
522 522
523 #ifndef emacs
524 #define fatal(a, b, c) fprintf(stderr, a, b, c), exit(1)
525 #else
526 extern void fatal(char *, ...);
527 #endif
528
529 /* Get the address of a particular section or program header entry, 523 /* Get the address of a particular section or program header entry,
530 * accounting for the size of the entries. 524 * accounting for the size of the entries.
531 */ 525 */
532 526
533 #define OLD_SECTION_H(n) \ 527 #define OLD_SECTION_H(n) \
603 * 597 *
604 * In ELF, this works by replacing the old .bss section with a new 598 * In ELF, this works by replacing the old .bss section with a new
605 * .data section, and inserting an empty .bss immediately afterwards. 599 * .data section, and inserting an empty .bss immediately afterwards.
606 * 600 *
607 */ 601 */
608 void 602 int
609 unexec (new_name, old_name, data_start, bss_start, entry_address) 603 unexec (new_name, old_name, data_start, bss_start, entry_address)
610 char *new_name, *old_name; 604 char *new_name, *old_name;
611 uintptr_t data_start, bss_start, entry_address; 605 uintptr_t data_start, bss_start, entry_address;
612 { 606 {
613 extern uintptr_t bss_end; 607 extern uintptr_t bss_end;
1009 n = umask (777); 1003 n = umask (777);
1010 umask (n); 1004 umask (n);
1011 stat_buf.st_mode |= 0111 & ~n; 1005 stat_buf.st_mode |= 0111 & ~n;
1012 if (chmod (new_name, stat_buf.st_mode) == -1) 1006 if (chmod (new_name, stat_buf.st_mode) == -1)
1013 fatal ("Can't chmod (%s): errno %d\n", new_name, errno); 1007 fatal ("Can't chmod (%s): errno %d\n", new_name, errno);
1008
1009 return 0;
1014 } 1010 }