mirror of
https://github.com/reactos/reactos.git
synced 2025-07-09 23:18:06 +00:00
[WINESYNC] dbghelp: Translate the 32-bit Mach-O section header to the 64-bit one.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> wine commit id 1dc9bb70cd16fa7b37e8fd6e82ed18311ddfbe38 by Zebediah Figura <zfigura@codeweavers.com>
This commit is contained in:
parent
75e77444c6
commit
f631b4d120
3 changed files with 31 additions and 22 deletions
|
@ -46,12 +46,6 @@
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_MACH_O_LOADER_H
|
#ifdef HAVE_MACH_O_LOADER_H
|
||||||
#include <mach-o/loader.h>
|
#include <mach-o/loader.h>
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
typedef struct section_64 macho_section;
|
|
||||||
#else
|
|
||||||
typedef struct section macho_section;
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define IMAGE_NO_MAP ((void*)-1)
|
#define IMAGE_NO_MAP ((void*)-1)
|
||||||
|
@ -107,7 +101,7 @@ struct image_file_map
|
||||||
int num_sections;
|
int num_sections;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
const macho_section* section;
|
struct section_64 section;
|
||||||
const char* mapped;
|
const char* mapped;
|
||||||
unsigned int ignored : 1;
|
unsigned int ignored : 1;
|
||||||
}* sect;
|
}* sect;
|
||||||
|
|
|
@ -328,7 +328,7 @@ BOOL macho_find_section(struct image_file_map* ifm, const char* segname, const c
|
||||||
{
|
{
|
||||||
struct macho_file_map* fmap;
|
struct macho_file_map* fmap;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
char tmp[sizeof(fmap->sect[0].section->sectname)];
|
char tmp[sizeof(fmap->sect[0].section.sectname)];
|
||||||
|
|
||||||
/* Other parts of dbghelp use section names like ".eh_frame". Mach-O uses
|
/* Other parts of dbghelp use section names like ".eh_frame". Mach-O uses
|
||||||
names like "__eh_frame". Convert those. */
|
names like "__eh_frame". Convert those. */
|
||||||
|
@ -345,8 +345,8 @@ BOOL macho_find_section(struct image_file_map* ifm, const char* segname, const c
|
||||||
for (i = 0; i < fmap->num_sections; i++)
|
for (i = 0; i < fmap->num_sections; i++)
|
||||||
{
|
{
|
||||||
if (!fmap->sect[i].ignored &&
|
if (!fmap->sect[i].ignored &&
|
||||||
strcmp(fmap->sect[i].section->sectname, sectname) == 0 &&
|
strcmp(fmap->sect[i].section.sectname, sectname) == 0 &&
|
||||||
(!segname || strcmp(fmap->sect[i].section->segname, segname) == 0))
|
(!segname || strcmp(fmap->sect[i].section.segname, segname) == 0))
|
||||||
{
|
{
|
||||||
ism->fmap = ifm;
|
ism->fmap = ifm;
|
||||||
ism->sidx = i;
|
ism->sidx = i;
|
||||||
|
@ -372,7 +372,7 @@ const char* macho_map_section(struct image_section_map* ism)
|
||||||
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.macho.num_sections || fmap->sect[ism->sidx].ignored)
|
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.macho.num_sections || fmap->sect[ism->sidx].ignored)
|
||||||
return IMAGE_NO_MAP;
|
return IMAGE_NO_MAP;
|
||||||
|
|
||||||
return macho_map_range(fmap, fmap->sect[ism->sidx].section->offset, fmap->sect[ism->sidx].section->size,
|
return macho_map_range(fmap, fmap->sect[ism->sidx].section.offset, fmap->sect[ism->sidx].section.size,
|
||||||
&fmap->sect[ism->sidx].mapped);
|
&fmap->sect[ism->sidx].mapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,8 +385,8 @@ void macho_unmap_section(struct image_section_map* ism)
|
||||||
|
|
||||||
if (ism->sidx >= 0 && ism->sidx < fmap->num_sections && fmap->sect[ism->sidx].mapped != IMAGE_NO_MAP)
|
if (ism->sidx >= 0 && ism->sidx < fmap->num_sections && fmap->sect[ism->sidx].mapped != IMAGE_NO_MAP)
|
||||||
{
|
{
|
||||||
macho_unmap_range(&fmap->sect[ism->sidx].mapped, NULL, fmap, fmap->sect[ism->sidx].section->offset,
|
macho_unmap_range(&fmap->sect[ism->sidx].mapped, NULL, fmap, fmap->sect[ism->sidx].section.offset,
|
||||||
fmap->sect[ism->sidx].section->size);
|
fmap->sect[ism->sidx].section.size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ DWORD_PTR macho_get_map_rva(const struct image_section_map* ism)
|
||||||
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.macho.num_sections ||
|
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.macho.num_sections ||
|
||||||
ism->fmap->u.macho.sect[ism->sidx].ignored)
|
ism->fmap->u.macho.sect[ism->sidx].ignored)
|
||||||
return 0;
|
return 0;
|
||||||
return ism->fmap->u.macho.sect[ism->sidx].section->addr - ism->fmap->u.macho.segs_start;
|
return ism->fmap->u.macho.sect[ism->sidx].section.addr - ism->fmap->u.macho.segs_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
|
@ -409,7 +409,7 @@ unsigned macho_get_map_size(const struct image_section_map* ism)
|
||||||
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.macho.num_sections ||
|
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.macho.num_sections ||
|
||||||
ism->fmap->u.macho.sect[ism->sidx].ignored)
|
ism->fmap->u.macho.sect[ism->sidx].ignored)
|
||||||
return 0;
|
return 0;
|
||||||
return ism->fmap->u.macho.sect[ism->sidx].section->size;
|
return ism->fmap->u.macho.sect[ism->sidx].section.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
|
@ -539,12 +539,12 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load
|
||||||
struct macho_file_map* fmap = &ifm->u.macho;
|
struct macho_file_map* fmap = &ifm->u.macho;
|
||||||
struct section_info* info = user;
|
struct section_info* info = user;
|
||||||
BOOL ignore;
|
BOOL ignore;
|
||||||
const macho_section* section;
|
|
||||||
int i;
|
int i;
|
||||||
unsigned long tmp, page_mask = sysconf( _SC_PAGESIZE ) - 1;
|
unsigned long tmp, page_mask = sysconf( _SC_PAGESIZE ) - 1;
|
||||||
uint64_t vmaddr, vmsize;
|
uint64_t vmaddr, vmsize;
|
||||||
char segname[16];
|
char segname[16];
|
||||||
uint32_t nsects;
|
uint32_t nsects;
|
||||||
|
const void *sections;
|
||||||
|
|
||||||
if (ifm->addr_size == 32)
|
if (ifm->addr_size == 32)
|
||||||
{
|
{
|
||||||
|
@ -553,7 +553,7 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load
|
||||||
vmsize = sc->vmsize;
|
vmsize = sc->vmsize;
|
||||||
memcpy(segname, sc->segname, sizeof(segname));
|
memcpy(segname, sc->segname, sizeof(segname));
|
||||||
nsects = sc->nsects;
|
nsects = sc->nsects;
|
||||||
section = (const macho_section*)(sc + 1);
|
sections = (const void *)(sc + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -562,7 +562,7 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load
|
||||||
vmsize = sc->vmsize;
|
vmsize = sc->vmsize;
|
||||||
memcpy(segname, sc->segname, sizeof(segname));
|
memcpy(segname, sc->segname, sizeof(segname));
|
||||||
nsects = sc->nsects;
|
nsects = sc->nsects;
|
||||||
section = (const macho_section*)(sc + 1);
|
sections = (const void *)(sc + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("(%p/%d, %p, %p) before: 0x%08lx - 0x%08lx\n", fmap, fmap->fd, lc, user,
|
TRACE("(%p/%d, %p, %p) before: 0x%08lx - 0x%08lx\n", fmap, fmap->fd, lc, user,
|
||||||
|
@ -596,7 +596,22 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load
|
||||||
|
|
||||||
for (i = 0; i < nsects; i++)
|
for (i = 0; i < nsects; i++)
|
||||||
{
|
{
|
||||||
fmap->sect[info->section_index].section = §ion[i];
|
if (ifm->addr_size == 32)
|
||||||
|
{
|
||||||
|
const struct section *section = &((const struct section *)sections)[i];
|
||||||
|
memcpy(fmap->sect[info->section_index].section.sectname, section->sectname, sizeof(section->sectname));
|
||||||
|
memcpy(fmap->sect[info->section_index].section.segname, section->segname, sizeof(section->segname));
|
||||||
|
fmap->sect[info->section_index].section.addr = section->addr;
|
||||||
|
fmap->sect[info->section_index].section.size = section->size;
|
||||||
|
fmap->sect[info->section_index].section.offset = section->offset;
|
||||||
|
fmap->sect[info->section_index].section.align = section->align;
|
||||||
|
fmap->sect[info->section_index].section.reloff = section->reloff;
|
||||||
|
fmap->sect[info->section_index].section.nreloc = section->nreloc;
|
||||||
|
fmap->sect[info->section_index].section.flags = section->flags;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fmap->sect[info->section_index].section = ((const struct section_64 *)sections)[i];
|
||||||
|
|
||||||
fmap->sect[info->section_index].mapped = IMAGE_NO_MAP;
|
fmap->sect[info->section_index].mapped = IMAGE_NO_MAP;
|
||||||
fmap->sect[info->section_index].ignored = ignore;
|
fmap->sect[info->section_index].ignored = ignore;
|
||||||
info->section_index++;
|
info->section_index++;
|
||||||
|
@ -831,8 +846,8 @@ static BOOL macho_sect_is_code(struct macho_file_map* fmap, unsigned char sectid
|
||||||
sectidx--; /* convert from 1-based to 0-based */
|
sectidx--; /* convert from 1-based to 0-based */
|
||||||
if (sectidx >= fmap->num_sections || fmap->sect[sectidx].ignored) return FALSE;
|
if (sectidx >= fmap->num_sections || fmap->sect[sectidx].ignored) return FALSE;
|
||||||
|
|
||||||
ret = (!(fmap->sect[sectidx].section->flags & SECTION_TYPE) &&
|
ret = (!(fmap->sect[sectidx].section.flags & SECTION_TYPE) &&
|
||||||
(fmap->sect[sectidx].section->flags & (S_ATTR_PURE_INSTRUCTIONS|S_ATTR_SOME_INSTRUCTIONS)));
|
(fmap->sect[sectidx].section.flags & (S_ATTR_PURE_INSTRUCTIONS|S_ATTR_SOME_INSTRUCTIONS)));
|
||||||
TRACE("-> %d\n", ret);
|
TRACE("-> %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,4 @@ directories:
|
||||||
files:
|
files:
|
||||||
include/dbghelp.h: sdk/include/psdk/dbghelp.h
|
include/dbghelp.h: sdk/include/psdk/dbghelp.h
|
||||||
tags:
|
tags:
|
||||||
wine: 0fc3c33637d4c8eff3f4373d374b3feb402bce4a
|
wine: 1dc9bb70cd16fa7b37e8fd6e82ed18311ddfbe38
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue