[WINESYNC] dbghelp: Don't store entire mach header in image_file_map.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 7254579417f337063734933975b25d21da4d31f3 by Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
winesync 2020-09-11 18:59:48 +02:00 committed by Jérôme Gardou
parent 45b55dc9b2
commit 00783527e0
3 changed files with 15 additions and 12 deletions

View file

@ -96,10 +96,11 @@ struct image_file_map
size_t segs_start;
HANDLE handle;
struct image_file_map* dsym; /* the debug symbols file associated with this one */
size_t header_size; /* size of real header in file */
size_t commands_size;
size_t commands_count;
#ifdef HAVE_MACH_O_LOADER_H
struct mach_header mach_header;
size_t header_size; /* size of real header in file */
const struct load_command* load_commands;
const struct uuid_command* uuid;

View file

@ -448,7 +448,7 @@ static const struct load_command* macho_map_load_commands(struct macho_file_map*
if (fmap->load_commands == IMAGE_NO_MAP)
{
fmap->load_commands = (const struct load_command*) macho_map_range(
fmap, fmap->header_size, fmap->mach_header.sizeofcmds, NULL);
fmap, fmap->header_size, fmap->commands_size, NULL);
TRACE("Mapped load commands: %p\n", fmap->load_commands);
}
@ -466,7 +466,7 @@ static void macho_unmap_load_commands(struct macho_file_map* fmap)
{
TRACE("Unmapping load commands: %p\n", fmap->load_commands);
macho_unmap_range(NULL, (const void**)&fmap->load_commands, fmap,
fmap->header_size, fmap->mach_header.sizeofcmds);
fmap->header_size, fmap->commands_size);
}
}
@ -504,9 +504,9 @@ static int macho_enum_load_commands(struct image_file_map *ifm, unsigned cmd,
if ((lc = macho_map_load_commands(fmap)) == IMAGE_NO_MAP) return -1;
TRACE("%d total commands\n", fmap->mach_header.ncmds);
TRACE("%lu total commands\n", fmap->commands_count);
for (i = 0; i < fmap->mach_header.ncmds; i++, lc = macho_next_load_command(lc))
for (i = 0; i < fmap->commands_count; i++, lc = macho_next_load_command(lc))
{
int result;
@ -683,6 +683,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW,
{
struct macho_file_map* fmap = &ifm->u.macho;
struct fat_header fat_header;
struct mach_header mach_header;
int i;
WCHAR* filename;
struct section_info info;
@ -745,15 +746,16 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW,
/* Individual architecture (standalone or within a fat file) is in its native byte order. */
SetFilePointer(fmap->handle, fmap->arch_offset, 0, FILE_BEGIN);
if (!ReadFile(fmap->handle, &fmap->mach_header, sizeof(fmap->mach_header), &bytes_read, NULL)
|| bytes_read != sizeof(fmap->mach_header))
if (!ReadFile(fmap->handle, &mach_header, sizeof(mach_header), &bytes_read, NULL)
|| bytes_read != sizeof(mach_header))
goto done;
TRACE("... got possible Mach header\n");
/* and check for a Mach-O header */
if (fmap->mach_header.magic != target_magic ||
fmap->mach_header.cputype != target_cpu) goto done;
if (mach_header.magic != target_magic || mach_header.cputype != target_cpu) goto done;
fmap->commands_size = mach_header.sizeofcmds;
fmap->commands_count = mach_header.ncmds;
/* Make sure the file type is one of the ones we expect. */
switch (fmap->mach_header.filetype)
switch (mach_header.filetype)
{
case MH_EXECUTE:
case MH_DYLIB:

View file

@ -4,4 +4,4 @@ files:
include/dbghelp.h: sdk/include/psdk/dbghelp.h
include/wine/mscvpdb.h: sdk/include/reactos/wine/mscvpdb.h
tags:
wine: b664ae8e60e08224cdc3025c28a37cb22356aaa4
wine: 7254579417f337063734933975b25d21da4d31f3