diff options
author | Karl Heuer <kwzh@gnu.org> | 1995-05-16 01:46:20 +0000 |
---|---|---|
committer | Karl Heuer <kwzh@gnu.org> | 1995-05-16 01:46:20 +0000 |
commit | 04f903c09aa37259be40a39eeadf344e1ae7eb1a (patch) | |
tree | 1603c7750265fac20544c0aaec473eeda985ac5f /src/unexelf.c | |
parent | 4dee6d0d08ae33201aa74fc5fb39ca556a0ab7e6 (diff) | |
download | emacs-04f903c09aa37259be40a39eeadf344e1ae7eb1a.tar.gz |
(unexec) [UNEXEC_USE_MAP_PRIVATE]: New logic for
systems that don't support MAP_SHARED with PROT_WRITE.
Diffstat (limited to 'src/unexelf.c')
-rw-r--r-- | src/unexelf.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/unexelf.c b/src/unexelf.c index edfaedb1dd2..c61f4c368f1 100644 --- a/src/unexelf.c +++ b/src/unexelf.c @@ -583,8 +583,13 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) 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 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) 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)) |