#include "dbghelp_private.h"
#include "image_private.h"
+#ifndef DBGHELP_STATIC_LIB
#include "winternl.h"
#include "wine/debug.h"
+#endif
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
fmap->sect[ism->sidx].mapped == IMAGE_NO_MAP)
{
IMAGE_NT_HEADERS* nth;
+
+ if (fmap->sect[ism->sidx].shdr.Misc.VirtualSize > fmap->sect[ism->sidx].shdr.SizeOfRawData)
+ {
+ FIXME("Section %ld: virtual (0x%x) > raw (0x%x) size - not supported\n",
+ ism->sidx, fmap->sect[ism->sidx].shdr.Misc.VirtualSize,
+ fmap->sect[ism->sidx].shdr.SizeOfRawData);
+ return IMAGE_NO_MAP;
+ }
/* FIXME: that's rather drastic, but that will do for now
- * that's ok if the full file map exists, but we could be less agressive otherwise and
+ * that's ok if the full file map exists, but we could be less aggressive otherwise and
* only map the relevant section
*/
if ((mapping = pe_map_full(ism->fmap, &nth)))
/******************************************************************
* pe_get_map_size
*
- * Get the size of an PE section
+ * Get the size of a PE section
*/
unsigned pe_get_map_size(const struct image_section_map* ism)
{
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.pe.ntheader.FileHeader.NumberOfSections)
return 0;
- return ism->fmap->u.pe.sect[ism->sidx].shdr.SizeOfRawData;
+ return ism->fmap->u.pe.sect[ism->sidx].shdr.Misc.VirtualSize;
}
/******************************************************************
if (!(nthdr = RtlImageNtHeader(mapping))) goto error;
memcpy(&fmap->u.pe.ntheader, nthdr, sizeof(fmap->u.pe.ntheader));
+ switch (nthdr->OptionalHeader.Magic)
+ {
+ case 0x10b: fmap->addr_size = 32; break;
+ case 0x20b: fmap->addr_size = 64; break;
+ default: return FALSE;
+ }
section = (IMAGE_SECTION_HEADER*)
((char*)&nthdr->OptionalHeader + nthdr->FileHeader.SizeOfOptionalHeader);
fmap->u.pe.sect = HeapAlloc(GetProcessHeap(), 0,
nth->OptionalHeader.DataDirectory[dirno].VirtualAddress, NULL);
}
-/******************************************************************
- * pe_unmap_directory
- *
- * Unmaps a directory content
- */
-void pe_unmap_directory(struct image_file_map* fmap, int dirno)
-{
- pe_unmap_full(fmap);
-}
-
static void pe_module_remove(struct process* pcs, struct module_format* modfmt)
{
pe_unmap_file(&modfmt->u.pe_info->fmap);
hash_table_iter_init(&module->ht_symbols, &hti, name);
while ((ptr = hash_table_iter_up(&hti)))
{
- sym = GET_ENTRY(ptr, struct symt_data, hash_elt);
+ sym = CONTAINING_RECORD(ptr, struct symt_data, hash_elt);
if (sym->symt.tag == SymTagData &&
(sym->kind == DataIsGlobal || sym->kind == DataIsFileStatic) &&
+ sym->u.var.kind == loc_absolute &&
!strcmp(sym->hash_elt.name, name))
{
TRACE("Changing absolute address for %d.%s: %lx -> %s\n",
source_new(module, NULL, lastfilename));
if (!(dbghelp_options & SYMOPT_NO_PUBLICS))
- symt_new_public(module, compiland, name,
+ symt_new_public(module, compiland, name, FALSE,
module->module.BaseOfImage + sect[isym->SectionNumber - 1].VirtualAddress +
- isym->Value,
+ isym->Value,
1);
}
naux = isym->NumberOfAuxSymbols + 1;
return TRUE;
}
-static inline void* pe_get_sect(IMAGE_NT_HEADERS* nth, void* mapping,
- IMAGE_SECTION_HEADER* sect)
-{
- return (sect) ? RtlImageRvaToVa(nth, mapping, sect->VirtualAddress, NULL) : NULL;
-}
-
-static inline DWORD pe_get_sect_size(IMAGE_SECTION_HEADER* sect)
-{
- return (sect) ? sect->SizeOfRawData : 0;
-}
-
/******************************************************************
* pe_load_stabs
*
static BOOL pe_load_dwarf(struct module* module)
{
struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
- BOOL ret = FALSE;
+ BOOL ret;
ret = dwarf2_parse(module,
module->module.BaseOfImage - fmap->u.pe.ntheader.OptionalHeader.ImageBase,
return ret;
}
+#ifndef DBGHELP_STATIC_LIB
+/******************************************************************
+ * pe_load_rsym
+ *
+ * look for ReactOS's own rsym format
+ */
+static BOOL pe_load_rsym(struct module* module)
+{
+ struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
+ struct image_section_map sect_rsym;
+ BOOL ret = FALSE;
+
+ if (pe_find_section(fmap, ".rossym", §_rsym))
+ {
+ const char* rsym = image_map_section(§_rsym);
+ if (rsym != IMAGE_NO_MAP)
+ {
+ ret = rsym_parse(module, module->module.BaseOfImage,
+ rsym, image_get_map_size(§_rsym));
+ }
+ image_unmap_section(§_rsym);
+ }
+ TRACE("%s the RSYM debug info\n", ret ? "successfully loaded" : "failed to load");
+
+ return ret;
+}
+
/******************************************************************
* pe_load_dbg_file
*
TRACE("Processing DBG file %s\n", debugstr_a(dbg_name));
- if (path_find_symbol_file(pcs, dbg_name, NULL, timestamp, 0, tmp, &module->module.DbgUnmatched) &&
+ if (path_find_symbol_file(pcs, module, dbg_name, NULL, timestamp, 0, tmp, &module->module.DbgUnmatched) &&
(hFile = CreateFileA(tmp, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE &&
((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) &&
dbg = RtlImageRvaToVa(nth, mapping, dir->VirtualAddress, NULL);
+#ifdef __REACTOS__
+ if (!dbg)
+ {
+ ERR("Debug directory not found in module %s\n",
+ debugstr_w(module->module.ModuleName));
+ goto done;
+ }
+#endif
+
/* Parse debug directory */
if (nth->FileHeader.Characteristics & IMAGE_FILE_DEBUG_STRIPPED)
{
if (nDbg != 1 || dbg->Type != IMAGE_DEBUG_TYPE_MISC ||
misc->DataType != IMAGE_DEBUG_MISC_EXENAME)
{
- WINE_ERR("-Debug info stripped, but no .DBG file in module %s\n",
- debugstr_w(module->module.ModuleName));
+ ERR("-Debug info stripped, but no .DBG file in module %s\n",
+ debugstr_w(module->module.ModuleName));
}
else
{
pe_unmap_full(fmap);
return ret;
}
+#endif /* DBGHELP_STATIC_LIB */
/***********************************************************************
* pe_load_export_debug_info
#if 0
/* Add start of DLL (better use the (yet unimplemented) Exe SymTag for this) */
/* FIXME: module.ModuleName isn't correctly set yet if it's passed in SymLoadModule */
- symt_new_public(module, NULL, module->module.ModuleName, base, 1);
+ symt_new_public(module, NULL, module->module.ModuleName, FALSE, base, 1);
#endif
/* Add entry point */
- symt_new_public(module, NULL, "EntryPoint",
+ symt_new_public(module, NULL, "EntryPoint", FALSE,
base + nth->OptionalHeader.AddressOfEntryPoint, 1);
#if 0
/* FIXME: we'd better store addresses linked to sections rather than
((char*)&nth->OptionalHeader + nth->FileHeader.SizeOfOptionalHeader);
for (i = 0; i < nth->FileHeader.NumberOfSections; i++, section++)
{
- symt_new_public(module, NULL, section->Name,
+ symt_new_public(module, NULL, section->Name, FALSE,
RtlImageRvaToVa(nth, mapping, section->VirtualAddress, NULL), 1);
}
#endif
if (!names[i]) continue;
symt_new_public(module, NULL,
RtlImageRvaToVa(nth, mapping, names[i], NULL),
+ FALSE,
base + functions[ordinals[i]], 1);
}
if ((ordinals[j] == i) && names[j]) break;
if (j < exports->NumberOfNames) continue;
snprintf(buffer, sizeof(buffer), "%d", i + exports->Base);
- symt_new_public(module, NULL, buffer, base + (DWORD)functions[i], 1);
+ symt_new_public(module, NULL, buffer, FALSE, base + (DWORD)functions[i], 1);
}
}
}
{
ret = pe_load_stabs(pcs, module);
ret = pe_load_dwarf(module) || ret;
+ #ifndef DBGHELP_STATIC_LIB
ret = pe_load_msc_debug_info(pcs, module) || ret;
+ ret = pe_load_rsym(module) || ret;
+ #endif
+
ret = ret || pe_load_coff_symbol_table(module); /* FIXME */
/* if we still have no debug info (we could only get SymExport at this
* point), then do the SymExport except if we have an ELF container,
*
*/
struct module* pe_load_native_module(struct process* pcs, const WCHAR* name,
- HANDLE hFile, DWORD base, DWORD size)
+ HANDLE hFile, DWORD64 base, DWORD size)
{
struct module* module = NULL;
BOOL opened = FALSE;
module->module.SymType = SymDeferred;
else
pe_load_debug_info(pcs, module);
+ module->reloc_delta = base - modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.ImageBase;
}
else
{