Mercurial > emacs
comparison src/unexelf.c @ 19201:f502f8e2322a
(unexec): Cast 1st arg in mmap calls.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 07 Aug 1997 03:52:11 +0000 |
parents | ee209ce34d8a |
children | 6910bd6de0d9 |
comparison
equal
deleted
inserted
replaced
19200:74ec766c0ada | 19201:f502f8e2322a |
---|---|
31 * University of Utah | 31 * University of Utah |
32 * Date: Tue Mar 2 1982 | 32 * Date: Tue Mar 2 1982 |
33 * Modified heavily since then. | 33 * Modified heavily since then. |
34 * | 34 * |
35 * Synopsis: | 35 * Synopsis: |
36 * unexec (new_name, a_name, data_start, bss_start, entry_address) | 36 * unexec (new_name, old_name, data_start, bss_start, entry_address) |
37 * char *new_name, *a_name; | 37 * char *new_name, *old_name; |
38 * unsigned data_start, bss_start, entry_address; | 38 * unsigned data_start, bss_start, entry_address; |
39 * | 39 * |
40 * Takes a snapshot of the program and makes an a.out format file in the | 40 * Takes a snapshot of the program and makes an a.out format file in the |
41 * file named by the string argument new_name. | 41 * file named by the string argument new_name. |
42 * If a_name is non-NULL, the symbol table will be taken from the given file. | 42 * If old_name is non-NULL, the symbol table will be taken from the given file. |
43 * On some machines, an existing a_name file is required. | 43 * On some machines, an existing old_name file is required. |
44 * | 44 * |
45 * The boundaries within the a.out file may be adjusted with the data_start | 45 * The boundaries within the a.out file may be adjusted with the data_start |
46 * and bss_start arguments. Either or both may be given as 0 for defaults. | 46 * and bss_start arguments. Either or both may be given as 0 for defaults. |
47 * | 47 * |
48 * Data_start gives the boundary between the text segment and the data | 48 * Data_start gives the boundary between the text segment and the data |
598 fatal ("Can't open %s for reading: errno %d\n", old_name, errno); | 598 fatal ("Can't open %s for reading: errno %d\n", old_name, errno); |
599 | 599 |
600 if (fstat (old_file, &stat_buf) == -1) | 600 if (fstat (old_file, &stat_buf) == -1) |
601 fatal ("Can't fstat (%s): errno %d\n", old_name, errno); | 601 fatal ("Can't fstat (%s): errno %d\n", old_name, errno); |
602 | 602 |
603 old_base = mmap (0, stat_buf.st_size, PROT_READ, MAP_SHARED, old_file, 0); | 603 old_base = mmap ((caddr_t) 0, stat_buf.st_size, PROT_READ, MAP_SHARED, |
604 old_file, 0); | |
604 | 605 |
605 if (old_base == (caddr_t) -1) | 606 if (old_base == (caddr_t) -1) |
606 fatal ("Can't mmap (%s): errno %d\n", old_name, errno); | 607 fatal ("Can't mmap (%s): errno %d\n", old_name, errno); |
607 | 608 |
608 #ifdef DEBUG | 609 #ifdef DEBUG |
718 | 719 |
719 if (ftruncate (new_file, new_file_size)) | 720 if (ftruncate (new_file, new_file_size)) |
720 fatal ("Can't ftruncate (%s): errno %d\n", new_name, errno); | 721 fatal ("Can't ftruncate (%s): errno %d\n", new_name, errno); |
721 | 722 |
722 #ifdef UNEXEC_USE_MAP_PRIVATE | 723 #ifdef UNEXEC_USE_MAP_PRIVATE |
723 new_base = mmap (0, new_file_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, | 724 new_base = mmap ((caddr_t) 0, new_file_size, PROT_READ | PROT_WRITE, |
724 new_file, 0); | 725 MAP_PRIVATE, new_file, 0); |
725 #else | 726 #else |
726 new_base = mmap (0, new_file_size, PROT_READ | PROT_WRITE, MAP_SHARED, | 727 new_base = mmap ((caddr_t) 0, new_file_size, PROT_READ | PROT_WRITE, |
727 new_file, 0); | 728 MAP_SHARED, new_file, 0); |
728 #endif | 729 #endif |
729 | 730 |
730 if (new_base == (caddr_t) -1) | 731 if (new_base == (caddr_t) -1) |
731 fatal ("Can't mmap (%s): errno %d\n", new_name, errno); | 732 fatal ("Can't mmap (%s): errno %d\n", new_name, errno); |
732 | 733 |