HCoop
/
bpt
/
emacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove `declare' macro
[bpt/emacs.git]
/
nt
/
preprep.c
diff --git
a/nt/preprep.c
b/nt/preprep.c
index
285ff69
..
fda937d
100644
(file)
--- a/
nt/preprep.c
+++ b/
nt/preprep.c
@@
-1,6
+1,5
@@
/* Pre-process emacs.exe for profiling by MSVC.
/* Pre-process emacs.exe for profiling by MSVC.
- Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
- 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2001-2014 Free Software Foundation, Inc.
This file is part of GNU Emacs.
This file is part of GNU Emacs.
@@
-26,7
+25,7
@@
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
#include <stdio.h>
#include <fcntl.h>
#include <time.h>
#include <stdio.h>
#include <fcntl.h>
#include <time.h>
-#if
def __GNUC__
+#if
defined(__GNUC__) && !defined(_W64)
#define _ANONYMOUS_UNION
#define _ANONYMOUS_STRUCT
#endif
#define _ANONYMOUS_UNION
#define _ANONYMOUS_STRUCT
#endif
@@
-37,9
+36,9
@@
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
PIMAGE_NT_HEADERS
(__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress,
PIMAGE_NT_HEADERS
(__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress,
- DWORD FileLength,
-
LPDWORD
HeaderSum,
-
LPDWORD
CheckSum);
+ DWORD
_PTR
FileLength,
+
PDWORD_PTR
HeaderSum,
+
PDWORD_PTR
CheckSum);
#undef min
#undef max
#undef min
#undef max
@@
-197,7
+196,7
@@
find_section (const char *name, IMAGE_NT_HEADERS *nt_header)
/* Return pointer to section header for section containing the given
relative virtual address. */
IMAGE_SECTION_HEADER *
/* Return pointer to section header for section containing the given
relative virtual address. */
IMAGE_SECTION_HEADER *
-rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
+rva_to_section (DWORD
_PTR
rva, IMAGE_NT_HEADERS * nt_header)
{
PIMAGE_SECTION_HEADER section;
int i;
{
PIMAGE_SECTION_HEADER section;
int i;
@@
-212,7
+211,7
@@
rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
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. */
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 real_size = max (section->SizeOfRawData,
+ DWORD
_PTR
real_size = max (section->SizeOfRawData,
section->Misc.VirtualSize);
if (rva >= section->VirtualAddress
&& rva < section->VirtualAddress + real_size)
section->Misc.VirtualSize);
if (rva >= section->VirtualAddress
&& rva < section->VirtualAddress + real_size)
@@
-225,7
+224,7
@@
rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
/* Return pointer to section header for section containing the given
offset in its raw data area. */
IMAGE_SECTION_HEADER *
/* Return pointer to section header for section containing the given
offset in its raw data area. */
IMAGE_SECTION_HEADER *
-offset_to_section (DWORD offset, IMAGE_NT_HEADERS * nt_header)
+offset_to_section (DWORD
_PTR
offset, IMAGE_NT_HEADERS * nt_header)
{
PIMAGE_SECTION_HEADER section;
int i;
{
PIMAGE_SECTION_HEADER section;
int i;
@@
-245,8
+244,8
@@
offset_to_section (DWORD offset, IMAGE_NT_HEADERS * nt_header)
/* 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). */
/* 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). */
-static DWORD
-relocate_offset (DWORD offset,
+static DWORD
_PTR
+relocate_offset (DWORD
_PTR
offset,
IMAGE_NT_HEADERS * src_nt_header,
IMAGE_NT_HEADERS * dst_nt_header)
{
IMAGE_NT_HEADERS * src_nt_header,
IMAGE_NT_HEADERS * dst_nt_header)
{
@@
-280,28
+279,29
@@
relocate_offset (DWORD offset,
}
#define OFFSET_TO_RVA(offset, section) \
}
#define OFFSET_TO_RVA(offset, section) \
-
(section->VirtualAddress + ((DWORD)(offset) - section
->PointerToRawData))
+
((section)->VirtualAddress + ((DWORD_PTR)(offset) - (section)
->PointerToRawData))
#define RVA_TO_OFFSET(rva, section) \
#define RVA_TO_OFFSET(rva, section) \
-
(section->PointerToRawData + ((DWORD)(rva) - section
->VirtualAddress))
+
((section)->PointerToRawData + ((DWORD_PTR)(rva) - (section)
->VirtualAddress))
#define RVA_TO_SECTION_OFFSET(rva, section) \
#define RVA_TO_SECTION_OFFSET(rva, section) \
-
((DWORD)(rva) - section
->VirtualAddress)
+
((DWORD_PTR)(rva) - (section)
->VirtualAddress)
#define RVA_TO_PTR(var,section,filedata) \
#define RVA_TO_PTR(var,section,filedata) \
-
((void *)(RVA_TO_OFFSET(var,section) + (filedata)->file_base
))
+
((void *)((unsigned char *)(RVA_TO_OFFSET(var,section) + (filedata)->file_base)
))
/* Convert address in executing image to RVA. */
/* Convert address in executing image to RVA. */
-#define PTR_TO_RVA(ptr) ((DWORD
)(ptr) - (DWORD
) GetModuleHandle (NULL))
+#define PTR_TO_RVA(ptr) ((DWORD
_PTR)(ptr) - (DWORD_PTR
) GetModuleHandle (NULL))
#define PTR_TO_OFFSET(ptr, pfile_data) \
((unsigned const char *)(ptr) - (pfile_data)->file_base)
#define OFFSET_TO_PTR(offset, pfile_data) \
#define PTR_TO_OFFSET(ptr, pfile_data) \
((unsigned const char *)(ptr) - (pfile_data)->file_base)
#define OFFSET_TO_PTR(offset, pfile_data) \
- ((pfile_data)->file_base + (DWORD)(offset))
+ ((pfile_data)->file_base + (DWORD
_PTR
)(offset))
-#define ROUND_UP(p, align) (((DWORD)(p) + (align)-1) & ~((align)-1))
-#define ROUND_DOWN(p, align) ((DWORD)(p) & ~((align)-1))
+#define ROUND_UP(p, align) \
+ (((DWORD_PTR)(p) + (align)-1) & ~((DWORD_PTR)(align)-1))
+#define ROUND_DOWN(p, align) ((DWORD_PTR)(p) & ~((DWORD_PTR)(align)-1))
/* The MSVC prep program generates a ._xe file from .exe, where relevant
/* The MSVC prep program generates a ._xe file from .exe, where relevant
@@
-322,7
+322,7
@@
relocate_offset (DWORD offset,
variables, because of dumping.]
We could potentially generate the relocation data ourselves by making
variables, because of dumping.]
We could potentially generate the relocation data ourselves by making
- two versions of temacs, one with an extra dumm
m
y section before
+ two versions of temacs, one with an extra dummy section before
EMHEAP to offset it, and then compare the dumped executables from
both. That is a lot of work though, and it doesn't solve the problem
of dumped pointers to static variables, which also can be relocated.
EMHEAP to offset it, and then compare the dumped executables from
both. That is a lot of work though, and it doesn't solve the problem
of dumped pointers to static variables, which also can be relocated.
@@
-354,9
+354,9
@@
copy_executable_and_move_sections (file_data *p_infile,
PIMAGE_SECTION_HEADER reloc_section;
PIMAGE_DATA_DIRECTORY import_dir;
PIMAGE_DATA_DIRECTORY reloc_dir;
PIMAGE_SECTION_HEADER reloc_section;
PIMAGE_DATA_DIRECTORY import_dir;
PIMAGE_DATA_DIRECTORY reloc_dir;
- DWORD import_delta_rva;
- DWORD reloc_delta_rva;
- DWORD offset;
+ DWORD
_PTR
import_delta_rva;
+ DWORD
_PTR
reloc_delta_rva;
+ DWORD
_PTR
offset;
int i;
#define COPY_CHUNK(message, src, size) \
int i;
#define COPY_CHUNK(message, src, size) \
@@
-389,7
+389,7
@@
copy_executable_and_move_sections (file_data *p_infile,
Note that dst is updated implicitly by each COPY_CHUNK. */
dos_header = (PIMAGE_DOS_HEADER) p_infile->file_base;
Note that dst is updated implicitly by each COPY_CHUNK. */
dos_header = (PIMAGE_DOS_HEADER) p_infile->file_base;
- nt_header = (PIMAGE_NT_HEADERS) (((unsigned
long
) dos_header) +
+ nt_header = (PIMAGE_NT_HEADERS) (((unsigned
char *
) dos_header) +
dos_header->e_lfanew);
section = IMAGE_FIRST_SECTION (nt_header);
dos_header->e_lfanew);
section = IMAGE_FIRST_SECTION (nt_header);
@@
-407,10
+407,10
@@
copy_executable_and_move_sections (file_data *p_infile,
dst = (unsigned char *) p_outfile->file_base;
COPY_CHUNK ("Copying DOS header...", dos_header,
dst = (unsigned char *) p_outfile->file_base;
COPY_CHUNK ("Copying DOS header...", dos_header,
- (DWORD
) nt_header - (DWORD
) dos_header);
+ (DWORD
_PTR) nt_header - (DWORD_PTR
) dos_header);
dst_nt_header = (PIMAGE_NT_HEADERS) dst;
COPY_CHUNK ("Copying NT header...", nt_header,
dst_nt_header = (PIMAGE_NT_HEADERS) dst;
COPY_CHUNK ("Copying NT header...", nt_header,
- (DWORD
) section - (DWORD
) nt_header);
+ (DWORD
_PTR) section - (DWORD_PTR
) nt_header);
dst_section = (PIMAGE_SECTION_HEADER) dst;
COPY_CHUNK ("Copying section table...", section,
nt_header->FileHeader.NumberOfSections * sizeof (*section));
dst_section = (PIMAGE_SECTION_HEADER) dst;
COPY_CHUNK ("Copying section table...", section,
nt_header->FileHeader.NumberOfSections * sizeof (*section));
@@
-538,7
+538,7
@@
copy_executable_and_move_sections (file_data *p_infile,
#define ADJUST_IMPORT_RVA(var) \
do { \
if ((var) != 0) \
#define ADJUST_IMPORT_RVA(var) \
do { \
if ((var) != 0) \
- *((DWORD
*)&(var)) += import_delta_rva;
\
+ *((DWORD
_PTR *)&(var)) += import_delta_rva;
\
} while (0)
dst_nt_header->OptionalHeader.SizeOfInitializedData = 0;
} while (0)
dst_nt_header->OptionalHeader.SizeOfInitializedData = 0;
@@
-628,10
+628,10
@@
copy_executable_and_move_sections (file_data *p_infile,
{
IMAGE_BASE_RELOCATION *relocs, *block, *start_block, *end_block;
{
IMAGE_BASE_RELOCATION *relocs, *block, *start_block, *end_block;
- DWORD import_start = import_section->VirtualAddress + dst_nt_header->OptionalHeader.ImageBase;
- DWORD import_end = import_start + import_section->Misc.VirtualSize;
- DWORD len_import_relocs;
- DWORD len_remaining_relocs;
+ DWORD
_PTR
import_start = import_section->VirtualAddress + dst_nt_header->OptionalHeader.ImageBase;
+ DWORD
_PTR
import_end = import_start + import_section->Misc.VirtualSize;
+ DWORD
_PTR
len_import_relocs;
+ DWORD
_PTR
len_remaining_relocs;
int seen_high = 0;
WORD * high_word;
void * holder;
int seen_high = 0;
WORD * high_word;
void * holder;
@@
-644,8
+644,8
@@
copy_executable_and_move_sections (file_data *p_infile,
any; the profiler needs to be able to patch RVAs in the import
section itself. */
for (block = relocs, start_block = 0;
any; the profiler needs to be able to patch RVAs in the import
section itself. */
for (block = relocs, start_block = 0;
- (DWORD
) block - (DWORD
) relocs < reloc_dir->Size;
- block = (void *)((DWORD) block + block->SizeOfBlock))
+ (DWORD
_PTR) block - (DWORD_PTR
) relocs < reloc_dir->Size;
+ block = (void *)((DWORD
_PTR
) block + block->SizeOfBlock))
{
if (block->VirtualAddress >= import_section->VirtualAddress + import_section->Misc.VirtualSize)
{
{
if (block->VirtualAddress >= import_section->VirtualAddress + import_section->Misc.VirtualSize)
{
@@
-661,8
+661,8
@@
copy_executable_and_move_sections (file_data *p_infile,
}
if (start_block)
{
}
if (start_block)
{
- len_import_relocs = (DWORD
) end_block - (DWORD
) start_block;
- len_remaining_relocs = (DWORD
) relocs + reloc_dir->Size - (DWORD
) end_block;
+ len_import_relocs = (DWORD
_PTR) end_block - (DWORD_PTR
) start_block;
+ len_remaining_relocs = (DWORD
_PTR) relocs + reloc_dir->Size - (DWORD_PTR
) end_block;
holder = malloc (len_import_relocs);
if (holder == 0)
abort ();
holder = malloc (len_import_relocs);
if (holder == 0)
abort ();
@@
-676,14
+676,14
@@
copy_executable_and_move_sections (file_data *p_infile,
to the old import section location, and patching them to
reference the new location. */
for (block = relocs;
to the old import section location, and patching them to
reference the new location. */
for (block = relocs;
- (DWORD
) block - (DWORD
) relocs < reloc_dir->Size;
- block = (void *)((DWORD) block + block->SizeOfBlock))
+ (DWORD
_PTR) block - (DWORD_PTR
) relocs < reloc_dir->Size;
+ block = (void *)((DWORD
_PTR
) block + block->SizeOfBlock))
{
{
- DWORD page_rva = block->VirtualAddress;
- DWORD page_offset;
+ DWORD
_PTR
page_rva = block->VirtualAddress;
+ DWORD
_PTR
page_offset;
union {
WORD word;
union {
WORD word;
- DWORD dword;
+ DWORD
_PTR
dword;
} * ploc;
WORD *fixup;
} * ploc;
WORD *fixup;
@@
-693,7
+693,7
@@
copy_executable_and_move_sections (file_data *p_infile,
continue;
for (fixup = (WORD *) &block[1];
continue;
for (fixup = (WORD *) &block[1];
- (DWORD
) fixup - (DWORD
) block < block->SizeOfBlock;
+ (DWORD
_PTR) fixup - (DWORD_PTR
) block < block->SizeOfBlock;
fixup++)
{
page_offset = (*fixup) & 0xfff;
fixup++)
{
page_offset = (*fixup) & 0xfff;
@@
-766,7
+766,6
@@
main (int argc, char **argv)
PIMAGE_NT_HEADERS nt_header;
file_data in_file, out_file;
char out_filename[MAX_PATH], in_filename[MAX_PATH];
PIMAGE_NT_HEADERS nt_header;
file_data in_file, out_file;
char out_filename[MAX_PATH], in_filename[MAX_PATH];
- const char *ptr;
strcpy (in_filename, argv[1]);
strcpy (out_filename, argv[2]);
strcpy (in_filename, argv[1]);
strcpy (out_filename, argv[2]);
@@
-796,8
+795,8
@@
main (int argc, char **argv)
/* Patch up header fields; profiler is picky about this. */
{
HANDLE hImagehelp = LoadLibrary ("imagehlp.dll");
/* Patch up header fields; profiler is picky about this. */
{
HANDLE hImagehelp = LoadLibrary ("imagehlp.dll");
- DWORD headersum;
- DWORD checksum;
+ DWORD
_PTR
headersum;
+ DWORD
_PTR
checksum;
dos_header = (PIMAGE_DOS_HEADER) out_file.file_base;
nt_header = (PIMAGE_NT_HEADERS) ((char *) dos_header + dos_header->e_lfanew);
dos_header = (PIMAGE_DOS_HEADER) out_file.file_base;
nt_header = (PIMAGE_NT_HEADERS) ((char *) dos_header + dos_header->e_lfanew);
@@
-827,6
+826,3
@@
main (int argc, char **argv)
}
/* eof */
}
/* eof */
-
-/* arch-tag: 144ca747-168e-43a0-9736-3f4c0ba1657f
- (do not change this comment) */