]> git.eshelyaron.com Git - emacs.git/commitdiff
(unexec) [UNEXEC_USE_MAP_PRIVATE]: New logic for
authorKarl Heuer <kwzh@gnu.org>
Tue, 16 May 1995 01:46:20 +0000 (01:46 +0000)
committerKarl Heuer <kwzh@gnu.org>
Tue, 16 May 1995 01:46:20 +0000 (01:46 +0000)
systems that don't support MAP_SHARED with PROT_WRITE.

src/unexelf.c

index edfaedb1dd213dc8710704170292f98969e723d6..c61f4c368f18d45085bae59327261d351d073742 100644 (file)
@@ -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))