$(MAKE) -C $(libsrc) make-fingerprint$(EXEEXT)
fingerprint.c: temacs.in$(EXEEXT) $(libsrc)/make-fingerprint$(EXEEXT)
- $(libsrc)/make-fingerprint$(EXEEXT) temacs.in$(EEXIST) > fingerprint.c
+ $(libsrc)/make-fingerprint$(EXEEXT) temacs.in$(EXEEXT) > fingerprint.c
## We have to create $(etc) here because init_cmdargs tests its
## existence when setting Vinstallation_directory (FIXME?).
XFLOAT (f)->u.data = n;
}
+#ifdef DOUG_LEA_MALLOC
static bool
pointers_fit_in_lispobj_p (void)
{
regions. */
return pointers_fit_in_lispobj_p () && !will_dump_with_unexec_p ();
}
+#endif
/* Head of a circularly-linked list of extant finalizers. */
struct Lisp_Finalizer finalizers;
ptrdiff_t len;
#ifdef USE_MMAP_FOR_BUFFERS
- if (dumped_with_unexec)
+ if (dumped_with_unexec_p ())
{
struct buffer *b;
ATTRIBUTE_UNUSED
static bool
-string_starts_with_p(const char* string, const char* prefix)
+string_starts_with_p (const char* string, const char* prefix)
{
- return strncmp(string, prefix, strlen(prefix)) == 0;
+ return strncmp (string, prefix, strlen (prefix)) == 0;
}
#ifdef HAVE_PDUMPER
/* Figure out where we are. Fancy filesystem functions aren't
available at this point, so use pure text manipulation. */
const char *argv0_base = strrchr (argv[0], DIRECTORY_SEP);
+#ifdef WINDOWSNT
+ /* Consider backslashes and the .exe extension. */
+ const char *argv0_alt = strrchr (argv[0], '\\');
+
+ if (argv0_alt > argv0_base)
+ argv0_base = argv0_alt;
+ argv0_base = argv0_base ? argv0_base + 1 : argv[0];
+ bool is_temacs =
+ c_strncasecmp ("temacs", argv0_base, 6) == 0
+ && strlen (argv0_base) >= 4
+ && c_strcasecmp (argv0_base + strlen (argv0_base) - 4, ".exe") == 0;
+#else
argv0_base = argv0_base ? argv0_base + 1 : argv[0];
bool is_temacs = strcmp ("temacs", argv0_base) == 0;
+#endif
const char *loaded_dump = NULL;
const char *dump_mode = NULL;
that causes an infinite recursive loop with FreeBSD. See
Bug#14569. The part of this bug involving Cygwin is no longer
relevant, now that Cygwin defines HYBRID_MALLOC. */
- if (!noninteractive || !will_dump)
+ if (!noninteractive || !will_dump_p ())
malloc_enable_thread ();
#endif
bool module_assertions
= argmatch (argv, argc, "-module-assertions", "--module-assertions", 15,
NULL, &skip_args);
- if (dumping && module_assertions)
+ if (will_dump_p () && module_assertions)
{
fputs ("Module assertions are not supported during dumping\n", stderr);
exit (1);
variables from the parent process without modifications from
Emacs. */
init_environment (argv);
- init_ntproc (will_dump); /* must precede init_editfns. */
+ init_ntproc (will_dump_p ()); /* must precede init_editfns. */
#endif
/* AIX crashes are reported in system versions 3.2.3 and 3.2.4
# define MAP_POPULATE 0
# endif
#elif defined (WINDOWSNT)
+ /* Use a float infinity, to avoid compiler warnings in comparing vs
+ candidates' score. */
+# undef INFINITY
+# define INFINITY __builtin_inff ()
# include <windows.h>
# define VM_SUPPORTED VM_MS_WINDOWS
#else
dump_emacs_reloc_to_dump_ptr_raw (ctx, &charset_table, offset);
dump_emacs_reloc_immediate_int (
ctx, &charset_table_used, charset_table_used);
- dump_emacs_reloc_immediate_emacs_int (
+ dump_emacs_reloc_immediate_ptrdiff_t (
ctx, &charset_table_size, charset_table_used);
return offset;
}
HANDLE file;
uint64_t full_offset = offset;
- uint32_t size_high = (uint32_t) (full_offset >> 32);
- uint32_t size_low = (uint32_t) full_offset;
+ uint32_t offset_high = (uint32_t) (full_offset >> 32);
+ uint32_t offset_low = (uint32_t) (full_offset & 0xffffffff);
- file = (HANDLE) __get_osfhandle (fd);
+ int error;
+ DWORD map_access;
+
+ file = (HANDLE) _get_osfhandle (fd);
if (file == INVALID_HANDLE_VALUE)
goto out;
goto out;
}
- DWORD map_access;
-
switch (protection)
{
case DUMP_MEMORY_ACCESS_NONE:
size,
base);
- int error = GetLastError ();
+ error = GetLastError ();
if (ret == NULL)
errno = (error == ERROR_INVALID_ADDRESS ? EBUSY : EPERM);
out:
if (resv)
dump_anonymous_release (resv, total_size);
if (!ret)
- for (int i = 0; i < nr_maps; ++i)
- if (VM_SUPPORTED == VM_MS_WINDOWS)
- dump_mmap_reset (&maps[i]);
- else
- dump_mmap_release (&maps[i]);
+ {
+ for (int i = 0; i < nr_maps; ++i)
+ {
+ if (VM_SUPPORTED == VM_MS_WINDOWS)
+ dump_mmap_reset (&maps[i]);
+ else
+ dump_mmap_release (&maps[i]);
+ }
+ }
return ret;
}
#else /* not HAVE_STACK_OVERFLOW_HANDLING or WINDOWSNT */
-static bool
+bool
init_sigsegv (void)
{
return 0;
LPDWORD HeaderSum,
LPDWORD CheckSum);
-extern BOOL ctrl_c_handler (unsigned long type);
-
extern char my_begdata[];
extern char my_begbss[];
extern char *my_begbss_static;
DWORD_PTR bss_size_static = 0;
DWORD_PTR extra_bss_size_static = 0;
-/* MinGW64 doesn't add a leading underscore to external symbols,
- whereas configure.ac sets up LD_SWITCH_SYSTEM_TEMACS to force the
- entry point at __start, with two underscores. */
-#ifdef __MINGW64__
-#define _start __start
-#endif
-
-extern void mainCRTStartup (void);
-
-/* Startup code for running on NT. When we are running as the dumped
- version, we need to bootstrap our heap and .bss section into our
- address space before we can actually hand off control to the startup
- code supplied by NT (primarily because that code relies upon malloc ()). */
-void _start (void);
-
-void
-_start (void)
-{
-
-#if 1
- /* Give us a way to debug problems with crashes on startup when
- running under the MSVC profiler. */
- if (GetEnvironmentVariable ("EMACS_DEBUG", NULL, 0) > 0)
- DebugBreak ();
-#endif
-
- /* Cache system info, e.g., the NT page size. */
- cache_system_info ();
-
- /* Grab our malloc arena space now, before CRT starts up. */
- init_heap ();
-
- /* This prevents ctrl-c's in shells running while we're suspended from
- having us exit. */
- SetConsoleCtrlHandler ((PHANDLER_ROUTINE) ctrl_c_handler, TRUE);
-
- /* Prevent Emacs from being locked up (eg. in batch mode) when
- accessing devices that aren't mounted (eg. removable media drives). */
- SetErrorMode (SEM_FAILCRITICALERRORS);
- mainCRTStartup ();
-}
-
-
/* File handling. */
/* Implementation note: this and the next functions work with ANSI
codepage encoded file names! */
-int
-open_input_file (file_data *p_file, char *filename)
-{
- HANDLE file;
- HANDLE file_mapping;
- void *file_base;
- unsigned long size, upper_size;
-
- file = CreateFileA (filename, GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
- if (file == INVALID_HANDLE_VALUE)
- return FALSE;
-
- size = GetFileSize (file, &upper_size);
- file_mapping = CreateFileMapping (file, NULL, PAGE_READONLY,
- 0, size, NULL);
- if (!file_mapping)
- return FALSE;
-
- file_base = MapViewOfFile (file_mapping, FILE_MAP_READ, 0, 0, size);
- if (file_base == 0)
- return FALSE;
-
- p_file->name = filename;
- p_file->size = size;
- p_file->file = file;
- p_file->file_mapping = file_mapping;
- p_file->file_base = file_base;
-
- return TRUE;
-}
int
open_output_file (file_data *p_file, char *filename, unsigned long size)
return TRUE;
}
-/* Close the system structures associated with the given file. */
-void
-close_file_data (file_data *p_file)
-{
- UnmapViewOfFile (p_file->file_base);
- CloseHandle (p_file->file_mapping);
- /* For the case of output files, set final size. */
- SetFilePointer (p_file->file, p_file->size, NULL, FILE_BEGIN);
- SetEndOfFile (p_file->file);
- CloseHandle (p_file->file);
-}
-
/* Routines to manipulate NT executable file sections. */
return NULL;
}
-/* Return pointer to section header for section containing the given
- relative virtual address. */
-IMAGE_SECTION_HEADER *
-rva_to_section (DWORD_PTR rva, IMAGE_NT_HEADERS * nt_header)
-{
- PIMAGE_SECTION_HEADER section;
- int i;
-
- section = IMAGE_FIRST_SECTION (nt_header);
-
- for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++)
- {
- /* Some linkers (eg. the NT SDK linker I believe) swapped the
- meaning of these two values - or rather, they ignored
- VirtualSize entirely and always set it to zero. This affects
- some very old exes (eg. gzip dated Dec 1993). Since
- w32_executable_type relies on this function to work reliably,
- we need to cope with this. */
- DWORD_PTR real_size = max (section->SizeOfRawData,
- section->Misc.VirtualSize);
- if (rva >= section->VirtualAddress
- && rva < section->VirtualAddress + real_size)
- return section;
- section++;
- }
- return NULL;
-}
-
#if 0 /* unused */
/* Return pointer to section header for section containing the given
offset in its raw data area. */
typedef WINBASEAPI BOOL (WINAPI * HeapSetInformation_Proc)(HANDLE,HEAP_INFORMATION_CLASS,PVOID,SIZE_T);
#endif
+#ifdef HAVE_PDUMPER
+BOOL using_dynamic_heap = FALSE;
+#endif
+
void
init_heap (void)
{
+#ifdef HAVE_PDUMPER
+ using_dynamic_heap = TRUE;
+#endif
if (using_dynamic_heap)
{
#ifndef MINGW_W64
static CRITICAL_SECTION crit_sig;
+
+extern BOOL ctrl_c_handler (unsigned long type);
+
+/* MinGW64 doesn't add a leading underscore to external symbols,
+ whereas configure.ac sets up LD_SWITCH_SYSTEM_TEMACS to force the
+ entry point at __start, with two underscores. */
+#ifdef __MINGW64__
+#define _start __start
+#endif
+
+extern void mainCRTStartup (void);
+
+/* Startup code for running on NT. When we are running as the dumped
+ version, we need to bootstrap our heap and .bss section into our
+ address space before we can actually hand off control to the startup
+ code supplied by NT (primarily because that code relies upon malloc ()). */
+void _start (void);
+
+void
+_start (void)
+{
+
+#if 1
+ /* Give us a way to debug problems with crashes on startup when
+ running under the MSVC profiler. */
+ if (GetEnvironmentVariable ("EMACS_DEBUG", NULL, 0) > 0)
+ DebugBreak ();
+#endif
+
+ /* Cache system info, e.g., the NT page size. */
+ cache_system_info ();
+
+ /* Grab our malloc arena space now, before CRT starts up. */
+ init_heap ();
+
+ /* This prevents ctrl-c's in shells running while we're suspended from
+ having us exit. */
+ SetConsoleCtrlHandler ((PHANDLER_ROUTINE) ctrl_c_handler, TRUE);
+
+ /* Prevent Emacs from being locked up (eg. in batch mode) when
+ accessing devices that aren't mounted (eg. removable media drives). */
+ SetErrorMode (SEM_FAILCRITICALERRORS);
+ mainCRTStartup ();
+}
+
/* Improve on the CRT 'signal' implementation so that we could record
the SIGCHLD handler and fake interval timers. */
signal_handler
return pid;
}
+int
+open_input_file (file_data *p_file, char *filename)
+{
+ HANDLE file;
+ HANDLE file_mapping;
+ void *file_base;
+ unsigned long size, upper_size;
+
+ file = CreateFileA (filename, GENERIC_READ, FILE_SHARE_READ, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
+ if (file == INVALID_HANDLE_VALUE)
+ return FALSE;
+
+ size = GetFileSize (file, &upper_size);
+ file_mapping = CreateFileMapping (file, NULL, PAGE_READONLY,
+ 0, size, NULL);
+ if (!file_mapping)
+ return FALSE;
+
+ file_base = MapViewOfFile (file_mapping, FILE_MAP_READ, 0, 0, size);
+ if (file_base == 0)
+ return FALSE;
+
+ p_file->name = filename;
+ p_file->size = size;
+ p_file->file = file;
+ p_file->file_mapping = file_mapping;
+ p_file->file_base = file_base;
+
+ return TRUE;
+}
+
+/* Return pointer to section header for section containing the given
+ relative virtual address. */
+IMAGE_SECTION_HEADER *
+rva_to_section (DWORD_PTR rva, IMAGE_NT_HEADERS * nt_header)
+{
+ PIMAGE_SECTION_HEADER section;
+ int i;
+
+ section = IMAGE_FIRST_SECTION (nt_header);
+
+ for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++)
+ {
+ /* Some linkers (eg. the NT SDK linker I believe) swapped the
+ meaning of these two values - or rather, they ignored
+ VirtualSize entirely and always set it to zero. This affects
+ some very old exes (eg. gzip dated Dec 1993). Since
+ w32_executable_type relies on this function to work reliably,
+ we need to cope with this. */
+ DWORD_PTR real_size = max (section->SizeOfRawData,
+ section->Misc.VirtualSize);
+ if (rva >= section->VirtualAddress
+ && rva < section->VirtualAddress + real_size)
+ return section;
+ section++;
+ }
+ return NULL;
+}
+
+/* Close the system structures associated with the given file. */
+void
+close_file_data (file_data *p_file)
+{
+ UnmapViewOfFile (p_file->file_base);
+ CloseHandle (p_file->file_mapping);
+ /* For the case of output files, set final size. */
+ SetFilePointer (p_file->file, p_file->size, NULL, FILE_BEGIN);
+ SetEndOfFile (p_file->file);
+ CloseHandle (p_file->file);
+}
+
/* Old versions of w32api headers don't have separate 32-bit and
64-bit defines, but the one they have matches the 32-bit variety. */
#ifndef IMAGE_NT_OPTIONAL_HDR32_MAGIC