ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
September 2020
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
25 participants
382 discussions
Start a n
N
ew thread
[reactos] 24/179: [WINESYNC] dbghelp: Map SIMD dwarf registers on ARM64.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d1191416699f8e50cda8f…
commit d1191416699f8e50cda8f37acc1394899e953234 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 13:14:08 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:33 2020 +0200 [WINESYNC] dbghelp: Map SIMD dwarf registers on ARM64. Signed-off-by: André Hentschel <nerv(a)dawncrow.de> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 86864486be64a277f6edf8e66709cd0f17a4eed9 by André Hentschel <nerv(a)dawncrow.de> --- dll/win32/dbghelp/cpu_arm64.c | 1 + sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dll/win32/dbghelp/cpu_arm64.c b/dll/win32/dbghelp/cpu_arm64.c index dea19f83bac..f50b3255bd0 100644 --- a/dll/win32/dbghelp/cpu_arm64.c +++ b/dll/win32/dbghelp/cpu_arm64.c @@ -158,6 +158,7 @@ static unsigned arm64_map_dwarf_register(unsigned regno, BOOL eh_frame) if (regno == 29) return CV_ARM64_FP; if (regno == 30) return CV_ARM64_LR; if (regno == 31) return CV_ARM64_SP; + if (regno >= 64 && regno <= 95) return CV_ARM64_Q0 + regno - 64; FIXME("Don't know how to map register %d\n", regno); return CV_ARM64_NOREG; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index d497e3133cc..15ff3dbd075 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: 7d441808ac3b1d8bcef7795b636bda14c31c927b + wine: 86864486be64a277f6edf8e66709cd0f17a4eed9
4 years, 3 months
1
0
0
0
[reactos] 23/179: [WINESYNC] dbghelp: Read the stabs nlist entry corresponding to the target's architecture.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eaf6edad46672a486303b…
commit eaf6edad46672a486303bd783026f90e3a66a1a8 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 13:14:05 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:33 2020 +0200 [WINESYNC] dbghelp: Read the stabs nlist entry corresponding to the target's architecture. Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 7d441808ac3b1d8bcef7795b636bda14c31c927b by Zebediah Figura <zfigura(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp_private.h | 2 +- dll/win32/dbghelp/macho_module.c | 16 +++----- dll/win32/dbghelp/stabs.c | 73 +++++++++++++++++++++---------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 4 files changed, 48 insertions(+), 45 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index 537b9bc087b..21198f400ab 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -708,7 +708,7 @@ typedef void (*stabs_def_cb)(struct module* module, unsigned long load_offset, BOOL is_public, BOOL is_global, unsigned char other, struct symt_compiland* compiland, void* user); extern BOOL stabs_parse(struct module* module, unsigned long load_offset, - const void* stabs, int stablen, + const char* stabs, int stablen, const char* strs, int strtablen, stabs_def_cb callback, void* user) DECLSPEC_HIDDEN; diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index b8f5967137d..52c8e69108c 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -88,13 +88,6 @@ struct dyld_all_image_infos { WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_macho); -#ifdef _WIN64 -typedef struct nlist_64 macho_nlist; -#else -typedef struct nlist macho_nlist; -#endif - - /* Bitmask for Mach-O image header flags indicating that the image is in dyld's shared cached. That implies that its segments are mapped non-contiguously. This value isn't defined anywhere in headers. It's used in dyld and in @@ -913,24 +906,25 @@ static int macho_parse_symtab(struct image_file_map* ifm, struct macho_file_map* fmap = &ifm->u.macho; const struct symtab_command* sc = (const struct symtab_command*)lc; struct macho_debug_info* mdi = user; - const macho_nlist* stab; const char* stabstr; int ret = 0; + size_t stabsize = (ifm->addr_size == 32) ? sizeof(struct nlist) : sizeof(struct nlist_64); + const char *stab; TRACE("(%p/%d, %p, %p) %u syms at 0x%08x, strings 0x%08x - 0x%08x\n", fmap, fmap->fd, lc, user, sc->nsyms, sc->symoff, sc->stroff, sc->stroff + sc->strsize); - if (!macho_map_ranges(fmap, sc->symoff, sc->nsyms * sizeof(macho_nlist), + if (!macho_map_ranges(fmap, sc->symoff, sc->nsyms * stabsize, sc->stroff, sc->strsize, (const void**)&stab, (const void**)&stabstr)) return 0; if (!stabs_parse(mdi->module, mdi->module->format_info[DFI_MACHO]->u.macho_info->load_addr - fmap->segs_start, - stab, sc->nsyms * sizeof(macho_nlist), + stab, sc->nsyms * stabsize, stabstr, sc->strsize, macho_stabs_def_cb, mdi)) ret = -1; - macho_unmap_ranges(fmap, sc->symoff, sc->nsyms * sizeof(macho_nlist), + macho_unmap_ranges(fmap, sc->symoff, sc->nsyms * stabsize, sc->stroff, sc->strsize, (const void**)&stab, (const void**)&stabstr); return ret; diff --git a/dll/win32/dbghelp/stabs.c b/dll/win32/dbghelp/stabs.c index 1ec0065bb71..9caf6f9d427 100644 --- a/dll/win32/dbghelp/stabs.c +++ b/dll/win32/dbghelp/stabs.c @@ -41,6 +41,7 @@ #include <sys/mman.h> #endif #include <limits.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #ifdef HAVE_UNISTD_H @@ -119,11 +120,7 @@ struct stab_nlist unsigned char n_type; char n_other; short n_desc; -#if defined(__APPLE__) && defined(_WIN64) - unsigned long n_value; -#else unsigned n_value; -#endif }; static void stab_strcpy(char* dest, int sz, const char* source) @@ -1273,7 +1270,7 @@ static inline void stabbuf_append(char **buf, unsigned *buf_size, const char *st } BOOL stabs_parse(struct module* module, unsigned long load_offset, - const void* pv_stab_ptr, int stablen, + const char* pv_stab_ptr, int stablen, const char* strs, int strtablen, stabs_def_cb callback, void* user) { @@ -1286,7 +1283,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, const char* ptr; char* stabbuff; unsigned int stabbufflen; - const struct stab_nlist* stab_ptr = pv_stab_ptr; + const struct stab_nlist* stab_ptr; const char* strs_end; int strtabinc; char symname[4096]; @@ -1298,8 +1295,14 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, BOOL ret = TRUE; struct location loc; unsigned char type; + size_t stabsize = sizeof(struct stab_nlist); + uint64_t n_value; - nstab = stablen / sizeof(struct stab_nlist); +#ifdef __APPLE__ + if (module->process->is_64bit) + stabsize = sizeof(struct nlist_64); +#endif + nstab = stablen / stabsize; strs_end = strs + strtablen; memset(stabs_basic, 0, sizeof(stabs_basic)); @@ -1315,8 +1318,14 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, strtabinc = 0; stabbuff[0] = '\0'; - for (i = 0; i < nstab; i++, stab_ptr++) + for (i = 0; i < nstab; i++) { + stab_ptr = (struct stab_nlist *)(pv_stab_ptr + i * stabsize); + n_value = stab_ptr->n_value; +#ifdef __APPLE__ + if (module->process->is_64bit) + n_value = ((struct nlist_64 *)stab_ptr)->n_value; +#endif ptr = strs + stab_ptr->n_strx; if ((ptr > strs_end) || (ptr + strlen(ptr) > strs_end)) { @@ -1390,7 +1399,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, stab_strcpy(symname, sizeof(symname), ptr); loc.kind = loc_absolute; loc.reg = 0; - loc.offset = load_offset + stab_ptr->n_value; + loc.offset = load_offset + n_value; symt_new_global_variable(module, compiland, symname, TRUE /* FIXME */, loc, 0, stabs_parse_type(ptr)); break; @@ -1400,7 +1409,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, stab_strcpy(symname, sizeof(symname), ptr); loc.kind = loc_absolute; loc.reg = 0; - loc.offset = load_offset + stab_ptr->n_value; + loc.offset = load_offset + n_value; symt_new_global_variable(module, compiland, symname, TRUE /* FIXME */, loc, 0, stabs_parse_type(ptr)); break; @@ -1408,14 +1417,14 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, if (curr_func) { block = symt_open_func_block(module, curr_func, block, - stab_ptr->n_value, 0); + n_value, 0); pending_flush(&pending_block, module, curr_func, block); } break; case N_RBRAC: if (curr_func) block = symt_close_func_block(module, curr_func, block, - stab_ptr->n_value); + n_value); break; case N_PSYM: /* These are function parameters. */ @@ -1425,9 +1434,9 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, stab_strcpy(symname, sizeof(symname), ptr); loc.kind = loc_regrel; loc.reg = dbghelp_current_cpu->frame_regno; - loc.offset = stab_ptr->n_value; + loc.offset = n_value; symt_add_func_local(module, curr_func, - (int)stab_ptr->n_value >= 0 ? DataIsParam : DataIsLocal, + (int)n_value >= 0 ? DataIsParam : DataIsLocal, &loc, NULL, param_type, symname); symt_add_function_signature_parameter(module, (struct symt_function_signature*)curr_func->type, @@ -1441,7 +1450,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, loc.kind = loc_register; loc.offset = 0; - switch (stab_ptr->n_value) + switch (n_value) { case 0: loc.reg = CV_REG_EAX; break; case 1: loc.reg = CV_REG_ECX; break; @@ -1459,7 +1468,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, case 16: case 17: case 18: - case 19: loc.reg = CV_REG_ST0 + stab_ptr->n_value - 12; break; + case 19: loc.reg = CV_REG_ST0 + n_value - 12; break; case 21: case 22: case 23: @@ -1467,7 +1476,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, case 25: case 26: case 27: - case 28: loc.reg = CV_REG_XMM0 + stab_ptr->n_value - 21; break; + case 28: loc.reg = CV_REG_XMM0 + n_value - 21; break; case 29: case 30: case 31: @@ -1475,9 +1484,9 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, case 33: case 34: case 35: - case 36: loc.reg = CV_REG_MM0 + stab_ptr->n_value - 29; break; + case 36: loc.reg = CV_REG_MM0 + n_value - 29; break; default: - FIXME("Unknown register value (%lu)\n", (unsigned long)stab_ptr->n_value); + FIXME("Unknown register value (%lu)\n", (unsigned long)n_value); loc.reg = CV_REG_NONE; break; } @@ -1500,7 +1509,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, /* These are local variables */ loc.kind = loc_regrel; loc.reg = dbghelp_current_cpu->frame_regno; - loc.offset = stab_ptr->n_value; + loc.offset = n_value; if (curr_func != NULL) pending_add_var(&pending_block, ptr, DataIsLocal, &loc); break; case N_SLINE: @@ -1511,14 +1520,14 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, assert(source_idx >= 0); if (curr_func != NULL) { - unsigned long offset = stab_ptr->n_value; + unsigned long offset = n_value; if (module->type == DMT_MACHO) offset -= curr_func->address - load_offset; symt_add_func_line(module, curr_func, source_idx, stab_ptr->n_desc, offset); } else pending_add_line(&pending_func, source_idx, stab_ptr->n_desc, - stab_ptr->n_value, load_offset); + n_value, load_offset); break; case N_FUN: /* @@ -1545,13 +1554,13 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, * and offset of last function */ stabs_finalize_function(module, curr_func, - stab_ptr->n_value ? - (load_offset + stab_ptr->n_value - curr_func->address) : 0); + n_value ? + (load_offset + n_value - curr_func->address) : 0); } func_type = symt_new_function_signature(module, stabs_parse_type(ptr), -1); curr_func = symt_new_function(module, compiland, symname, - load_offset + stab_ptr->n_value, 0, + load_offset + n_value, 0, &func_type->symt); pending_flush(&pending_func, module, curr_func, NULL); } @@ -1560,7 +1569,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, /* some versions of GCC to use a N_FUN "" to mark the end of a function * and n_value contains the size of the func */ - stabs_finalize_function(module, curr_func, stab_ptr->n_value); + stabs_finalize_function(module, curr_func, n_value); curr_func = NULL; } break; @@ -1602,7 +1611,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, break; case N_UNDF: strs += strtabinc; - strtabinc = stab_ptr->n_value; + strtabinc = n_value; /* I'm not sure this is needed, so trace it before we obsolete it */ if (curr_func) { @@ -1615,7 +1624,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, /* Ignore this. We don't care what it points to. */ break; case N_BINCL: - stabs_add_include(stabs_new_include(ptr, stab_ptr->n_value)); + stabs_add_include(stabs_new_include(ptr, n_value)); assert(incl_stk < (int)(sizeof(incl) / sizeof(incl[0])) - 1); incl[++incl_stk] = source_idx; source_idx = source_new(module, NULL, ptr); @@ -1625,9 +1634,9 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, source_idx = incl[incl_stk--]; break; case N_EXCL: - if (stabs_add_include(stabs_find_include(ptr, stab_ptr->n_value)) < 0) + if (stabs_add_include(stabs_find_include(ptr, n_value)) < 0) { - ERR("Excluded header not found (%s,%ld)\n", ptr, (unsigned long)stab_ptr->n_value); + ERR("Excluded header not found (%s,%ld)\n", ptr, (unsigned long)n_value); module_reset_debug_info(module); ret = FALSE; goto done; @@ -1664,7 +1673,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, if (*ptr == '_') ptr++; stab_strcpy(symname, sizeof(symname), ptr); - callback(module, load_offset, symname, stab_ptr->n_value, + callback(module, load_offset, symname, n_value, is_public, is_global, stab_ptr->n_other, compiland, user); } break; @@ -1674,7 +1683,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset, } stabbuff[0] = '\0'; TRACE("0x%02x %lx %s\n", - stab_ptr->n_type, (unsigned long)stab_ptr->n_value, debugstr_a(strs + stab_ptr->n_strx)); + stab_ptr->n_type, (unsigned long)n_value, debugstr_a(strs + stab_ptr->n_strx)); } module->module.SymType = SymDia; module->module.CVSig = 'S' | ('T' << 8) | ('A' << 16) | ('B' << 24); diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index e4f1f15e1b4..d497e3133cc 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: 1dc9bb70cd16fa7b37e8fd6e82ed18311ddfbe38 + wine: 7d441808ac3b1d8bcef7795b636bda14c31c927b
4 years, 3 months
1
0
0
0
[reactos] 22/179: [WINESYNC] dbghelp: Translate the 32-bit Mach-O section header to the 64-bit one.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f631b4d12035fcb25616d…
commit f631b4d12035fcb25616dcfb51b1f52c0ff60043 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 13:14:05 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> 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 <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 1dc9bb70cd16fa7b37e8fd6e82ed18311ddfbe38 by Zebediah Figura <zfigura(a)codeweavers.com> --- 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 = §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].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
4 years, 3 months
1
0
0
0
[reactos] 21/179: [WINESYNC] dbghelp: Read the Mach-O segment command corresponding to the target's architecture.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=75e77444c6be66dacd390…
commit 75e77444c6be66dacd390e163e6cf274c3edd5f0 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 13:14:05 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:33 2020 +0200 [WINESYNC] dbghelp: Read the Mach-O segment command corresponding to the target's architecture. Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 0fc3c33637d4c8eff3f4373d374b3feb402bce4a by Zebediah Figura <zfigura(a)codeweavers.com> --- dll/win32/dbghelp/macho_module.c | 68 +++++++++++++++++++++++++++++----------- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 51 insertions(+), 19 deletions(-) diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 50fcca4d41f..52ea739b13a 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -89,10 +89,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_macho); #ifdef _WIN64 -typedef struct segment_command_64 macho_segment_command; typedef struct nlist_64 macho_nlist; #else -typedef struct segment_command macho_segment_command; typedef struct nlist macho_nlist; #endif @@ -506,12 +504,26 @@ static int macho_enum_load_commands(struct image_file_map *ifm, unsigned cmd, */ static int macho_count_sections(struct image_file_map* ifm, const struct load_command* lc, void* user) { - const macho_segment_command* sc = (const macho_segment_command*)lc; + char segname[16]; + uint32_t nsects; + + if (ifm->addr_size == 32) + { + const struct segment_command *sc = (const struct segment_command *)lc; + memcpy(segname, sc->segname, sizeof(segname)); + nsects = sc->nsects; + } + else + { + const struct segment_command_64 *sc = (const struct segment_command_64 *)lc; + memcpy(segname, sc->segname, sizeof(segname)); + nsects = sc->nsects; + } TRACE("(%p/%d, %p, %p) segment %s\n", ifm, ifm->u.macho.fd, lc, user, - debugstr_an(sc->segname, sizeof(sc->segname))); + debugstr_an(segname, sizeof(segname))); - ifm->u.macho.num_sections += sc->nsects; + ifm->u.macho.num_sections += nsects; return 0; } @@ -525,44 +537,64 @@ static int macho_count_sections(struct image_file_map* ifm, const struct load_co static int macho_load_section_info(struct image_file_map* ifm, const struct load_command* lc, void* user) { struct macho_file_map* fmap = &ifm->u.macho; - const macho_segment_command* sc = (const macho_segment_command*)lc; 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; + + if (ifm->addr_size == 32) + { + const struct segment_command *sc = (const struct segment_command *)lc; + vmaddr = sc->vmaddr; + vmsize = sc->vmsize; + memcpy(segname, sc->segname, sizeof(segname)); + nsects = sc->nsects; + section = (const macho_section*)(sc + 1); + } + else + { + const struct segment_command_64 *sc = (const struct segment_command_64 *)lc; + vmaddr = sc->vmaddr; + vmsize = sc->vmsize; + memcpy(segname, sc->segname, sizeof(segname)); + nsects = sc->nsects; + section = (const macho_section*)(sc + 1); + } TRACE("(%p/%d, %p, %p) before: 0x%08lx - 0x%08lx\n", fmap, fmap->fd, lc, user, (unsigned long)fmap->segs_start, (unsigned long)fmap->segs_size); - TRACE("Segment command vm: 0x%08lx - 0x%08lx\n", (unsigned long)sc->vmaddr, - (unsigned long)(sc->vmaddr + sc->vmsize)); + TRACE("Segment command vm: 0x%08lx - 0x%08lx\n", (unsigned long)vmaddr, + (unsigned long)(vmaddr + vmsize)); /* Images in the dyld shared cache have their segments mapped non-contiguously. We don't know how to properly locate any of the segments other than __TEXT, so ignore them. */ - ignore = (info->split_segs && strcmp(sc->segname, SEG_TEXT)); + ignore = (info->split_segs && strcmp(segname, SEG_TEXT)); - if (!strncmp(sc->segname, "WINE_", 5)) - TRACE("Ignoring special Wine segment %s\n", debugstr_an(sc->segname, sizeof(sc->segname))); - else if (!strncmp(sc->segname, "__PAGEZERO", 10)) + if (!strncmp(segname, "WINE_", 5)) + TRACE("Ignoring special Wine segment %s\n", debugstr_an(segname, sizeof(segname))); + else if (!strncmp(segname, "__PAGEZERO", 10)) TRACE("Ignoring __PAGEZERO segment\n"); else if (ignore) - TRACE("Ignoring %s segment because image has split segments\n", sc->segname); + TRACE("Ignoring %s segment because image has split segments\n", segname); else { /* If this segment starts before previously-known earliest, record new earliest. */ - if (sc->vmaddr < fmap->segs_start) - fmap->segs_start = sc->vmaddr; + if (vmaddr < fmap->segs_start) + fmap->segs_start = vmaddr; /* If this segment extends beyond previously-known furthest, record new furthest. */ - tmp = (sc->vmaddr + sc->vmsize + page_mask) & ~page_mask; + tmp = (vmaddr + vmsize + page_mask) & ~page_mask; if (fmap->segs_size < tmp) fmap->segs_size = tmp; TRACE("after: 0x%08lx - 0x%08lx\n", (unsigned long)fmap->segs_start, (unsigned long)fmap->segs_size); } - section = (const macho_section*)(sc + 1); - for (i = 0; i < sc->nsects; i++) + for (i = 0; i < nsects; i++) { fmap->sect[info->section_index].section = §ion[i]; fmap->sect[info->section_index].mapped = IMAGE_NO_MAP; diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 47ba99d45ee..7b8de6b1dbd 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: bf7681cb2f3a73239170b4f0ebc8f6b38bc027ec + wine: 0fc3c33637d4c8eff3f4373d374b3feb402bce4a
4 years, 3 months
1
0
0
0
[reactos] 20/179: [WINESYNC] dbghelp: Pass an image_file_map to macho_enum_load_commands().
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0d3ccc92fb935fb335a5d…
commit 0d3ccc92fb935fb335a5d2fde4d454eb3105e1ca Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 13:14:05 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:33 2020 +0200 [WINESYNC] dbghelp: Pass an image_file_map to macho_enum_load_commands(). Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id bf7681cb2f3a73239170b4f0ebc8f6b38bc027ec by Zebediah Figura <zfigura(a)codeweavers.com> --- dll/win32/dbghelp/macho_module.c | 38 ++++++++++++++++++++++---------------- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 679c2030b6a..50fcca4d41f 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -467,10 +467,11 @@ static const struct load_command* macho_next_load_command(const struct load_comm * callback. If >=0, that's the count of load commands successfully * processed. */ -static int macho_enum_load_commands(struct macho_file_map* fmap, unsigned cmd, - int (*cb)(struct macho_file_map*, const struct load_command*, void*), +static int macho_enum_load_commands(struct image_file_map *ifm, unsigned cmd, + int (*cb)(struct image_file_map*, const struct load_command*, void*), void* user) { + struct macho_file_map* fmap = &ifm->u.macho; const struct load_command* lc; int i; int count = 0; @@ -488,7 +489,7 @@ static int macho_enum_load_commands(struct macho_file_map* fmap, unsigned cmd, if (cmd && cmd != lc->cmd) continue; count++; - result = cb(fmap, lc, user); + result = cb(ifm, lc, user); TRACE("load_command[%d] (%p), cmd %u; callback => %d\n", i, lc, lc->cmd, result); if (result) return (result < 0) ? result : count; } @@ -503,13 +504,14 @@ static int macho_enum_load_commands(struct macho_file_map* fmap, unsigned cmd, * significant sections in a Mach-O file. All commands are * expected to be of LC_SEGMENT[_64] type. */ -static int macho_count_sections(struct macho_file_map* fmap, const struct load_command* lc, void* user) +static int macho_count_sections(struct image_file_map* ifm, const struct load_command* lc, void* user) { const macho_segment_command* sc = (const macho_segment_command*)lc; - TRACE("(%p/%d, %p, %p) segment %s\n", fmap, fmap->fd, lc, user, debugstr_an(sc->segname, sizeof(sc->segname))); + TRACE("(%p/%d, %p, %p) segment %s\n", ifm, ifm->u.macho.fd, lc, user, + debugstr_an(sc->segname, sizeof(sc->segname))); - fmap->num_sections += sc->nsects; + ifm->u.macho.num_sections += sc->nsects; return 0; } @@ -520,8 +522,9 @@ static int macho_count_sections(struct macho_file_map* fmap, const struct load_c * range covered by the segments of a Mach-O file and builds the * section map. All commands are expected to be of LC_SEGMENT[_64] type. */ -static int macho_load_section_info(struct macho_file_map* fmap, const struct load_command* lc, void* user) +static int macho_load_section_info(struct image_file_map* ifm, const struct load_command* lc, void* user) { + struct macho_file_map* fmap = &ifm->u.macho; const macho_segment_command* sc = (const macho_segment_command*)lc; struct section_info* info = user; BOOL ignore; @@ -576,9 +579,9 @@ static int macho_load_section_info(struct macho_file_map* fmap, const struct loa * Callback for macho_enum_load_commands. Records the UUID load * command of a Mach-O file. */ -static int find_uuid(struct macho_file_map* fmap, const struct load_command* lc, void* user) +static int find_uuid(struct image_file_map* ifm, const struct load_command* lc, void* user) { - fmap->uuid = (const struct uuid_command*)lc; + ifm->u.macho.uuid = (const struct uuid_command*)lc; return 1; } @@ -700,7 +703,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW, TRACE("... verified Mach header\n"); fmap->num_sections = 0; - if (macho_enum_load_commands(fmap, target_cmd, macho_count_sections, NULL) < 0) + if (macho_enum_load_commands(ifm, target_cmd, macho_count_sections, NULL) < 0) goto done; TRACE("%d sections\n", fmap->num_sections); @@ -713,7 +716,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW, info.split_segs = split_segs; info.section_index = 0; - if (macho_enum_load_commands(fmap, target_cmd, macho_load_section_info, &info) < 0) + if (macho_enum_load_commands(ifm, target_cmd, macho_load_section_info, &info) < 0) { fmap->num_sections = 0; goto done; @@ -723,7 +726,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW, TRACE("segs_start: 0x%08lx, segs_size: 0x%08lx\n", (unsigned long)fmap->segs_start, (unsigned long)fmap->segs_size); - if (macho_enum_load_commands(fmap, LC_UUID, find_uuid, NULL) < 0) + if (macho_enum_load_commands(ifm, LC_UUID, find_uuid, NULL) < 0) goto done; if (fmap->uuid) { @@ -857,9 +860,10 @@ static void macho_stabs_def_cb(struct module* module, unsigned long load_offset, * Callback for macho_enum_load_commands. Processes the LC_SYMTAB * load commands from the Mach-O file. */ -static int macho_parse_symtab(struct macho_file_map* fmap, +static int macho_parse_symtab(struct image_file_map* ifm, const struct load_command* lc, void* user) { + struct macho_file_map* fmap = &ifm->u.macho; const struct symtab_command* sc = (const struct symtab_command*)lc; struct macho_debug_info* mdi = user; const macho_nlist* stab; @@ -1219,6 +1223,7 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module) BOOL ret = FALSE; struct macho_debug_info mdi; int result; + struct image_file_map *ifm; struct macho_file_map *fmap; if (module->type != DMT_MACHO || !module->format_info[DFI_MACHO]->u.macho_info) @@ -1227,7 +1232,8 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module) return FALSE; } - fmap = &module->format_info[DFI_MACHO]->u.macho_info->file_map.u.macho; + ifm = &module->format_info[DFI_MACHO]->u.macho_info->file_map; + fmap = &ifm->u.macho; TRACE("(%p, %p/%d)\n", module, fmap, fmap->fd); @@ -1246,7 +1252,7 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module) mdi.module = module; pool_init(&mdi.pool, 65536); hash_table_init(&mdi.pool, &mdi.ht_symtab, 256); - result = macho_enum_load_commands(fmap, LC_SYMTAB, macho_parse_symtab, &mdi); + result = macho_enum_load_commands(ifm, LC_SYMTAB, macho_parse_symtab, &mdi); if (result > 0) ret = TRUE; else if (result < 0) @@ -1255,7 +1261,7 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module) if (!(dbghelp_options & SYMOPT_PUBLICS_ONLY) && fmap->dsym) { mdi.fmap = &fmap->dsym->u.macho; - result = macho_enum_load_commands(mdi.fmap, LC_SYMTAB, macho_parse_symtab, &mdi); + result = macho_enum_load_commands(fmap->dsym, LC_SYMTAB, macho_parse_symtab, &mdi); if (result > 0) ret = TRUE; else if (result < 0) diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index bb75907c7a0..47ba99d45ee 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: f2e38e17956197180ad730fd00a267fc25d4f238 + wine: bf7681cb2f3a73239170b4f0ebc8f6b38bc027ec
4 years, 3 months
1
0
0
0
[reactos] 19/179: [WINESYNC] dbghelp: Read the 32-bit Mach-O header.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9985483679bdc61852251…
commit 9985483679bdc618522519b2d1092f72e0dba3b2 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 13:14:04 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:33 2020 +0200 [WINESYNC] dbghelp: Read the 32-bit Mach-O header. It is identical to the 64-bit header, except for the "reserved" field. Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id f2e38e17956197180ad730fd00a267fc25d4f238 by Zebediah Figura <zfigura(a)codeweavers.com> --- dll/win32/dbghelp/image_private.h | 4 +--- dll/win32/dbghelp/macho_module.c | 2 +- sdk/tools/winesync/dbghelp.cfg | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/dll/win32/dbghelp/image_private.h b/dll/win32/dbghelp/image_private.h index 060e0272f1a..329236c9bf5 100644 --- a/dll/win32/dbghelp/image_private.h +++ b/dll/win32/dbghelp/image_private.h @@ -48,10 +48,8 @@ #include <mach-o/loader.h> #ifdef _WIN64 -typedef struct mach_header_64 macho_mach_header; typedef struct section_64 macho_section; #else -typedef struct mach_header macho_mach_header; typedef struct section macho_section; #endif #endif @@ -98,7 +96,7 @@ struct image_file_map struct image_file_map* dsym; /* the debug symbols file associated with this one */ #ifdef HAVE_MACH_O_LOADER_H - macho_mach_header mach_header; + struct mach_header mach_header; const struct load_command* load_commands; const struct uuid_command* uuid; diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index ee35af53b17..679c2030b6a 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -1196,7 +1196,7 @@ static BOOL image_uses_split_segs(HANDLE process, unsigned long load_addr) struct process *pcs = process_find_by_handle(process); cpu_type_t target_cpu = (pcs->is_64bit) ? CPU_TYPE_X86_64 : CPU_TYPE_X86; uint32_t target_magic = (pcs->is_64bit) ? MH_MAGIC_64 : MH_MAGIC; - macho_mach_header header; + struct mach_header header; if (ReadProcessMemory(process, (void*)load_addr, &header, sizeof(header), NULL) && header.magic == target_magic && header.cputype == target_cpu && diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index c5c81db8387..bb75907c7a0 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: f0ee3471f369bc3d3911647c7efa63fc503e6ce2 + wine: f2e38e17956197180ad730fd00a267fc25d4f238
4 years, 3 months
1
0
0
0
[reactos] 18/179: [WINESYNC] dbghelp: Determine the target Mach-O architecture from the process's architecture.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=887025f3a05241da3ba19…
commit 887025f3a05241da3ba19dd57e694da9cead3cbb Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 13:06:46 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:33 2020 +0200 [WINESYNC] dbghelp: Determine the target Mach-O architecture from the process's architecture. Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id f0ee3471f369bc3d3911647c7efa63fc503e6ce2 by Zebediah Figura <zfigura(a)codeweavers.com> --- dll/win32/dbghelp/dbghelp_private.h | 2 +- dll/win32/dbghelp/macho_module.c | 66 ++++++++++++++++++------------------- dll/win32/dbghelp/module.c | 2 +- sdk/tools/winesync/dbghelp.cfg | 2 +- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/dll/win32/dbghelp/dbghelp_private.h b/dll/win32/dbghelp/dbghelp_private.h index 24db267a6b6..537b9bc087b 100644 --- a/dll/win32/dbghelp/dbghelp_private.h +++ b/dll/win32/dbghelp/dbghelp_private.h @@ -621,7 +621,7 @@ extern int elf_is_in_thunk_area(unsigned long addr, const struct elf_th /* macho_module.c */ extern BOOL macho_enum_modules(HANDLE hProc, enum_modules_cb, void*) DECLSPEC_HIDDEN; extern BOOL macho_fetch_file_info(HANDLE process, const WCHAR* name, unsigned long load_addr, DWORD_PTR* base, DWORD* size, DWORD* checksum) DECLSPEC_HIDDEN; -extern BOOL macho_load_debug_info(struct module* module) DECLSPEC_HIDDEN; +extern BOOL macho_load_debug_info(struct process *pcs, struct module* module) DECLSPEC_HIDDEN; extern struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsigned long) DECLSPEC_HIDDEN; extern BOOL macho_read_wine_loader_dbg_info(struct process* pcs) DECLSPEC_HIDDEN; diff --git a/dll/win32/dbghelp/macho_module.c b/dll/win32/dbghelp/macho_module.c index 7c40801d89c..ee35af53b17 100644 --- a/dll/win32/dbghelp/macho_module.c +++ b/dll/win32/dbghelp/macho_module.c @@ -91,17 +91,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_macho); #ifdef _WIN64 typedef struct segment_command_64 macho_segment_command; typedef struct nlist_64 macho_nlist; - -#define TARGET_CPU_TYPE CPU_TYPE_X86_64 -#define TARGET_MH_MAGIC MH_MAGIC_64 -#define TARGET_SEGMENT_COMMAND LC_SEGMENT_64 #else typedef struct segment_command macho_segment_command; typedef struct nlist macho_nlist; - -#define TARGET_CPU_TYPE CPU_TYPE_X86 -#define TARGET_MH_MAGIC MH_MAGIC -#define TARGET_SEGMENT_COMMAND LC_SEGMENT #endif @@ -610,7 +602,8 @@ static inline void reset_file_map(struct image_file_map* ifm) * * Maps a Mach-O file into memory (and checks it's a real Mach-O file) */ -static BOOL macho_map_file(const WCHAR* filenameW, BOOL split_segs, struct image_file_map* ifm) +static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW, + BOOL split_segs, struct image_file_map* ifm) { struct macho_file_map* fmap = &ifm->u.macho; struct fat_header fat_header; @@ -620,17 +613,16 @@ static BOOL macho_map_file(const WCHAR* filenameW, BOOL split_segs, struct image unsigned len; struct section_info info; BOOL ret = FALSE; + cpu_type_t target_cpu = (pcs->is_64bit) ? CPU_TYPE_X86_64 : CPU_TYPE_X86; + uint32_t target_magic = (pcs->is_64bit) ? MH_MAGIC_64 : MH_MAGIC; + uint32_t target_cmd = (pcs->is_64bit) ? LC_SEGMENT_64 : LC_SEGMENT; TRACE("(%s, %p)\n", debugstr_w(filenameW), fmap); reset_file_map(ifm); ifm->modtype = DMT_MACHO; -#ifdef _WIN64 - ifm->addr_size = 64; -#else - ifm->addr_size = 32; -#endif + ifm->addr_size = (pcs->is_64bit) ? 64 : 32; len = WideCharToMultiByte(CP_UNIXCP, 0, filenameW, -1, NULL, 0, NULL, NULL); if (!(filename = HeapAlloc(GetProcessHeap(), 0, len))) @@ -670,14 +662,14 @@ static BOOL macho_map_file(const WCHAR* filenameW, BOOL split_segs, struct image struct fat_arch fat_arch; if (read(fmap->fd, &fat_arch, sizeof(fat_arch)) != sizeof(fat_arch)) goto done; - if (swap_ulong_be_to_host(fat_arch.cputype) == TARGET_CPU_TYPE) + if (swap_ulong_be_to_host(fat_arch.cputype) == target_cpu) { fmap->arch_offset = swap_ulong_be_to_host(fat_arch.offset); break; } } if (i >= narch) goto done; - TRACE("... found target arch (%d)\n", TARGET_CPU_TYPE); + TRACE("... found target arch (%d)\n", target_cpu); } else { @@ -691,8 +683,8 @@ static BOOL macho_map_file(const WCHAR* filenameW, BOOL split_segs, struct image goto done; TRACE("... got possible Mach header\n"); /* and check for a Mach-O header */ - if (fmap->mach_header.magic != TARGET_MH_MAGIC || - fmap->mach_header.cputype != TARGET_CPU_TYPE) goto done; + if (fmap->mach_header.magic != target_magic || + fmap->mach_header.cputype != target_cpu) goto done; /* Make sure the file type is one of the ones we expect. */ switch (fmap->mach_header.filetype) { @@ -708,7 +700,7 @@ static BOOL macho_map_file(const WCHAR* filenameW, BOOL split_segs, struct image TRACE("... verified Mach header\n"); fmap->num_sections = 0; - if (macho_enum_load_commands(fmap, TARGET_SEGMENT_COMMAND, macho_count_sections, NULL) < 0) + if (macho_enum_load_commands(fmap, target_cmd, macho_count_sections, NULL) < 0) goto done; TRACE("%d sections\n", fmap->num_sections); @@ -721,7 +713,7 @@ static BOOL macho_map_file(const WCHAR* filenameW, BOOL split_segs, struct image info.split_segs = split_segs; info.section_index = 0; - if (macho_enum_load_commands(fmap, TARGET_SEGMENT_COMMAND, macho_load_section_info, &info) < 0) + if (macho_enum_load_commands(fmap, target_cmd, macho_load_section_info, &info) < 0) { fmap->num_sections = 0; goto done; @@ -1072,11 +1064,11 @@ static void macho_finish_stabs(struct module* module, struct hash_table* ht_symt * TRUE. If it can't be mapped or its UUID doesn't match, return * FALSE. */ -static BOOL try_dsym(const WCHAR* path, struct macho_file_map* fmap) +static BOOL try_dsym(struct process *pcs, const WCHAR* path, struct macho_file_map* fmap) { struct image_file_map dsym_ifm; - if (macho_map_file(path, FALSE, &dsym_ifm)) + if (macho_map_file(pcs, path, FALSE, &dsym_ifm)) { char uuid_string[UUID_STRING_LEN]; @@ -1110,7 +1102,7 @@ static BOOL try_dsym(const WCHAR* path, struct macho_file_map* fmap) * "dsymutil --flat". Finally, use Spotlight to search for a * .dSYM bundle with the same UUID as the module file. */ -static void find_and_map_dsym(struct module* module) +static void find_and_map_dsym(struct process *pcs, struct module* module) { static const WCHAR dot_dsym[] = {'.','d','S','Y','M',0}; static const WCHAR dsym_subpath[] = {'/','C','o','n','t','e','n','t','s','/','R','e','s','o','u','r','c','e','s','/','D','W','A','R','F','/',0}; @@ -1142,12 +1134,12 @@ static void find_and_map_dsym(struct module* module) strcatW(path, dsym_subpath); strcatW(path, p); - if (try_dsym(path, fmap)) + if (try_dsym(pcs, path, fmap)) goto found; strcpyW(path + strlenW(module->module.LoadedImageName), dot_dwarf); - if (try_dsym(path, fmap)) + if (try_dsym(pcs, path, fmap)) goto found; format_uuid(fmap->uuid->uuid, uuid_string); @@ -1175,7 +1167,7 @@ static void find_and_map_dsym(struct module* module) strcatW(path, p); CFRelease(item_path); - if (try_dsym(path, fmap)) + if (try_dsym(pcs, path, fmap)) goto found; } } @@ -1201,9 +1193,13 @@ static BOOL image_uses_split_segs(HANDLE process, unsigned long load_addr) if (process && load_addr) { + struct process *pcs = process_find_by_handle(process); + cpu_type_t target_cpu = (pcs->is_64bit) ? CPU_TYPE_X86_64 : CPU_TYPE_X86; + uint32_t target_magic = (pcs->is_64bit) ? MH_MAGIC_64 : MH_MAGIC; macho_mach_header header; + if (ReadProcessMemory(process, (void*)load_addr, &header, sizeof(header), NULL) && - header.magic == TARGET_MH_MAGIC && header.cputype == TARGET_CPU_TYPE && + header.magic == target_magic && header.cputype == target_cpu && header.flags & MACHO_DYLD_IN_SHARED_CACHE) { split_segs = TRUE; @@ -1218,7 +1214,7 @@ static BOOL image_uses_split_segs(HANDLE process, unsigned long load_addr) * * Loads Mach-O debugging information from the module image file. */ -BOOL macho_load_debug_info(struct module* module) +BOOL macho_load_debug_info(struct process *pcs, struct module* module) { BOOL ret = FALSE; struct macho_debug_info mdi; @@ -1239,7 +1235,7 @@ BOOL macho_load_debug_info(struct module* module) if (!(dbghelp_options & SYMOPT_PUBLICS_ONLY)) { - find_and_map_dsym(module); + find_and_map_dsym(pcs, module); if (dwarf2_parse(module, module->reloc_delta, NULL /* FIXME: some thunks to deal with ? */, &module->format_info[DFI_MACHO]->u.macho_info->file_map)) @@ -1281,12 +1277,16 @@ BOOL macho_fetch_file_info(HANDLE process, const WCHAR* name, unsigned long load DWORD* size, DWORD* checksum) { struct image_file_map fmap; + struct process *pcs; BOOL split_segs; TRACE("(%s, %p, %p, %p)\n", debugstr_w(name), base, size, checksum); + pcs = process_find_by_handle(process); + if (!pcs) return FALSE; + split_segs = image_uses_split_segs(process, load_addr); - if (!macho_map_file(name, split_segs, &fmap)) return FALSE; + if (!macho_map_file(pcs, name, split_segs, &fmap)) return FALSE; if (base) *base = fmap.u.macho.segs_start; *size = fmap.u.macho.segs_size; *checksum = calc_crc32(fmap.u.macho.fd); @@ -1375,7 +1375,7 @@ static BOOL macho_load_file(struct process* pcs, const WCHAR* filename, load_addr, macho_info, macho_info->flags); split_segs = image_uses_split_segs(pcs->handle, load_addr); - if (!macho_map_file(filename, split_segs, &fmap)) return FALSE; + if (!macho_map_file(pcs, filename, split_segs, &fmap)) return FALSE; /* Find the dynamic loader's table of images loaded into the process. */ @@ -1415,7 +1415,7 @@ static BOOL macho_load_file(struct process* pcs, const WCHAR* filename, reset_file_map(&fmap); if (dbghelp_options & SYMOPT_DEFERRED_LOADS) macho_info->module->module.SymType = SymDeferred; - else if (!macho_load_debug_info(macho_info->module)) + else if (!macho_load_debug_info(pcs, macho_info->module)) ret = FALSE; macho_info->module->format_info[DFI_MACHO]->u.macho_info->in_use = 1; @@ -1930,7 +1930,7 @@ struct module* macho_load_module(struct process* pcs, const WCHAR* name, unsign return NULL; } -BOOL macho_load_debug_info(struct module* module) +BOOL macho_load_debug_info(struct process *pcs, struct module* module) { return FALSE; } diff --git a/dll/win32/dbghelp/module.c b/dll/win32/dbghelp/module.c index 8f7150460be..b47fbb2af66 100644 --- a/dll/win32/dbghelp/module.c +++ b/dll/win32/dbghelp/module.c @@ -415,7 +415,7 @@ BOOL module_get_debug(struct module_pair* pair) break; #ifndef DBGHELP_STATIC_LIB case DMT_MACHO: - ret = macho_load_debug_info(pair->effective); + ret = macho_load_debug_info(pair->pcs, pair->effective); break; #endif default: diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 0014cc129c2..c5c81db8387 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: 99e818154a803c8cfd2478b9db3b455fc9adef30 + wine: f0ee3471f369bc3d3911647c7efa63fc503e6ce2
4 years, 3 months
1
0
0
0
[reactos] 17/179: [WINESYNC] dbghelp: Read the r_debug and link_map structs corresponding to the target's architecture.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c719e68907cdea1b1dadb…
commit c719e68907cdea1b1dadb4e99d135474ee7b9c04 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 13:06:43 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:32 2020 +0200 [WINESYNC] dbghelp: Read the r_debug and link_map structs corresponding to the target's architecture. Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 99e818154a803c8cfd2478b9db3b455fc9adef30 by Zebediah Figura <zfigura(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 110 +++++++++++++++++++++++++++++++---------- sdk/tools/winesync/dbghelp.cfg | 2 +- 2 files changed, 85 insertions(+), 27 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index c43d10812c3..32ce3455db0 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -78,6 +78,15 @@ struct r_debug }; #endif /* HAVE_STRUCT_R_DEBUG */ +struct r_debug32 +{ + int r_version; + DWORD r_map; + Elf32_Addr r_brk; + int r_state; + Elf32_Addr r_ldbase; +}; + #ifndef HAVE_STRUCT_LINK_MAP struct link_map { @@ -88,6 +97,14 @@ struct link_map }; #endif /* HAVE_STRUCT_LINK_MAP */ +struct link_map32 +{ + Elf32_Addr l_addr; + DWORD l_name; + DWORD l_ld; + DWORD l_next, l_prev; +}; + WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); struct elf_info @@ -1648,36 +1665,77 @@ static BOOL elf_enum_modules_internal(const struct process* pcs, const WCHAR* main_name, enum_elf_modules_cb cb, void* user) { - struct r_debug dbg_hdr; - void* lm_addr; - struct link_map lm; - char bufstr[256]; - WCHAR bufstrW[MAX_PATH]; - - if (!pcs->dbg_hdr_addr || - !ReadProcessMemory(pcs->handle, (void*)pcs->dbg_hdr_addr, - &dbg_hdr, sizeof(dbg_hdr), NULL)) - return FALSE; + WCHAR bufstrW[MAX_PATH]; + char bufstr[256]; + void *lm_addr; - /* Now walk the linked list. In all known ELF implementations, - * the dynamic loader maintains this linked list for us. In some - * cases the first entry doesn't appear with a name, in other cases it - * does. - */ - for (lm_addr = (void*)dbg_hdr.r_map; lm_addr; lm_addr = (void*)lm.l_next) + if (pcs->is_64bit) { - if (!ReadProcessMemory(pcs->handle, lm_addr, &lm, sizeof(lm), NULL)) - return FALSE; + struct r_debug dbg_hdr; + struct link_map lm; + + if (!pcs->dbg_hdr_addr || + !ReadProcessMemory(pcs->handle, (void*)pcs->dbg_hdr_addr, + &dbg_hdr, sizeof(dbg_hdr), NULL)) + return FALSE; - if (lm.l_prev != NULL && /* skip first entry, normally debuggee itself */ - lm.l_name != NULL && - ReadProcessMemory(pcs->handle, lm.l_name, bufstr, sizeof(bufstr), NULL)) + /* Now walk the linked list. In all known ELF implementations, + * the dynamic loader maintains this linked list for us. In some + * cases the first entry doesn't appear with a name, in other cases it + * does. + */ + for (lm_addr = (void*)dbg_hdr.r_map; lm_addr; lm_addr = (void*)lm.l_next) { - bufstr[sizeof(bufstr) - 1] = '\0'; - MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW, sizeof(bufstrW) / sizeof(WCHAR)); - if (main_name && !bufstrW[0]) strcpyW(bufstrW, main_name); - if (!cb(bufstrW, (unsigned long)lm.l_addr, (unsigned long)lm.l_ld, FALSE, user)) break; - } + if (!ReadProcessMemory(pcs->handle, lm_addr, &lm, sizeof(lm), NULL)) + return FALSE; + + if (lm.l_prev != NULL && /* skip first entry, normally debuggee itself */ + lm.l_name != NULL && + ReadProcessMemory(pcs->handle, lm.l_name, bufstr, sizeof(bufstr), NULL)) + { + bufstr[sizeof(bufstr) - 1] = '\0'; + MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW, + sizeof(bufstrW) / sizeof(WCHAR)); + if (main_name && !bufstrW[0]) strcpyW(bufstrW, main_name); + if (!cb(bufstrW, (unsigned long)lm.l_addr, (unsigned long)lm.l_ld, FALSE, user)) + break; + } + } + } + else + { + struct r_debug32 dbg_hdr; + struct link_map32 lm; + + if (!pcs->dbg_hdr_addr || + !ReadProcessMemory(pcs->handle, (void*)pcs->dbg_hdr_addr, + &dbg_hdr, sizeof(dbg_hdr), NULL)) + return FALSE; + + /* Now walk the linked list. In all known ELF implementations, + * the dynamic loader maintains this linked list for us. In some + * cases the first entry doesn't appear with a name, in other cases it + * does. + */ + for (lm_addr = (void *)(DWORD_PTR)dbg_hdr.r_map; lm_addr; + lm_addr = (void *)(DWORD_PTR)lm.l_next) + { + if (!ReadProcessMemory(pcs->handle, lm_addr, &lm, sizeof(lm), NULL)) + return FALSE; + + if (lm.l_prev && /* skip first entry, normally debuggee itself */ + lm.l_name && + ReadProcessMemory(pcs->handle, (void *)(DWORD_PTR)lm.l_name, + bufstr, sizeof(bufstr), NULL)) + { + bufstr[sizeof(bufstr) - 1] = '\0'; + MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW, + sizeof(bufstrW) / sizeof(WCHAR)); + if (main_name && !bufstrW[0]) strcpyW(bufstrW, main_name); + if (!cb(bufstrW, (unsigned long)lm.l_addr, (unsigned long)lm.l_ld, FALSE, user)) + break; + } + } } #ifdef AT_SYSINFO_EHDR diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 7069689f26f..0014cc129c2 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: 7e4fd17d5b62e888fd6a3a452dc3ee22dfb74ccd + wine: 99e818154a803c8cfd2478b9db3b455fc9adef30
4 years, 3 months
1
0
0
0
[reactos] 16/179: [WINESYNC] dbghelp: Translate the 32-bit ELF symbol struct to the 64-bit one.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=76ad5c4b684579b8d73bd…
commit 76ad5c4b684579b8d73bd0b35ec91fe2ed773982 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 13:05:44 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:32 2020 +0200 [WINESYNC] dbghelp: Translate the 32-bit ELF symbol struct to the 64-bit one. Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 7e4fd17d5b62e888fd6a3a452dc3ee22dfb74ccd by Zebediah Figura <zfigura(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 87 ++++++++++++++++++++++++--------------- dll/win32/dbghelp/image_private.h | 9 +--- sdk/tools/winesync/dbghelp.cfg | 2 +- 3 files changed, 55 insertions(+), 43 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 0cbeb98c407..c43d10812c3 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -101,7 +101,7 @@ struct elf_info struct symtab_elt { struct hash_table_elt ht_elt; - const Elf_Sym* symp; + Elf64_Sym sym; struct symt_compiland* compiland; unsigned used; }; @@ -548,13 +548,13 @@ static void elf_hash_symtab(struct module* module, struct pool* pool, const char* symname; struct symt_compiland* compiland = NULL; const char* ptr; - const Elf_Sym* symp; struct symtab_elt* ste; struct image_section_map ism, ism_str; + const char *symtab; if (!elf_find_section(fmap, ".symtab", SHT_SYMTAB, &ism) && !elf_find_section(fmap, ".dynsym", SHT_DYNSYM, &ism)) return; - if ((symp = (const Elf_Sym*)image_map_section(&ism)) == IMAGE_NO_MAP) return; + if ((symtab = image_map_section(&ism)) == IMAGE_NO_MAP) return; ism_str.fmap = ism.fmap; ism_str.sidx = fmap->u.elf.sect[ism.sidx].shdr.sh_link; if ((strp = image_map_section(&ism_str)) == IMAGE_NO_MAP) @@ -563,33 +563,50 @@ static void elf_hash_symtab(struct module* module, struct pool* pool, return; } - nsym = image_get_map_size(&ism) / sizeof(*symp); + nsym = image_get_map_size(&ism) / + (fmap->addr_size == 32 ? sizeof(Elf32_Sym) : sizeof(Elf64_Sym)); for (j = 0; thunks[j].symname; j++) thunks[j].rva_start = thunks[j].rva_end = 0; - for (i = 0; i < nsym; i++, symp++) + for (i = 0; i < nsym; i++) { + Elf64_Sym sym; + + if (fmap->addr_size == 32) + { + Elf32_Sym *sym32 = &((Elf32_Sym *)symtab)[i]; + + sym.st_name = sym32->st_name; + sym.st_value = sym32->st_value; + sym.st_size = sym32->st_size; + sym.st_info = sym32->st_info; + sym.st_other = sym32->st_other; + sym.st_shndx = sym32->st_shndx; + } + else + sym = ((Elf64_Sym *)symtab)[i]; + /* Ignore certain types of entries which really aren't of that much * interest. */ - if ((ELF32_ST_TYPE(symp->st_info) != STT_NOTYPE && - ELF32_ST_TYPE(symp->st_info) != STT_FILE && - ELF32_ST_TYPE(symp->st_info) != STT_OBJECT && - ELF32_ST_TYPE(symp->st_info) != STT_FUNC) || - symp->st_shndx == SHN_UNDEF) + if ((ELF32_ST_TYPE(sym.st_info) != STT_NOTYPE && + ELF32_ST_TYPE(sym.st_info) != STT_FILE && + ELF32_ST_TYPE(sym.st_info) != STT_OBJECT && + ELF32_ST_TYPE(sym.st_info) != STT_FUNC) || + sym.st_shndx == SHN_UNDEF) { continue; } - symname = strp + symp->st_name; + symname = strp + sym.st_name; /* handle some specific symtab (that we'll throw away when done) */ - switch (ELF32_ST_TYPE(symp->st_info)) + switch (ELF32_ST_TYPE(sym.st_info)) { case STT_FILE: if (symname) - compiland = symt_new_compiland(module, symp->st_value, + compiland = symt_new_compiland(module, sym.st_value, source_new(module, NULL, symname)); else compiland = NULL; @@ -600,8 +617,8 @@ static void elf_hash_symtab(struct module* module, struct pool* pool, { if (!strcmp(symname, thunks[j].symname)) { - thunks[j].rva_start = symp->st_value; - thunks[j].rva_end = symp->st_value + symp->st_size; + thunks[j].rva_start = sym.st_value; + thunks[j].rva_end = sym.st_value + sym.st_size; break; } } @@ -635,7 +652,7 @@ static void elf_hash_symtab(struct module* module, struct pool* pool, ste->ht_elt.name = n; } } - ste->symp = symp; + ste->sym = sym; ste->compiland = compiland; ste->used = 0; hash_table_add(ht_symtab, &ste->ht_elt); @@ -651,7 +668,7 @@ static void elf_hash_symtab(struct module* module, struct pool* pool, * * lookup a symbol by name in our internal hash table for the symtab */ -static const Elf_Sym* elf_lookup_symtab(const struct module* module, +static const Elf64_Sym *elf_lookup_symtab(const struct module* module, const struct hash_table* ht_symtab, const char* name, const struct symt* compiland) { @@ -698,8 +715,8 @@ static const Elf_Sym* elf_lookup_symtab(const struct module* module, { FIXME("Already found symbol %s (%s) in symtab %s @%08x and %s @%08x\n", name, compiland_name, - source_get(module, result->compiland->source), (unsigned int)result->symp->st_value, - source_get(module, ste->compiland->source), (unsigned int)ste->symp->st_value); + source_get(module, result->compiland->source), (unsigned int)result->sym.st_value, + source_get(module, ste->compiland->source), (unsigned int)ste->sym.st_value); } else { @@ -713,7 +730,7 @@ static const Elf_Sym* elf_lookup_symtab(const struct module* module, debugstr_w(module->module.ModuleName), name); return NULL; } - return result->symp; + return &result->sym; } /****************************************************************** @@ -727,7 +744,7 @@ static void elf_finish_stabs_info(struct module* module, const struct hash_table struct hash_table_iter hti; void* ptr; struct symt_ht* sym; - const Elf_Sym* symp; + const Elf64_Sym* symp; struct elf_module_info* elf_info = module->format_info[DFI_ELF]->u.elf_info; hash_table_iter_init(&module->ht_symbols, &hti, NULL); @@ -748,9 +765,10 @@ static void elf_finish_stabs_info(struct module* module, const struct hash_table { if (((struct symt_function*)sym)->address != elf_info->elf_addr && ((struct symt_function*)sym)->address != elf_info->elf_addr + symp->st_value) - FIXME("Changing address for %p/%s!%s from %08lx to %08lx\n", + FIXME("Changing address for %p/%s!%s from %08lx to %s\n", sym, debugstr_w(module->module.ModuleName), sym->hash_elt.name, - ((struct symt_function*)sym)->address, elf_info->elf_addr + symp->st_value); + ((struct symt_function*)sym)->address, + wine_dbgstr_longlong(elf_info->elf_addr + symp->st_value)); if (((struct symt_function*)sym)->size && ((struct symt_function*)sym)->size != symp->st_size) FIXME("Changing size for %p/%s!%s from %08lx to %08x\n", sym, debugstr_w(module->module.ModuleName), sym->hash_elt.name, @@ -776,9 +794,10 @@ static void elf_finish_stabs_info(struct module* module, const struct hash_table { if (((struct symt_data*)sym)->u.var.offset != elf_info->elf_addr && ((struct symt_data*)sym)->u.var.offset != elf_info->elf_addr + symp->st_value) - FIXME("Changing address for %p/%s!%s from %08lx to %08lx\n", + FIXME("Changing address for %p/%s!%s from %08lx to %s\n", sym, debugstr_w(module->module.ModuleName), sym->hash_elt.name, - ((struct symt_function*)sym)->address, elf_info->elf_addr + symp->st_value); + ((struct symt_function*)sym)->address, + wine_dbgstr_longlong(elf_info->elf_addr + symp->st_value)); ((struct symt_data*)sym)->u.var.offset = elf_info->elf_addr + symp->st_value; ((struct symt_data*)sym)->kind = (ELF32_ST_BIND(symp->st_info) == STB_LOCAL) ? DataIsFileStatic : DataIsGlobal; @@ -817,13 +836,13 @@ static int elf_new_wine_thunks(struct module* module, const struct hash_table* h { if (ste->used) continue; - addr = module->reloc_delta + ste->symp->st_value; + addr = module->reloc_delta + ste->sym.st_value; - j = elf_is_in_thunk_area(ste->symp->st_value, thunks); + j = elf_is_in_thunk_area(ste->sym.st_value, thunks); if (j >= 0) /* thunk found */ { symt_new_thunk(module, ste->compiland, ste->ht_elt.name, thunks[j].ordinal, - addr, ste->symp->st_size); + addr, ste->sym.st_size); } else { @@ -839,19 +858,19 @@ static int elf_new_wine_thunks(struct module* module, const struct hash_table* h * used yet (ie we have no debug information on them) * That's the case, for example, of the .spec.c files */ - switch (ELF32_ST_TYPE(ste->symp->st_info)) + switch (ELF32_ST_TYPE(ste->sym.st_info)) { case STT_FUNC: symt_new_function(module, ste->compiland, ste->ht_elt.name, - addr, ste->symp->st_size, NULL); + addr, ste->sym.st_size, NULL); break; case STT_OBJECT: loc.kind = loc_absolute; loc.reg = 0; loc.offset = addr; symt_new_global_variable(module, ste->compiland, ste->ht_elt.name, - ELF32_ST_BIND(ste->symp->st_info) == STB_LOCAL, - loc, ste->symp->st_size, NULL); + ELF32_ST_BIND(ste->sym.st_info) == STB_LOCAL, + loc, ste->sym.st_size, NULL); break; default: FIXME("Shouldn't happen\n"); @@ -891,8 +910,8 @@ static int elf_new_public_symbols(struct module* module, const struct hash_table while ((ste = hash_table_iter_up(&hti))) { symt_new_public(module, ste->compiland, ste->ht_elt.name, - module->reloc_delta + ste->symp->st_value, - ste->symp->st_size); + module->reloc_delta + ste->sym.st_value, + ste->sym.st_size); } return TRUE; } diff --git a/dll/win32/dbghelp/image_private.h b/dll/win32/dbghelp/image_private.h index ecd15a27c29..060e0272f1a 100644 --- a/dll/win32/dbghelp/image_private.h +++ b/dll/win32/dbghelp/image_private.h @@ -58,14 +58,7 @@ typedef struct section macho_section; #define IMAGE_NO_MAP ((void*)-1) -#if defined(__ELF__) && !defined(DBGHELP_STATIC_LIB) - -#ifdef _WIN64 -#define Elf_Sym Elf64_Sym -#else -#define Elf_Sym Elf32_Sym -#endif -#else +#ifndef __ELF__ #ifndef SHT_NULL #define SHT_NULL 0 #endif diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index eb2b78f98ff..7069689f26f 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: 51ada19ac235df104e95476e9b3fa8204357bb9a + wine: 7e4fd17d5b62e888fd6a3a452dc3ee22dfb74ccd
4 years, 3 months
1
0
0
0
[reactos] 15/179: [WINESYNC] dbghelp: Read the Elf_auxv_t struct corresponding to the target's architecture.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4a24f9acfc8d442f889e8…
commit 4a24f9acfc8d442f889e858bd03905b852439e49 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Fri Sep 11 13:05:43 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Wed Sep 16 10:35:32 2020 +0200 [WINESYNC] dbghelp: Read the Elf_auxv_t struct corresponding to the target's architecture. Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 51ada19ac235df104e95476e9b3fa8204357bb9a by Zebediah Figura <zfigura(a)codeweavers.com> --- dll/win32/dbghelp/elf_module.c | 30 ++++++++++++++++++++++++------ dll/win32/dbghelp/image_private.h | 2 -- sdk/tools/winesync/dbghelp.cfg | 2 +- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c index 2b444f8b015..0cbeb98c407 100644 --- a/dll/win32/dbghelp/elf_module.c +++ b/dll/win32/dbghelp/elf_module.c @@ -1522,7 +1522,6 @@ static BOOL elf_search_auxv(const struct process* pcs, unsigned type, unsigned l void* addr; void* str; void* str_max; - Elf_auxv_t auxv; si->SizeOfStruct = sizeof(*si); si->MaxNameLen = MAX_SYM_NAME; @@ -1548,14 +1547,33 @@ static BOOL elf_search_auxv(const struct process* pcs, unsigned type, unsigned l while (addr < str_max && ReadProcessMemory(pcs->handle, addr, &str, sizeof(str), NULL) && str == NULL) addr = (void*)((DWORD_PTR)addr + sizeof(str)); - while (ReadProcessMemory(pcs->handle, addr, &auxv, sizeof(auxv), NULL) && auxv.a_type != AT_NULL) + if (pcs->is_64bit) { - if (auxv.a_type == type) + Elf64_auxv_t auxv; + + while (ReadProcessMemory(pcs->handle, addr, &auxv, sizeof(auxv), NULL) && auxv.a_type != AT_NULL) { - *val = auxv.a_un.a_val; - return TRUE; + if (auxv.a_type == type) + { + *val = auxv.a_un.a_val; + return TRUE; + } + addr = (void*)((DWORD_PTR)addr + sizeof(auxv)); + } + } + else + { + Elf32_auxv_t auxv; + + while (ReadProcessMemory(pcs->handle, addr, &auxv, sizeof(auxv), NULL) && auxv.a_type != AT_NULL) + { + if (auxv.a_type == type) + { + *val = auxv.a_un.a_val; + return TRUE; + } + addr = (void*)((DWORD_PTR)addr + sizeof(auxv)); } - addr = (void*)((DWORD_PTR)addr + sizeof(auxv)); } return FALSE; diff --git a/dll/win32/dbghelp/image_private.h b/dll/win32/dbghelp/image_private.h index 22e81ae3e01..ecd15a27c29 100644 --- a/dll/win32/dbghelp/image_private.h +++ b/dll/win32/dbghelp/image_private.h @@ -62,10 +62,8 @@ typedef struct section macho_section; #ifdef _WIN64 #define Elf_Sym Elf64_Sym -#define Elf_auxv_t Elf64_auxv_t #else #define Elf_Sym Elf32_Sym -#define Elf_auxv_t Elf32_auxv_t #endif #else #ifndef SHT_NULL diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg index 15733bdd51b..eb2b78f98ff 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: bb53152faab705d972de3763ddd9bb3351e92460 + wine: 51ada19ac235df104e95476e9b3fa8204357bb9a
4 years, 3 months
1
0
0
0
← Newer
1
...
23
24
25
26
27
28
29
...
39
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Results per page:
10
25
50
100
200