]> code.delx.au - gnu-emacs/blobdiff - src/unexw32.c
Fix compiler warnings in the MinGW build
[gnu-emacs] / src / unexw32.c
index 322d60d062f4e4161584481935c0c9ab4faf9a7c..f4183dc976fcbd1fee7ef4617e1b8a6514a169fa 100644 (file)
@@ -1,12 +1,12 @@
 /* unexec for GNU Emacs on Windows NT.
-   Copyright (C) 1994, 2001-2015 Free Software Foundation, Inc.
+   Copyright (C) 1994, 2001-2016 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -34,11 +34,10 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 /* Include relevant definitions from IMAGEHLP.H, which can be found
    in \\win32sdk\mstools\samples\image\include\imagehlp.h. */
 
-PIMAGE_NT_HEADERS
-(__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress,
-                                   DWORD FileLength,
-                                   LPDWORD HeaderSum,
-                                   LPDWORD CheckSum);
+PIMAGE_NT_HEADERS (__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress,
+                                                      DWORD FileLength,
+                                                      LPDWORD HeaderSum,
+                                                      LPDWORD CheckSum);
 
 extern BOOL ctrl_c_handler (unsigned long type);
 
@@ -51,10 +50,6 @@ extern char *my_begbss_static;
 /* Basically, our "initialized" flag.  */
 BOOL using_dynamic_heap = FALSE;
 
-int open_input_file (file_data *p_file, char *name);
-int open_output_file (file_data *p_file, char *name, unsigned long size);
-void close_file_data (file_data *p_file);
-
 void get_section_info (file_data *p_file);
 void copy_executable_and_dump_data (file_data *, file_data *);
 void dump_bss_and_heap (file_data *p_infile, file_data *p_outfile);
@@ -82,14 +77,17 @@ DWORD_PTR  extra_bss_size_static = 0;
 #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)
 {
-  extern void mainCRTStartup (void);
 
 #if 1
   /* Give us a way to debug problems with crashes on startup when
@@ -206,7 +204,7 @@ close_file_data (file_data *p_file)
 
 /* Return pointer to section header for named section. */
 IMAGE_SECTION_HEADER *
-find_section (char * name, IMAGE_NT_HEADERS * nt_header)
+find_section (const char * name, IMAGE_NT_HEADERS * nt_header)
 {
   PIMAGE_SECTION_HEADER section;
   int i;
@@ -215,7 +213,7 @@ find_section (char * name, IMAGE_NT_HEADERS * nt_header)
 
   for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++)
     {
-      if (strcmp (section->Name, name) == 0)
+      if (strcmp ((char *)section->Name, name) == 0)
        return section;
       section++;
     }
@@ -250,9 +248,10 @@ rva_to_section (DWORD_PTR rva, IMAGE_NT_HEADERS * nt_header)
   return NULL;
 }
 
+#if 0  /* unused */
 /* Return pointer to section header for section containing the given
    offset in its raw data area. */
-IMAGE_SECTION_HEADER *
+static IMAGE_SECTION_HEADER *
 offset_to_section (DWORD_PTR offset, IMAGE_NT_HEADERS * nt_header)
 {
   PIMAGE_SECTION_HEADER section;
@@ -269,11 +268,12 @@ offset_to_section (DWORD_PTR offset, IMAGE_NT_HEADERS * nt_header)
     }
   return NULL;
 }
+#endif
 
 /* Return offset to an object in dst, given offset in src.  We assume
    there is at least one section in both src and dst images, and that
    the some sections may have been added to dst (after sections in src).  */
-DWORD_PTR
+static DWORD_PTR
 relocate_offset (DWORD_PTR offset,
                 IMAGE_NT_HEADERS * src_nt_header,
                 IMAGE_NT_HEADERS * dst_nt_header)
@@ -307,9 +307,6 @@ relocate_offset (DWORD_PTR offset,
     (dst_section->PointerToRawData - src_section->PointerToRawData);
 }
 
-#define OFFSET_TO_RVA(offset, section) \
-  ((section)->VirtualAddress + ((DWORD_PTR)(offset) - (section)->PointerToRawData))
-
 #define RVA_TO_OFFSET(rva, section) \
   ((section)->PointerToRawData + ((DWORD_PTR)(rva) - (section)->VirtualAddress))
 
@@ -319,15 +316,20 @@ relocate_offset (DWORD_PTR offset,
 /* Convert address in executing image to RVA.  */
 #define PTR_TO_RVA(ptr) ((DWORD_PTR)(ptr) - (DWORD_PTR) GetModuleHandle (NULL))
 
-#define RVA_TO_PTR(var,section,filedata) \
-         ((unsigned char *)(RVA_TO_OFFSET (var,section) + (filedata).file_base))
-
 #define PTR_TO_OFFSET(ptr, pfile_data) \
           ((unsigned char *)(ptr) - (pfile_data)->file_base)
 
 #define OFFSET_TO_PTR(offset, pfile_data) \
           ((pfile_data)->file_base + (DWORD_PTR)(offset))
 
+#if 0  /* unused */
+#define OFFSET_TO_RVA(offset, section) \
+  ((section)->VirtualAddress + ((DWORD_PTR)(offset) - (section)->PointerToRawData))
+
+#define RVA_TO_PTR(var,section,filedata) \
+         ((unsigned char *)(RVA_TO_OFFSET (var,section) + (filedata).file_base))
+#endif
+
 
 /* Flip through the executable and cache the info necessary for dumping.  */
 void