mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 22:56:00 +00:00
[WINESYNC] dbghelp: Translate the 32-bit ELF symbol struct to the 64-bit one.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> wine commit id 7e4fd17d5b62e888fd6a3a452dc3ee22dfb74ccd by Zebediah Figura <zfigura@codeweavers.com>
This commit is contained in:
parent
4a24f9acfc
commit
76ad5c4b68
3 changed files with 55 additions and 43 deletions
|
@ -101,7 +101,7 @@ struct elf_info
|
||||||
struct symtab_elt
|
struct symtab_elt
|
||||||
{
|
{
|
||||||
struct hash_table_elt ht_elt;
|
struct hash_table_elt ht_elt;
|
||||||
const Elf_Sym* symp;
|
Elf64_Sym sym;
|
||||||
struct symt_compiland* compiland;
|
struct symt_compiland* compiland;
|
||||||
unsigned used;
|
unsigned used;
|
||||||
};
|
};
|
||||||
|
@ -548,13 +548,13 @@ static void elf_hash_symtab(struct module* module, struct pool* pool,
|
||||||
const char* symname;
|
const char* symname;
|
||||||
struct symt_compiland* compiland = NULL;
|
struct symt_compiland* compiland = NULL;
|
||||||
const char* ptr;
|
const char* ptr;
|
||||||
const Elf_Sym* symp;
|
|
||||||
struct symtab_elt* ste;
|
struct symtab_elt* ste;
|
||||||
struct image_section_map ism, ism_str;
|
struct image_section_map ism, ism_str;
|
||||||
|
const char *symtab;
|
||||||
|
|
||||||
if (!elf_find_section(fmap, ".symtab", SHT_SYMTAB, &ism) &&
|
if (!elf_find_section(fmap, ".symtab", SHT_SYMTAB, &ism) &&
|
||||||
!elf_find_section(fmap, ".dynsym", SHT_DYNSYM, &ism)) return;
|
!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.fmap = ism.fmap;
|
||||||
ism_str.sidx = fmap->u.elf.sect[ism.sidx].shdr.sh_link;
|
ism_str.sidx = fmap->u.elf.sect[ism.sidx].shdr.sh_link;
|
||||||
if ((strp = image_map_section(&ism_str)) == IMAGE_NO_MAP)
|
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;
|
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++)
|
for (j = 0; thunks[j].symname; j++)
|
||||||
thunks[j].rva_start = thunks[j].rva_end = 0;
|
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
|
/* Ignore certain types of entries which really aren't of that much
|
||||||
* interest.
|
* interest.
|
||||||
*/
|
*/
|
||||||
if ((ELF32_ST_TYPE(symp->st_info) != STT_NOTYPE &&
|
if ((ELF32_ST_TYPE(sym.st_info) != STT_NOTYPE &&
|
||||||
ELF32_ST_TYPE(symp->st_info) != STT_FILE &&
|
ELF32_ST_TYPE(sym.st_info) != STT_FILE &&
|
||||||
ELF32_ST_TYPE(symp->st_info) != STT_OBJECT &&
|
ELF32_ST_TYPE(sym.st_info) != STT_OBJECT &&
|
||||||
ELF32_ST_TYPE(symp->st_info) != STT_FUNC) ||
|
ELF32_ST_TYPE(sym.st_info) != STT_FUNC) ||
|
||||||
symp->st_shndx == SHN_UNDEF)
|
sym.st_shndx == SHN_UNDEF)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
symname = strp + symp->st_name;
|
symname = strp + sym.st_name;
|
||||||
|
|
||||||
/* handle some specific symtab (that we'll throw away when done) */
|
/* 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:
|
case STT_FILE:
|
||||||
if (symname)
|
if (symname)
|
||||||
compiland = symt_new_compiland(module, symp->st_value,
|
compiland = symt_new_compiland(module, sym.st_value,
|
||||||
source_new(module, NULL, symname));
|
source_new(module, NULL, symname));
|
||||||
else
|
else
|
||||||
compiland = NULL;
|
compiland = NULL;
|
||||||
|
@ -600,8 +617,8 @@ static void elf_hash_symtab(struct module* module, struct pool* pool,
|
||||||
{
|
{
|
||||||
if (!strcmp(symname, thunks[j].symname))
|
if (!strcmp(symname, thunks[j].symname))
|
||||||
{
|
{
|
||||||
thunks[j].rva_start = symp->st_value;
|
thunks[j].rva_start = sym.st_value;
|
||||||
thunks[j].rva_end = symp->st_value + symp->st_size;
|
thunks[j].rva_end = sym.st_value + sym.st_size;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -635,7 +652,7 @@ static void elf_hash_symtab(struct module* module, struct pool* pool,
|
||||||
ste->ht_elt.name = n;
|
ste->ht_elt.name = n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ste->symp = symp;
|
ste->sym = sym;
|
||||||
ste->compiland = compiland;
|
ste->compiland = compiland;
|
||||||
ste->used = 0;
|
ste->used = 0;
|
||||||
hash_table_add(ht_symtab, &ste->ht_elt);
|
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
|
* 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 struct hash_table* ht_symtab,
|
||||||
const char* name, const struct symt* compiland)
|
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",
|
FIXME("Already found symbol %s (%s) in symtab %s @%08x and %s @%08x\n",
|
||||||
name, compiland_name,
|
name, compiland_name,
|
||||||
source_get(module, result->compiland->source), (unsigned int)result->symp->st_value,
|
source_get(module, result->compiland->source), (unsigned int)result->sym.st_value,
|
||||||
source_get(module, ste->compiland->source), (unsigned int)ste->symp->st_value);
|
source_get(module, ste->compiland->source), (unsigned int)ste->sym.st_value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -713,7 +730,7 @@ static const Elf_Sym* elf_lookup_symtab(const struct module* module,
|
||||||
debugstr_w(module->module.ModuleName), name);
|
debugstr_w(module->module.ModuleName), name);
|
||||||
return NULL;
|
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;
|
struct hash_table_iter hti;
|
||||||
void* ptr;
|
void* ptr;
|
||||||
struct symt_ht* sym;
|
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;
|
struct elf_module_info* elf_info = module->format_info[DFI_ELF]->u.elf_info;
|
||||||
|
|
||||||
hash_table_iter_init(&module->ht_symbols, &hti, NULL);
|
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 &&
|
if (((struct symt_function*)sym)->address != elf_info->elf_addr &&
|
||||||
((struct symt_function*)sym)->address != elf_info->elf_addr + symp->st_value)
|
((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,
|
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)
|
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",
|
FIXME("Changing size for %p/%s!%s from %08lx to %08x\n",
|
||||||
sym, debugstr_w(module->module.ModuleName), sym->hash_elt.name,
|
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 &&
|
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)
|
((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,
|
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)->u.var.offset = elf_info->elf_addr + symp->st_value;
|
||||||
((struct symt_data*)sym)->kind = (ELF32_ST_BIND(symp->st_info) == STB_LOCAL) ?
|
((struct symt_data*)sym)->kind = (ELF32_ST_BIND(symp->st_info) == STB_LOCAL) ?
|
||||||
DataIsFileStatic : DataIsGlobal;
|
DataIsFileStatic : DataIsGlobal;
|
||||||
|
@ -817,13 +836,13 @@ static int elf_new_wine_thunks(struct module* module, const struct hash_table* h
|
||||||
{
|
{
|
||||||
if (ste->used) continue;
|
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 */
|
if (j >= 0) /* thunk found */
|
||||||
{
|
{
|
||||||
symt_new_thunk(module, ste->compiland, ste->ht_elt.name, thunks[j].ordinal,
|
symt_new_thunk(module, ste->compiland, ste->ht_elt.name, thunks[j].ordinal,
|
||||||
addr, ste->symp->st_size);
|
addr, ste->sym.st_size);
|
||||||
}
|
}
|
||||||
else
|
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)
|
* used yet (ie we have no debug information on them)
|
||||||
* That's the case, for example, of the .spec.c files
|
* 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:
|
case STT_FUNC:
|
||||||
symt_new_function(module, ste->compiland, ste->ht_elt.name,
|
symt_new_function(module, ste->compiland, ste->ht_elt.name,
|
||||||
addr, ste->symp->st_size, NULL);
|
addr, ste->sym.st_size, NULL);
|
||||||
break;
|
break;
|
||||||
case STT_OBJECT:
|
case STT_OBJECT:
|
||||||
loc.kind = loc_absolute;
|
loc.kind = loc_absolute;
|
||||||
loc.reg = 0;
|
loc.reg = 0;
|
||||||
loc.offset = addr;
|
loc.offset = addr;
|
||||||
symt_new_global_variable(module, ste->compiland, ste->ht_elt.name,
|
symt_new_global_variable(module, ste->compiland, ste->ht_elt.name,
|
||||||
ELF32_ST_BIND(ste->symp->st_info) == STB_LOCAL,
|
ELF32_ST_BIND(ste->sym.st_info) == STB_LOCAL,
|
||||||
loc, ste->symp->st_size, NULL);
|
loc, ste->sym.st_size, NULL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FIXME("Shouldn't happen\n");
|
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)))
|
while ((ste = hash_table_iter_up(&hti)))
|
||||||
{
|
{
|
||||||
symt_new_public(module, ste->compiland, ste->ht_elt.name,
|
symt_new_public(module, ste->compiland, ste->ht_elt.name,
|
||||||
module->reloc_delta + ste->symp->st_value,
|
module->reloc_delta + ste->sym.st_value,
|
||||||
ste->symp->st_size);
|
ste->sym.st_size);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,14 +58,7 @@ typedef struct section macho_section;
|
||||||
|
|
||||||
#define IMAGE_NO_MAP ((void*)-1)
|
#define IMAGE_NO_MAP ((void*)-1)
|
||||||
|
|
||||||
#if defined(__ELF__) && !defined(DBGHELP_STATIC_LIB)
|
#ifndef __ELF__
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
#define Elf_Sym Elf64_Sym
|
|
||||||
#else
|
|
||||||
#define Elf_Sym Elf32_Sym
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#ifndef SHT_NULL
|
#ifndef SHT_NULL
|
||||||
#define SHT_NULL 0
|
#define SHT_NULL 0
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,4 +3,4 @@ directories:
|
||||||
files:
|
files:
|
||||||
include/dbghelp.h: sdk/include/psdk/dbghelp.h
|
include/dbghelp.h: sdk/include/psdk/dbghelp.h
|
||||||
tags:
|
tags:
|
||||||
wine: 51ada19ac235df104e95476e9b3fa8204357bb9a
|
wine: 7e4fd17d5b62e888fd6a3a452dc3ee22dfb74ccd
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue