https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f631b4d12035fcb25616dcfb51b1f52c0ff60043

commit f631b4d12035fcb25616dcfb51b1f52c0ff60043
Author:     winesync <[email protected]>
AuthorDate: Fri Sep 11 13:14:05 2020 +0200
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Wed Sep 16 10:35:33 2020 +0200

    [WINESYNC] dbghelp: Translate the 32-bit Mach-O section header to the 
64-bit one.
    
    Signed-off-by: Zebediah Figura <[email protected]>
    Signed-off-by: Alexandre Julliard <[email protected]>
    
    wine commit id 1dc9bb70cd16fa7b37e8fd6e82ed18311ddfbe38 by Zebediah Figura 
<[email protected]>
---
 dll/win32/dbghelp/image_private.h |  8 +-------
 dll/win32/dbghelp/macho_module.c  | 43 ++++++++++++++++++++++++++-------------
 sdk/tools/winesync/dbghelp.cfg    |  2 +-
 3 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/dll/win32/dbghelp/image_private.h 
b/dll/win32/dbghelp/image_private.h
index 329236c9bf5..6b435559d72 100644
--- a/dll/win32/dbghelp/image_private.h
+++ b/dll/win32/dbghelp/image_private.h
@@ -46,12 +46,6 @@
 #endif
 #ifdef HAVE_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
 
 #define IMAGE_NO_MAP  ((void*)-1)
@@ -107,7 +101,7 @@ struct image_file_map
             int                         num_sections;
             struct
             {
-                const macho_section*            section;
+                struct section_64               section;
                 const char*                     mapped;
                 unsigned int                    ignored : 1;
             }*                          sect;
diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c
index 52ea739b13a..b8f5967137d 100644
--- a/dll/win32/dbghelp/macho_module.c
+++ b/dll/win32/dbghelp/macho_module.c
@@ -328,7 +328,7 @@ BOOL macho_find_section(struct image_file_map* ifm, const 
char* segname, const c
 {
     struct macho_file_map* fmap;
     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
        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++)
         {
             if (!fmap->sect[i].ignored &&
-                strcmp(fmap->sect[i].section->sectname, sectname) == 0 &&
-                (!segname || strcmp(fmap->sect[i].section->segname, segname) 
== 0))
+                strcmp(fmap->sect[i].section.sectname, sectname) == 0 &&
+                (!segname || strcmp(fmap->sect[i].section.segname, segname) == 
0))
             {
                 ism->fmap = ifm;
                 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)
         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);
 }
 
@@ -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)
     {
-        macho_unmap_range(&fmap->sect[ism->sidx].mapped, NULL, fmap, 
fmap->sect[ism->sidx].section->offset,
-                          fmap->sect[ism->sidx].section->size);
+        macho_unmap_range(&fmap->sect[ism->sidx].mapped, NULL, fmap, 
fmap->sect[ism->sidx].section.offset,
+                          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 ||
         ism->fmap->u.macho.sect[ism->sidx].ignored)
         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 ||
         ism->fmap->u.macho.sect[ism->sidx].ignored)
         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 section_info*            info = user;
     BOOL                            ignore;
-    const macho_section*            section;
     int                             i;
     unsigned long                   tmp, page_mask = sysconf( _SC_PAGESIZE ) - 
1;
     uint64_t vmaddr, vmsize;
     char segname[16];
     uint32_t nsects;
+    const void *sections;
 
     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;
         memcpy(segname, sc->segname, sizeof(segname));
         nsects = sc->nsects;
-        section = (const macho_section*)(sc + 1);
+        sections = (const void *)(sc + 1);
     }
     else
     {
@@ -562,7 +562,7 @@ static int macho_load_section_info(struct image_file_map* 
ifm, const struct load
         vmsize = sc->vmsize;
         memcpy(segname, sc->segname, sizeof(segname));
         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,
@@ -596,7 +596,22 @@ static int macho_load_section_info(struct image_file_map* 
ifm, const struct load
 
     for (i = 0; i < nsects; i++)
     {
-        fmap->sect[info->section_index].section = &section[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].ignored = ignore;
         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 */
     if (sectidx >= fmap->num_sections || fmap->sect[sectidx].ignored) return 
FALSE;
 
-    ret = (!(fmap->sect[sectidx].section->flags & SECTION_TYPE) &&
-           (fmap->sect[sectidx].section->flags & 
(S_ATTR_PURE_INSTRUCTIONS|S_ATTR_SOME_INSTRUCTIONS)));
+    ret = (!(fmap->sect[sectidx].section.flags & SECTION_TYPE) &&
+           (fmap->sect[sectidx].section.flags & 
(S_ATTR_PURE_INSTRUCTIONS|S_ATTR_SOME_INSTRUCTIONS)));
     TRACE("-> %d\n", ret);
     return ret;
 }
diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg
index 7b8de6b1dbd..e4f1f15e1b4 100644
--- a/sdk/tools/winesync/dbghelp.cfg
+++ b/sdk/tools/winesync/dbghelp.cfg
@@ -3,4 +3,4 @@ directories:
 files:
   include/dbghelp.h: sdk/include/psdk/dbghelp.h
 tags:
-  wine: 0fc3c33637d4c8eff3f4373d374b3feb402bce4a
+  wine: 1dc9bb70cd16fa7b37e8fd6e82ed18311ddfbe38

Reply via email to