dbghelp: Allow to add an alternate file_map for an ELF file (where to look for its debug information).

This commit is contained in:
Eric Pouech 2007-02-24 21:01:10 +01:00 committed by Alexandre Julliard
parent 62b57f9e21
commit fc66bb37f4

View File

@ -115,6 +115,7 @@ struct elf_file_map
unsigned with_crc;
unsigned long crc;
const char* shstrtab;
struct elf_file_map* alternate; /* another ELF file (linked to this one) */
};
struct elf_section_map
@ -167,12 +168,15 @@ static const char* elf_map_section(struct elf_section_map* esm)
* elf_find_section
*
* Finds a section by name (and type) into memory from an ELF file
* or its alternate if any
*/
static BOOL elf_find_section(struct elf_file_map* fmap, const char* name,
unsigned sht, struct elf_section_map* esm)
{
unsigned i;
while (fmap)
{
if (fmap->shstrtab == ELF_NO_MAP)
{
struct elf_section_map hdr_esm = {fmap, fmap->elfhdr.e_shstrndx};
@ -189,6 +193,8 @@ static BOOL elf_find_section(struct elf_file_map* fmap, const char* name,
return TRUE;
}
}
fmap = fmap->alternate;
}
return FALSE;
}
@ -217,9 +223,14 @@ static void elf_end_find(struct elf_file_map* fmap)
{
struct elf_section_map esm;
esm.fmap = fmap; esm.sidx = fmap->elfhdr.e_shstrndx;
while (fmap)
{
esm.fmap = fmap;
esm.sidx = fmap->elfhdr.e_shstrndx;
elf_unmap_section(&esm);
fmap->shstrtab = ELF_NO_MAP;
fmap = fmap->alternate;
}
}
/******************************************************************
@ -257,6 +268,7 @@ static BOOL elf_map_file(const WCHAR* filenameW, struct elf_file_map* fmap)
fmap->fd = -1;
fmap->with_crc = 0;
fmap->shstrtab = ELF_NO_MAP;
fmap->alternate = NULL;
/* check that the file exists, and that the module hasn't been loaded yet */
if (stat(filename, &statbuf) == -1 || S_ISDIR(statbuf.st_mode)) goto done;
@ -311,6 +323,8 @@ done:
* Unmaps an ELF file from memory (previously mapped with elf_map_file)
*/
static void elf_unmap_file(struct elf_file_map* fmap)
{
while (fmap)
{
if (fmap->fd != -1)
{
@ -323,6 +337,8 @@ static void elf_unmap_file(struct elf_file_map* fmap)
HeapFree(GetProcessHeap(), 0, fmap->sect);
close(fmap->fd);
}
fmap = fmap->alternate;
}
}
/******************************************************************