emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/unexec.c


From: Eli Zaretskii
Subject: [Emacs-diffs] Changes to emacs/src/unexec.c
Date: Sat, 19 Mar 2005 06:51:13 -0500

Index: emacs/src/unexec.c
diff -c emacs/src/unexec.c:1.37 emacs/src/unexec.c:1.38
*** emacs/src/unexec.c:1.37     Mon Sep  1 15:45:57 2003
--- emacs/src/unexec.c  Sat Mar 19 11:51:13 2005
***************
*** 368,415 ****
  static void mark_x ();
  
  /* ****************************************************************
-  * unexec
-  *
-  * driving logic.
-  */
- unexec (new_name, a_name, data_start, bss_start, entry_address)
-      char *new_name, *a_name;
-      unsigned data_start, bss_start, entry_address;
- {
-   int new, a_out = -1;
- 
-   if (a_name && (a_out = open (a_name, O_RDONLY)) < 0)
-     {
-       PERROR (a_name);
-     }
-   if ((new = creat (new_name, 0666)) < 0)
-     {
-       PERROR (new_name);
-     }
- 
-   if (make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, 
new_name) < 0
-       || copy_text_and_data (new, a_out) < 0
-       || copy_sym (new, a_out, a_name, new_name) < 0
- #ifdef COFF
- #ifndef COFF_BSD_SYMBOLS
-       || adjust_lnnoptrs (new, a_out, new_name) < 0
- #endif
- #endif
-       )
-     {
-       close (new);
-       /* unlink (new_name);           /* Failed, unlink new a.out */
-       return -1;
-     }
- 
-   close (new);
-   if (a_out >= 0)
-     close (a_out);
-   mark_x (new_name);
-   return 0;
- }
- 
- /* ****************************************************************
   * make_hdr
   *
   * Make the header in the new a.out from the header in core.
--- 368,373 ----
***************
*** 835,840 ****
--- 793,853 ----
  #endif /* not COFF */
  }
  
+ write_segment (new, ptr, end)
+      int new;
+      register char *ptr, *end;
+ {
+   register int i, nwrite, ret;
+   char buf[80];
+ #ifndef USE_CRT_DLL
+   extern int errno;
+ #endif
+   /* This is the normal amount to write at once.
+      It is the size of block that NFS uses.  */
+   int writesize = 1 << 13;
+   int pagesize = getpagesize ();
+   char zeros[1 << 13];
+ 
+   bzero (zeros, sizeof (zeros));
+ 
+   for (i = 0; ptr < end;)
+     {
+       /* Distance to next multiple of writesize.  */
+       nwrite = (((int) ptr + writesize) & -writesize) - (int) ptr;
+       /* But not beyond specified end.  */
+       if (nwrite > end - ptr) nwrite = end - ptr;
+       ret = write (new, ptr, nwrite);
+       /* If write gets a page fault, it means we reached
+        a gap between the old text segment and the old data segment.
+        This gap has probably been remapped into part of the text segment.
+        So write zeros for it.  */
+       if (ret == -1
+ #ifdef EFAULT
+         && errno == EFAULT
+ #endif
+         )
+       {
+         /* Write only a page of zeros at once,
+            so that we we don't overshoot the start
+            of the valid memory in the old data segment.  */
+         if (nwrite > pagesize)
+           nwrite = pagesize;
+         write (new, zeros, nwrite);
+       }
+ #if 0 /* Now that we have can ask `write' to write more than a page,
+        it is legit for write do less than the whole amount specified.  */
+       else if (nwrite != ret)
+       {
+         sprintf (buf,
+                  "unexec write failure: addr 0x%x, fileno %d, size 0x%x, 
wrote 0x%x, errno %d",
+                  ptr, new, nwrite, ret, errno);
+         PERROR (buf);
+       }
+ #endif
+       i += nwrite;
+       ptr += nwrite;
+     }
+ }
  /* ****************************************************************
   * copy_text_and_data
   *
***************
*** 1060,1121 ****
  
    return 0;
  }
- 
- write_segment (new, ptr, end)
-      int new;
-      register char *ptr, *end;
- {
-   register int i, nwrite, ret;
-   char buf[80];
- #ifndef USE_CRT_DLL
-   extern int errno;
- #endif
-   /* This is the normal amount to write at once.
-      It is the size of block that NFS uses.  */
-   int writesize = 1 << 13;
-   int pagesize = getpagesize ();
-   char zeros[1 << 13];
- 
-   bzero (zeros, sizeof (zeros));
- 
-   for (i = 0; ptr < end;)
-     {
-       /* Distance to next multiple of writesize.  */
-       nwrite = (((int) ptr + writesize) & -writesize) - (int) ptr;
-       /* But not beyond specified end.  */
-       if (nwrite > end - ptr) nwrite = end - ptr;
-       ret = write (new, ptr, nwrite);
-       /* If write gets a page fault, it means we reached
-        a gap between the old text segment and the old data segment.
-        This gap has probably been remapped into part of the text segment.
-        So write zeros for it.  */
-       if (ret == -1
- #ifdef EFAULT
-         && errno == EFAULT
- #endif
-         )
-       {
-         /* Write only a page of zeros at once,
-            so that we we don't overshoot the start
-            of the valid memory in the old data segment.  */
-         if (nwrite > pagesize)
-           nwrite = pagesize;
-         write (new, zeros, nwrite);
-       }
- #if 0 /* Now that we have can ask `write' to write more than a page,
-        it is legit for write do less than the whole amount specified.  */
-       else if (nwrite != ret)
-       {
-         sprintf (buf,
-                  "unexec write failure: addr 0x%x, fileno %d, size 0x%x, 
wrote 0x%x, errno %d",
-                  ptr, new, nwrite, ret, errno);
-         PERROR (buf);
-       }
- #endif
-       i += nwrite;
-       ptr += nwrite;
-     }
- }
  
  /* ****************************************************************
   * copy_sym
--- 1073,1078 ----
***************
*** 1264,1269 ****
--- 1221,1268 ----
  
  #endif /* COFF */
  
+ /* ****************************************************************
+  * unexec
+  *
+  * driving logic.
+  */
+ unexec (new_name, a_name, data_start, bss_start, entry_address)
+      char *new_name, *a_name;
+      unsigned data_start, bss_start, entry_address;
+ {
+   int new, a_out = -1;
+ 
+   if (a_name && (a_out = open (a_name, O_RDONLY)) < 0)
+     {
+       PERROR (a_name);
+     }
+   if ((new = creat (new_name, 0666)) < 0)
+     {
+       PERROR (new_name);
+     }
+ 
+   if (make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, 
new_name) < 0
+       || copy_text_and_data (new, a_out) < 0
+       || copy_sym (new, a_out, a_name, new_name) < 0
+ #ifdef COFF
+ #ifndef COFF_BSD_SYMBOLS
+       || adjust_lnnoptrs (new, a_out, new_name) < 0
+ #endif
+ #endif
+       )
+     {
+       close (new);
+       /* unlink (new_name);           /* Failed, unlink new a.out */
+       return -1;
+     }
+ 
+   close (new);
+   if (a_out >= 0)
+     close (a_out);
+   mark_x (new_name);
+   return 0;
+ }
+ 
  #endif /* not CANNOT_DUMP */
  
  /* arch-tag: 62409b69-e27a-4a7c-9413-0210d6b54e7f




reply via email to

[Prev in Thread] Current Thread [Next in Thread]