diff options
Diffstat (limited to 'src/unexcoff.c')
| -rw-r--r-- | src/unexcoff.c | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/src/unexcoff.c b/src/unexcoff.c index 5ac8ea8c9b0..3f6549003a5 100644 --- a/src/unexcoff.c +++ b/src/unexcoff.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1985-1988, 1992-1994, 2001-2013 Free Software +/* Copyright (C) 1985-1988, 1992-1994, 2001-2015 Free Software * Foundation, Inc. This file is part of GNU Emacs. @@ -65,6 +65,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <crt0.h> /* for _crt0_startup_flags and its bits */ #include <sys/exceptn.h> static int save_djgpp_startup_flags; +#include <libc/atexit.h> +static struct __atexit *save_atexit_ptr; #define filehdr external_filehdr #define scnhdr external_scnhdr #define syment external_syment @@ -82,7 +84,7 @@ struct aouthdr unsigned long text_start;/* base of text used for this file */ unsigned long data_start;/* base of data used for this file */ }; -#endif /* not MSDOS */ +#endif /* MSDOS */ #else /* not HAVE_COFF_H */ #include <a.out.h> #endif /* not HAVE_COFF_H */ @@ -95,7 +97,6 @@ struct aouthdr #include <sys/types.h> #endif /* makedev */ #include <stdio.h> -#include <sys/stat.h> #include <errno.h> #include <sys/file.h> @@ -120,7 +121,7 @@ static int pagemask; into an int which is the number of a byte. This is a no-op on ordinary machines, but not on all. */ -#define ADDR_CORRECT(x) ((char *)(x) - (char*)0) +#define ADDR_CORRECT(x) ((char *) (x) - (char *) 0) #include "lisp.h" @@ -368,6 +369,12 @@ copy_text_and_data (int new, int a_out) and which might change the way that dumped Emacs works. */ save_djgpp_startup_flags = _crt0_startup_flags; _crt0_startup_flags &= ~(_CRT0_FLAG_NO_LFN | _CRT0_FLAG_NEARPTR); + + /* Zero out the 'atexit' chain in the dumped executable, to avoid + calling the atexit functions twice. (emacs.c:main installs an + atexit function.) */ + save_atexit_ptr = __atexit_ptr; + __atexit_ptr = NULL; #endif lseek (new, (long) text_scnptr, 0); @@ -386,6 +393,9 @@ copy_text_and_data (int new, int a_out) /* Restore the startup flags. */ _crt0_startup_flags = save_djgpp_startup_flags; + + /* Restore the atexit chain. */ + __atexit_ptr = save_atexit_ptr; #endif @@ -428,29 +438,6 @@ copy_sym (int new, int a_out, const char *a_name, const char *new_name) return 0; } -/* **************************************************************** - * mark_x - * - * After successfully building the new a.out, mark it executable - */ -static void -mark_x (const char *name) -{ - struct stat sbuf; - int um; - int new = 0; /* for PERROR */ - - um = umask (777); - umask (um); - if (stat (name, &sbuf) == -1) - { - PERROR (name); - } - sbuf.st_mode |= 0111 & ~um; - if (chmod (name, sbuf.st_mode) == -1) - PERROR (name); -} - /* * If the COFF file contains a symbol table and a line number section, @@ -531,7 +518,7 @@ unexec (const char *new_name, const char *a_name) { PERROR (a_name); } - if ((new = emacs_open (new_name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) + if ((new = emacs_open (new_name, O_WRONLY | O_CREAT | O_TRUNC, 0777)) < 0) { PERROR (new_name); } @@ -549,7 +536,6 @@ unexec (const char *new_name, const char *a_name) emacs_close (new); if (a_out >= 0) emacs_close (a_out); - mark_x (new_name); } #endif /* not CANNOT_DUMP */ |
