Mercurial > emacs
changeset 11827:16a95d5d252e
(unexec) [UNEXEC_USE_MAP_PRIVATE]: New logic for
systems that don't support MAP_SHARED with PROT_WRITE.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 16 May 1995 01:46:20 +0000 |
parents | 6197ce4cd509 |
children | cb6c1026a0f7 |
files | src/unexelf.c |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/unexelf.c Tue May 16 01:33:12 1995 +0000 +++ b/src/unexelf.c Tue May 16 01:46:20 1995 +0000 @@ -583,8 +583,13 @@ if (ftruncate (new_file, new_file_size)) fatal ("Can't ftruncate (%s): errno %d\n", new_name, errno); +#ifdef UNEXEC_USE_MAP_PRIVATE + new_base = mmap (0, new_file_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, + new_file, 0); +#else new_base = mmap (0, new_file_size, PROT_READ | PROT_WRITE, MAP_SHARED, new_file, 0); +#endif if (new_base == (caddr_t) -1) fatal ("Can't mmap (%s): errno %d\n", new_name, errno); @@ -802,6 +807,14 @@ memcpy (&symp->st_value, &new_bss_addr, sizeof (new_bss_addr)); } +#ifdef UNEXEC_USE_MAP_PRIVATE + if (lseek (new_file, 0, SEEK_SET) == -1) + fatal ("Can't rewind (%s): errno %d\n", new_name, errno); + + if (write (new_file, new_base, new_file_size) != new_file_size) + fatal ("Can't write (%s): errno %d\n", new_name, errno); +#endif + /* Close the files and make the new file executable. */ if (close (old_file))