[WINESYNC] dbghelp: Use elf_check_debug_link in elf_locate_build_id_target.

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

wine commit id 171c6fadab8eb444968c1b3a4b364e2e978a639a by Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
winesync 2020-09-11 17:05:17 +02:00 committed by Jérôme Gardou
parent 3d39743d1b
commit 56b57ef7c5
2 changed files with 14 additions and 12 deletions

View file

@ -985,20 +985,25 @@ static BOOL elf_check_debug_link(const WCHAR* file, struct image_file_map* fmap,
{ {
HANDLE handle; HANDLE handle;
WCHAR *path; WCHAR *path;
DWORD crc; BOOL ret;
BOOL ret = FALSE;
path = get_dos_file_name(file); path = get_dos_file_name(file);
handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); handle = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
heap_free(path); heap_free(path);
if (handle == INVALID_HANDLE_VALUE) return FALSE; if (handle == INVALID_HANDLE_VALUE) return FALSE;
crc = calc_crc32(handle); if (link_crc)
if (crc != link_crc) {
WARN("Bad CRC for file %s (got %08x while expecting %08x)\n", debugstr_w(file), crc, link_crc); DWORD crc = calc_crc32(handle);
else if (crc != link_crc)
ret = elf_map_handle(handle, fmap); {
WARN("Bad CRC for file %s (got %08x while expecting %08x)\n", debugstr_w(file), crc, link_crc);
CloseHandle(handle);
return FALSE;
}
}
ret = elf_map_handle(handle, fmap);
CloseHandle(handle); CloseHandle(handle);
return ret; return ret;
} }
@ -1094,7 +1099,6 @@ static BOOL elf_locate_build_id_target(struct image_file_map* fmap, const BYTE*
WCHAR* p; WCHAR* p;
WCHAR* z; WCHAR* z;
const BYTE* idend = id + idlen; const BYTE* idend = id + idlen;
struct elf_map_file_data emfd;
fmap_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link)); fmap_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link));
if (!fmap_link) return FALSE; if (!fmap_link) return FALSE;
@ -1125,9 +1129,7 @@ static BOOL elf_locate_build_id_target(struct image_file_map* fmap, const BYTE*
memcpy(z, dotDebug0W, sizeof(dotDebug0W)); memcpy(z, dotDebug0W, sizeof(dotDebug0W));
TRACE("checking %s\n", wine_dbgstr_w(p)); TRACE("checking %s\n", wine_dbgstr_w(p));
emfd.kind = from_file; if (elf_check_debug_link(p, fmap_link, 0))
emfd.u.file.filename = p;
if (elf_map_file(&emfd, fmap_link))
{ {
struct image_section_map buildid_sect; struct image_section_map buildid_sect;
if (image_find_section(fmap_link, ".note.gnu.build-id", &buildid_sect)) if (image_find_section(fmap_link, ".note.gnu.build-id", &buildid_sect))

View file

@ -4,4 +4,4 @@ files:
include/dbghelp.h: sdk/include/psdk/dbghelp.h include/dbghelp.h: sdk/include/psdk/dbghelp.h
include/wine/mscvpdb.h: sdk/include/reactos/wine/mscvpdb.h include/wine/mscvpdb.h: sdk/include/reactos/wine/mscvpdb.h
tags: tags:
wine: c1d867fa872fafe1e6cc54ba6da63868fb7a4a6f wine: 171c6fadab8eb444968c1b3a4b364e2e978a639a