2 * File elf.c - processing of ELF files
4 * Copyright (C) 1996, Eric Youngdale.
5 * 1999-2007 Eric Pouech
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
25 #if defined(__svr4__) || defined(__sun)
27 /* large files are not supported by libelf */
28 #undef _FILE_OFFSET_BITS
29 #define _FILE_OFFSET_BITS 32
35 #ifdef HAVE_SYS_STAT_H
36 # include <sys/stat.h>
39 #ifdef HAVE_SYS_MMAN_H
46 #define PATH_MAX MAX_PATH
49 #include "dbghelp_private.h"
54 #ifdef HAVE_SYS_ELF32_H
55 # include <sys/elf32.h>
57 #ifdef HAVE_SYS_EXEC_ELF_H
58 # include <sys/exec_elf.h>
61 # if defined(DT_COUNT)
62 # define DT_NUM DT_COUNT
64 /* this seems to be a satisfactory value on Solaris, which doesn't support this AFAICT */
71 #ifdef HAVE_SYS_LINK_H
72 # include <sys/link.h>
75 #include "wine/library.h"
76 #include "wine/debug.h"
80 #define ELF_INFO_DEBUG_HEADER 0x0001
81 #define ELF_INFO_MODULE 0x0002
82 #define ELF_INFO_NAME 0x0004
84 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
88 unsigned flags; /* IN one (or several) of the ELF_INFO constants */
89 DWORD_PTR dbg_hdr_addr; /* OUT address of debug header (if ELF_INFO_DEBUG_HEADER is set) */
90 struct module* module; /* OUT loaded module (if ELF_INFO_MODULE is set) */
91 const WCHAR* module_name; /* OUT found module name (if ELF_INFO_NAME is set) */
95 #define Elf_Ehdr Elf64_Ehdr
96 #define Elf_Shdr Elf64_Shdr
97 #define Elf_Phdr Elf64_Phdr
98 #define Elf_Dyn Elf64_Dyn
99 #define Elf_Sym Elf64_Sym
101 #define Elf_Ehdr Elf32_Ehdr
102 #define Elf_Shdr Elf32_Shdr
103 #define Elf_Phdr Elf32_Phdr
104 #define Elf_Dyn Elf32_Dyn
105 #define Elf_Sym Elf32_Sym
108 /* structure holding information while handling an ELF image
109 * allows one by one section mapping for memory savings
122 const char* shstrtab;
123 struct elf_file_map* alternate; /* another ELF file (linked to this one) */
126 struct elf_section_map
128 struct elf_file_map* fmap;
134 struct hash_table_elt ht_elt;
136 struct symt_compiland* compiland;
140 struct elf_thunk_area
143 THUNK_ORDINAL ordinal;
144 unsigned long rva_start;
145 unsigned long rva_end;
148 struct elf_module_info
150 unsigned long elf_addr;
151 unsigned short elf_mark : 1,
153 struct elf_file_map file_map;
156 /******************************************************************
159 * Maps a single section into memory from an ELF file
161 static const char* elf_map_section(struct elf_section_map* esm)
163 unsigned pgsz = getpagesize();
166 if (esm->sidx < 0 || esm->sidx >= esm->fmap->elfhdr.e_shnum ||
167 esm->fmap->sect[esm->sidx].shdr.sh_type == SHT_NOBITS)
170 /* align required information on page size (we assume pagesize is a power of 2) */
171 ofst = esm->fmap->sect[esm->sidx].shdr.sh_offset & ~(pgsz - 1);
172 size = ((esm->fmap->sect[esm->sidx].shdr.sh_offset +
173 esm->fmap->sect[esm->sidx].shdr.sh_size + pgsz - 1) & ~(pgsz - 1)) - ofst;
174 esm->fmap->sect[esm->sidx].mapped = mmap(NULL, size, PROT_READ, MAP_PRIVATE,
175 esm->fmap->fd, ofst);
176 if (esm->fmap->sect[esm->sidx].mapped == ELF_NO_MAP) return ELF_NO_MAP;
177 return esm->fmap->sect[esm->sidx].mapped + (esm->fmap->sect[esm->sidx].shdr.sh_offset & (pgsz - 1));
180 /******************************************************************
183 * Finds a section by name (and type) into memory from an ELF file
184 * or its alternate if any
186 static BOOL elf_find_section(struct elf_file_map* fmap, const char* name,
187 unsigned sht, struct elf_section_map* esm)
193 if (fmap->shstrtab == ELF_NO_MAP)
195 struct elf_section_map hdr_esm = {fmap, fmap->elfhdr.e_shstrndx};
196 if ((fmap->shstrtab = elf_map_section(&hdr_esm)) == ELF_NO_MAP) break;
198 for (i = 0; i < fmap->elfhdr.e_shnum; i++)
200 if (strcmp(fmap->shstrtab + fmap->sect[i].shdr.sh_name, name) == 0 &&
201 (sht == SHT_NULL || sht == fmap->sect[i].shdr.sh_type))
208 fmap = fmap->alternate;
215 /******************************************************************
218 * Unmaps a single section from memory
220 static void elf_unmap_section(struct elf_section_map* esm)
222 if (esm->sidx >= 0 && esm->sidx < esm->fmap->elfhdr.e_shnum && esm->fmap->sect[esm->sidx].mapped != ELF_NO_MAP)
224 unsigned pgsz = getpagesize();
227 ofst = esm->fmap->sect[esm->sidx].shdr.sh_offset & ~(pgsz - 1);
228 size = ((esm->fmap->sect[esm->sidx].shdr.sh_offset +
229 esm->fmap->sect[esm->sidx].shdr.sh_size + pgsz - 1) & ~(pgsz - 1)) - ofst;
230 if (munmap((char*)esm->fmap->sect[esm->sidx].mapped, size) < 0)
231 WARN("Couldn't unmap the section\n");
232 esm->fmap->sect[esm->sidx].mapped = ELF_NO_MAP;
236 static void elf_end_find(struct elf_file_map* fmap)
238 struct elf_section_map esm;
243 esm.sidx = fmap->elfhdr.e_shstrndx;
244 elf_unmap_section(&esm);
245 fmap->shstrtab = ELF_NO_MAP;
246 fmap = fmap->alternate;
250 /******************************************************************
253 * Get the size of an ELF section
255 static inline unsigned elf_get_map_size(const struct elf_section_map* esm)
257 if (esm->sidx < 0 || esm->sidx >= esm->fmap->elfhdr.e_shnum)
259 return esm->fmap->sect[esm->sidx].shdr.sh_size;
262 static inline void elf_reset_file_map(struct elf_file_map* fmap)
265 fmap->shstrtab = ELF_NO_MAP;
266 fmap->alternate = NULL;
269 /******************************************************************
272 * Maps an ELF file into memory (and checks it's a real ELF file)
274 static BOOL elf_map_file(const WCHAR* filenameW, struct elf_file_map* fmap)
276 static const BYTE elf_signature[4] = { ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3 };
280 unsigned tmp, page_mask = getpagesize() - 1;
285 len = WideCharToMultiByte(CP_UNIXCP, 0, filenameW, -1, NULL, 0, NULL, NULL);
286 if (!(filename = HeapAlloc(GetProcessHeap(), 0, len))) return FALSE;
287 WideCharToMultiByte(CP_UNIXCP, 0, filenameW, -1, filename, len, NULL, NULL);
289 elf_reset_file_map(fmap);
291 /* check that the file exists, and that the module hasn't been loaded yet */
292 if (stat(filename, &statbuf) == -1 || S_ISDIR(statbuf.st_mode)) goto done;
294 /* Now open the file, so that we can mmap() it. */
295 if ((fmap->fd = open(filename, O_RDONLY)) == -1) goto done;
297 if (read(fmap->fd, &fmap->elfhdr, sizeof(fmap->elfhdr)) != sizeof(fmap->elfhdr))
299 /* and check for an ELF header */
300 if (memcmp(fmap->elfhdr.e_ident,
301 elf_signature, sizeof(elf_signature))) goto done;
302 /* and check 32 vs 64 size according to current machine */
304 if (fmap->elfhdr.e_ident[EI_CLASS] != ELFCLASS64) goto done;
306 if (fmap->elfhdr.e_ident[EI_CLASS] != ELFCLASS32) goto done;
308 fmap->sect = HeapAlloc(GetProcessHeap(), 0,
309 fmap->elfhdr.e_shnum * sizeof(fmap->sect[0]));
310 if (!fmap->sect) goto done;
312 lseek(fmap->fd, fmap->elfhdr.e_shoff, SEEK_SET);
313 for (i = 0; i < fmap->elfhdr.e_shnum; i++)
315 read(fmap->fd, &fmap->sect[i].shdr, sizeof(fmap->sect[i].shdr));
316 fmap->sect[i].mapped = ELF_NO_MAP;
319 /* grab size of module once loaded in memory */
320 lseek(fmap->fd, fmap->elfhdr.e_phoff, SEEK_SET);
322 fmap->elf_start = ~0L;
323 for (i = 0; i < fmap->elfhdr.e_phnum; i++)
325 if (read(fmap->fd, &phdr, sizeof(phdr)) == sizeof(phdr) &&
326 phdr.p_type == PT_LOAD)
328 tmp = (phdr.p_vaddr + phdr.p_memsz + page_mask) & ~page_mask;
329 if (fmap->elf_size < tmp) fmap->elf_size = tmp;
330 if (phdr.p_vaddr < fmap->elf_start) fmap->elf_start = phdr.p_vaddr;
333 /* if non relocatable ELF, then remove fixed address from computation
334 * otherwise, all addresses are zero based and start has no effect
336 fmap->elf_size -= fmap->elf_start;
339 HeapFree(GetProcessHeap(), 0, filename);
343 /******************************************************************
346 * Unmaps an ELF file from memory (previously mapped with elf_map_file)
348 static void elf_unmap_file(struct elf_file_map* fmap)
354 struct elf_section_map esm;
356 for (esm.sidx = 0; esm.sidx < fmap->elfhdr.e_shnum; esm.sidx++)
358 elf_unmap_section(&esm);
360 HeapFree(GetProcessHeap(), 0, fmap->sect);
363 fmap = fmap->alternate;
367 static void elf_module_remove(struct process* pcs, struct module* module)
369 HeapFree(GetProcessHeap(), 0, module->elf_info);
372 /******************************************************************
373 * elf_is_in_thunk_area
375 * Check whether an address lies within one of the thunk area we
378 int elf_is_in_thunk_area(unsigned long addr,
379 const struct elf_thunk_area* thunks)
383 if (thunks) for (i = 0; thunks[i].symname; i++)
385 if (addr >= thunks[i].rva_start && addr < thunks[i].rva_end)
391 /******************************************************************
394 * creating an internal hash table to ease use ELF symtab information lookup
396 static void elf_hash_symtab(struct module* module, struct pool* pool,
397 struct hash_table* ht_symtab, struct elf_file_map* fmap,
398 struct elf_thunk_area* thunks)
403 struct symt_compiland* compiland = NULL;
406 struct symtab_elt* ste;
407 struct elf_section_map esm, esm_str;
409 if (!elf_find_section(fmap, ".symtab", SHT_SYMTAB, &esm) &&
410 !elf_find_section(fmap, ".dynsym", SHT_DYNSYM, &esm)) return;
411 if ((symp = (const Elf_Sym*)elf_map_section(&esm)) == ELF_NO_MAP) return;
413 esm_str.sidx = fmap->sect[esm.sidx].shdr.sh_link;
414 if ((strp = elf_map_section(&esm_str)) == ELF_NO_MAP) return;
416 nsym = elf_get_map_size(&esm) / sizeof(*symp);
418 for (j = 0; thunks[j].symname; j++)
419 thunks[j].rva_start = thunks[j].rva_end = 0;
421 for (i = 0; i < nsym; i++, symp++)
423 /* Ignore certain types of entries which really aren't of that much
426 if ((ELF32_ST_TYPE(symp->st_info) != STT_NOTYPE &&
427 ELF32_ST_TYPE(symp->st_info) != STT_FILE &&
428 ELF32_ST_TYPE(symp->st_info) != STT_OBJECT &&
429 ELF32_ST_TYPE(symp->st_info) != STT_FUNC) ||
430 symp->st_shndx == SHN_UNDEF)
435 symname = strp + symp->st_name;
437 /* handle some specific symtab (that we'll throw away when done) */
438 switch (ELF32_ST_TYPE(symp->st_info))
442 compiland = symt_new_compiland(module, symp->st_value,
443 source_new(module, NULL, symname));
448 /* we are only interested in wine markers inserted by winebuild */
449 for (j = 0; thunks[j].symname; j++)
451 if (!strcmp(symname, thunks[j].symname))
453 thunks[j].rva_start = symp->st_value;
454 thunks[j].rva_end = symp->st_value + symp->st_size;
461 /* FIXME: we don't need to handle them (GCC internals)
462 * Moreover, they screw up our symbol lookup :-/
464 if (symname[0] == '.' && symname[1] == 'L' && isdigit(symname[2]))
467 ste = pool_alloc(pool, sizeof(*ste));
468 ste->ht_elt.name = symname;
469 /* GCC emits, in some cases, a .<digit>+ suffix.
470 * This is used for static variable inside functions, so
471 * that we can have several such variables with same name in
472 * the same compilation unit
473 * We simply ignore that suffix when present (we also get rid
474 * of it in stabs parsing)
476 ptr = symname + strlen(symname) - 1;
479 while (isdigit(*ptr) && ptr >= symname) ptr--;
480 if (ptr > symname && *ptr == '.')
482 char* n = pool_alloc(pool, ptr - symname + 1);
483 memcpy(n, symname, ptr - symname + 1);
484 n[ptr - symname] = '\0';
485 ste->ht_elt.name = n;
489 ste->compiland = compiland;
491 hash_table_add(ht_symtab, &ste->ht_elt);
493 /* as we added in the ht_symtab pointers to the symbols themselves,
494 * we cannot unmap yet the sections, it will be done when we're over
499 /******************************************************************
502 * lookup a symbol by name in our internal hash table for the symtab
504 static const Elf_Sym* elf_lookup_symtab(const struct module* module,
505 const struct hash_table* ht_symtab,
506 const char* name, const struct symt* compiland)
508 struct symtab_elt* weak_result = NULL; /* without compiland name */
509 struct symtab_elt* result = NULL;
510 struct hash_table_iter hti;
511 struct symtab_elt* ste;
512 const char* compiland_name;
513 const char* compiland_basename;
516 /* we need weak match up (at least) when symbols of same name,
517 * defined several times in different compilation units,
518 * are merged in a single one (hence a different filename for c.u.)
522 compiland_name = source_get(module,
523 ((const struct symt_compiland*)compiland)->source);
524 compiland_basename = strrchr(compiland_name, '/');
525 if (!compiland_basename++) compiland_basename = compiland_name;
527 else compiland_name = compiland_basename = NULL;
529 hash_table_iter_init(ht_symtab, &hti, name);
530 while ((ste = hash_table_iter_up(&hti)))
532 if (ste->used || strcmp(ste->ht_elt.name, name)) continue;
535 if ((ste->compiland && !compiland_name) || (!ste->compiland && compiland_name))
537 if (ste->compiland && compiland_name)
539 const char* filename = source_get(module, ste->compiland->source);
540 if (strcmp(filename, compiland_name))
542 base = strrchr(filename, '/');
543 if (!base++) base = filename;
544 if (strcmp(base, compiland_basename)) continue;
549 FIXME("Already found symbol %s (%s) in symtab %s @%08x and %s @%08x\n",
550 name, compiland_name,
551 source_get(module, result->compiland->source), (unsigned int)result->symp->st_value,
552 source_get(module, ste->compiland->source), (unsigned int)ste->symp->st_value);
560 if (!result && !(result = weak_result))
562 FIXME("Couldn't find symbol %s!%s in symtab\n",
563 debugstr_w(module->module.ModuleName), name);
569 /******************************************************************
570 * elf_finish_stabs_info
572 * - get any relevant information (address & size) from the bits we got from the
573 * stabs debugging information
575 static void elf_finish_stabs_info(struct module* module, const struct hash_table* symtab)
577 struct hash_table_iter hti;
582 hash_table_iter_init(&module->ht_symbols, &hti, NULL);
583 while ((ptr = hash_table_iter_up(&hti)))
585 sym = GET_ENTRY(ptr, struct symt_ht, hash_elt);
586 switch (sym->symt.tag)
589 if (((struct symt_function*)sym)->address != module->elf_info->elf_addr &&
590 ((struct symt_function*)sym)->size)
594 symp = elf_lookup_symtab(module, symtab, sym->hash_elt.name,
595 ((struct symt_function*)sym)->container);
598 if (((struct symt_function*)sym)->address != module->elf_info->elf_addr &&
599 ((struct symt_function*)sym)->address != module->elf_info->elf_addr + symp->st_value)
600 FIXME("Changing address for %p/%s!%s from %08lx to %08lx\n",
601 sym, debugstr_w(module->module.ModuleName), sym->hash_elt.name,
602 ((struct symt_function*)sym)->address, module->elf_info->elf_addr + symp->st_value);
603 if (((struct symt_function*)sym)->size && ((struct symt_function*)sym)->size != symp->st_size)
604 FIXME("Changing size for %p/%s!%s from %08lx to %08x\n",
605 sym, debugstr_w(module->module.ModuleName), sym->hash_elt.name,
606 ((struct symt_function*)sym)->size, (unsigned int)symp->st_size);
608 ((struct symt_function*)sym)->address = module->elf_info->elf_addr +
610 ((struct symt_function*)sym)->size = symp->st_size;
612 FIXME("Couldn't find %s!%s\n",
613 debugstr_w(module->module.ModuleName), sym->hash_elt.name);
616 switch (((struct symt_data*)sym)->kind)
619 case DataIsFileStatic:
620 if (((struct symt_data*)sym)->u.var.offset != module->elf_info->elf_addr)
622 symp = elf_lookup_symtab(module, symtab, sym->hash_elt.name,
623 ((struct symt_data*)sym)->container);
626 if (((struct symt_data*)sym)->u.var.offset != module->elf_info->elf_addr &&
627 ((struct symt_data*)sym)->u.var.offset != module->elf_info->elf_addr + symp->st_value)
628 FIXME("Changing address for %p/%s!%s from %08lx to %08lx\n",
629 sym, debugstr_w(module->module.ModuleName), sym->hash_elt.name,
630 ((struct symt_function*)sym)->address, module->elf_info->elf_addr + symp->st_value);
631 ((struct symt_data*)sym)->u.var.offset = module->elf_info->elf_addr +
633 ((struct symt_data*)sym)->kind = (ELF32_ST_BIND(symp->st_info) == STB_LOCAL) ?
634 DataIsFileStatic : DataIsGlobal;
636 FIXME("Couldn't find %s!%s\n",
637 debugstr_w(module->module.ModuleName), sym->hash_elt.name);
643 FIXME("Unsupported tag %u\n", sym->symt.tag);
647 /* since we may have changed some addresses & sizes, mark the module to be resorted */
648 module->sortlist_valid = FALSE;
651 /******************************************************************
652 * elf_load_wine_thunks
654 * creating the thunk objects for a wine native DLL
656 static int elf_new_wine_thunks(struct module* module, const struct hash_table* ht_symtab,
657 const struct elf_thunk_area* thunks)
660 struct hash_table_iter hti;
661 struct symtab_elt* ste;
663 struct symt_ht* symt;
665 hash_table_iter_init(ht_symtab, &hti, NULL);
666 while ((ste = hash_table_iter_up(&hti)))
668 if (ste->used) continue;
670 addr = module->elf_info->elf_addr + ste->symp->st_value;
672 j = elf_is_in_thunk_area(ste->symp->st_value, thunks);
673 if (j >= 0) /* thunk found */
675 symt_new_thunk(module, ste->compiland, ste->ht_elt.name, thunks[j].ordinal,
676 addr, ste->symp->st_size);
682 symt = symt_find_nearest(module, addr);
683 if (symt && !symt_get_info(module, &symt->symt, TI_GET_ADDRESS, &ref_addr))
685 if (!symt || addr != ref_addr)
687 /* creating public symbols for all the ELF symbols which haven't been
688 * used yet (ie we have no debug information on them)
689 * That's the case, for example, of the .spec.c files
691 switch (ELF32_ST_TYPE(ste->symp->st_info))
694 symt_new_function(module, ste->compiland, ste->ht_elt.name,
695 addr, ste->symp->st_size, NULL);
698 symt_new_global_variable(module, ste->compiland, ste->ht_elt.name,
699 ELF32_ST_BIND(ste->symp->st_info) == STB_LOCAL,
700 addr, ste->symp->st_size, NULL);
703 FIXME("Shouldn't happen\n");
706 /* FIXME: this is a hack !!!
707 * we are adding new symbols, but as we're parsing a symbol table
708 * (hopefully without duplicate symbols) we delay rebuilding the sorted
709 * module table until we're done with the symbol table
710 * Otherwise, as we intertwine symbols's add and lookup, performance
713 module->sortlist_valid = TRUE;
715 else if (strcmp(ste->ht_elt.name, symt->hash_elt.name))
717 ULONG64 xaddr = 0, xsize = 0;
720 symt_get_info(module, &symt->symt, TI_GET_ADDRESS, &xaddr);
721 symt_get_info(module, &symt->symt, TI_GET_LENGTH, &xsize);
722 symt_get_info(module, &symt->symt, TI_GET_DATAKIND, &kind);
724 /* If none of symbols has a correct size, we consider they are both markers
725 * Hence, we can silence this warning
726 * Also, we check that we don't have two symbols, one local, the other
727 * global which is legal
729 if ((xsize || ste->symp->st_size) &&
730 (kind == (ELF32_ST_BIND(ste->symp->st_info) == STB_LOCAL) ? DataIsFileStatic : DataIsGlobal))
731 FIXME("Duplicate in %s: %s<%08lx-%08x> %s<%s-%s>\n",
732 debugstr_w(module->module.ModuleName),
733 ste->ht_elt.name, addr, (unsigned int)ste->symp->st_size,
735 wine_dbgstr_longlong(xaddr), wine_dbgstr_longlong(xsize));
739 /* see comment above */
740 module->sortlist_valid = FALSE;
744 /******************************************************************
745 * elf_new_public_symbols
747 * Creates a set of public symbols from an ELF symtab
749 static int elf_new_public_symbols(struct module* module, const struct hash_table* symtab)
751 struct hash_table_iter hti;
752 struct symtab_elt* ste;
754 if (dbghelp_options & SYMOPT_NO_PUBLICS) return TRUE;
756 /* FIXME: we're missing the ELF entry point here */
758 hash_table_iter_init(symtab, &hti, NULL);
759 while ((ste = hash_table_iter_up(&hti)))
761 symt_new_public(module, ste->compiland, ste->ht_elt.name,
762 module->elf_info->elf_addr + ste->symp->st_value,
768 static BOOL elf_check_debug_link(const WCHAR* file, struct elf_file_map* fmap, DWORD crc)
771 if (!elf_map_file(file, fmap)) return FALSE;
772 if (!(ret = crc == calc_crc32(fmap->fd)))
774 WARN("Bad CRC for file %s (got %08x while expecting %08x)\n",
775 debugstr_w(file), calc_crc32(fmap->fd), crc);
776 elf_unmap_file(fmap);
781 /******************************************************************
782 * elf_locate_debug_link
784 * Locate a filename from a .gnu_debuglink section, using the same
786 * "If the full name of the directory containing the executable is
787 * execdir, and the executable has a debug link that specifies the
788 * name debugfile, then GDB will automatically search for the
789 * debugging information file in three places:
790 * - the directory containing the executable file (that is, it
791 * will look for a file named `execdir/debugfile',
792 * - a subdirectory of that directory named `.debug' (that is, the
793 * file `execdir/.debug/debugfile', and
794 * - a subdirectory of the global debug file directory that includes
795 * the executable's full path, and the name from the link (that is,
796 * the file `globaldebugdir/execdir/debugfile', where globaldebugdir
797 * is the global debug file directory, and execdir has been turned
798 * into a relative path)." (from GDB manual)
800 static BOOL elf_locate_debug_link(struct elf_file_map* fmap, const char* filename,
801 const WCHAR* loaded_file, DWORD crc)
803 static const WCHAR globalDebugDirW[] = {'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/'};
804 static const WCHAR dotDebugW[] = {'.','d','e','b','u','g','/'};
805 const size_t globalDebugDirLen = sizeof(globalDebugDirW) / sizeof(WCHAR);
809 struct elf_file_map* fmap_link = NULL;
811 fmap_link = HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link));
812 if (!fmap_link) return FALSE;
814 filename_len = MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, NULL, 0);
815 p = HeapAlloc(GetProcessHeap(), 0,
816 (globalDebugDirLen + strlenW(loaded_file) + 6 + 1 + filename_len + 1) * sizeof(WCHAR));
819 /* we prebuild the string with "execdir" */
820 strcpyW(p, loaded_file);
821 slash = strrchrW(p, '/');
822 if (slash == NULL) slash = p; else slash++;
824 /* testing execdir/filename */
825 MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash, filename_len);
826 if (elf_check_debug_link(p, fmap_link, crc)) goto found;
828 /* testing execdir/.debug/filename */
829 memcpy(slash, dotDebugW, sizeof(dotDebugW));
830 MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash + sizeof(dotDebugW) / sizeof(WCHAR), filename_len);
831 if (elf_check_debug_link(p, fmap_link, crc)) goto found;
833 /* testing globaldebugdir/execdir/filename */
834 memmove(p + globalDebugDirLen, p, (slash - p) * sizeof(WCHAR));
835 memcpy(p, globalDebugDirW, globalDebugDirLen * sizeof(WCHAR));
836 slash += globalDebugDirLen;
837 MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, slash, filename_len);
838 if (elf_check_debug_link(p, fmap_link, crc)) goto found;
840 /* finally testing filename */
841 if (elf_check_debug_link(slash, fmap_link, crc)) goto found;
844 WARN("Couldn't locate or map %s\n", filename);
845 HeapFree(GetProcessHeap(), 0, p);
846 HeapFree(GetProcessHeap(), 0, fmap_link);
850 TRACE("Located debug information file %s at %s\n", filename, debugstr_w(p));
851 HeapFree(GetProcessHeap(), 0, p);
852 fmap->alternate = fmap_link;
856 /******************************************************************
857 * elf_debuglink_parse
859 * Parses a .gnu_debuglink section and loads the debug info from
860 * the external file specified there.
862 static BOOL elf_debuglink_parse(struct elf_file_map* fmap, const struct module* module,
863 const BYTE* debuglink)
865 /* The content of a debug link section is:
866 * 1/ a NULL terminated string, containing the file name for the
868 * 2/ padding on 4 byte boundary
869 * 3/ CRC of the linked ELF file
871 const char* dbg_link = (const char*)debuglink;
874 crc = *(const DWORD*)(dbg_link + ((DWORD_PTR)(strlen(dbg_link) + 4) & ~3));
875 return elf_locate_debug_link(fmap, dbg_link, module->module.LoadedImageName, crc);
878 /******************************************************************
879 * elf_load_debug_info_from_map
881 * Loads the symbolic information from ELF module which mapping is described
883 * the module has been loaded at 'load_offset' address, so symbols' address
884 * relocation is performed.
885 * CRC is checked if fmap->with_crc is TRUE
887 * 0 if the file doesn't contain symbolic info (or this info cannot be
891 static BOOL elf_load_debug_info_from_map(struct module* module,
892 struct elf_file_map* fmap,
894 struct hash_table* ht_symtab)
896 BOOL ret = FALSE, lret;
897 struct elf_thunk_area thunks[] =
899 {"__wine_spec_import_thunks", THUNK_ORDINAL_NOTYPE, 0, 0}, /* inter DLL calls */
900 {"__wine_spec_delayed_import_loaders", THUNK_ORDINAL_LOAD, 0, 0}, /* delayed inter DLL calls */
901 {"__wine_spec_delayed_import_thunks", THUNK_ORDINAL_LOAD, 0, 0}, /* delayed inter DLL calls */
902 {"__wine_delay_load", THUNK_ORDINAL_LOAD, 0, 0}, /* delayed inter DLL calls */
903 {"__wine_spec_thunk_text_16", -16, 0, 0}, /* 16 => 32 thunks */
904 {"__wine_spec_thunk_text_32", -32, 0, 0}, /* 32 => 16 thunks */
908 module->module.SymType = SymExport;
910 /* create a hash table for the symtab */
911 elf_hash_symtab(module, pool, ht_symtab, fmap, thunks);
913 if (!(dbghelp_options & SYMOPT_PUBLICS_ONLY))
915 struct elf_section_map stab_sect, stabstr_sect;
916 struct elf_section_map debug_sect, debug_str_sect, debug_abbrev_sect,
917 debug_line_sect, debug_loclist_sect;
918 struct elf_section_map debuglink_sect;
920 /* if present, add the .gnu_debuglink file as an alternate to current one */
921 if (elf_find_section(fmap, ".gnu_debuglink", SHT_NULL, &debuglink_sect))
923 const BYTE* dbg_link;
925 dbg_link = (const BYTE*)elf_map_section(&debuglink_sect);
926 if (dbg_link != ELF_NO_MAP)
928 lret = elf_debuglink_parse(fmap, module, dbg_link);
930 WARN("Couldn't load linked debug file for %s\n",
931 debugstr_w(module->module.ModuleName));
934 elf_unmap_section(&debuglink_sect);
936 if (elf_find_section(fmap, ".stab", SHT_NULL, &stab_sect) &&
937 elf_find_section(fmap, ".stabstr", SHT_NULL, &stabstr_sect))
942 stab = elf_map_section(&stab_sect);
943 stabstr = elf_map_section(&stabstr_sect);
944 if (stab != ELF_NO_MAP && stabstr != ELF_NO_MAP)
946 /* OK, now just parse all of the stabs. */
947 lret = stabs_parse(module, module->elf_info->elf_addr,
948 stab, elf_get_map_size(&stab_sect),
949 stabstr, elf_get_map_size(&stabstr_sect),
952 /* and fill in the missing information for stabs */
953 elf_finish_stabs_info(module, ht_symtab);
955 WARN("Couldn't correctly read stabs\n");
959 elf_unmap_section(&stab_sect);
960 elf_unmap_section(&stabstr_sect);
962 if (elf_find_section(fmap, ".debug_info", SHT_NULL, &debug_sect))
964 /* Dwarf 2 debug information */
965 const BYTE* dw2_debug;
966 const BYTE* dw2_debug_abbrev;
967 const BYTE* dw2_debug_str;
968 const BYTE* dw2_debug_line;
969 const BYTE* dw2_debug_loclist;
971 /* debug info might have a different base address than .so file
972 * when elf file is prelinked after splitting off debug info
973 * adjust symbol base addresses accordingly
975 unsigned long load_offset = module->elf_info->elf_addr +
976 fmap->elf_start - debug_sect.fmap->elf_start;
978 TRACE("Loading Dwarf2 information for %s\n", debugstr_w(module->module.ModuleName));
980 elf_find_section(fmap, ".debug_str", SHT_NULL, &debug_str_sect);
981 elf_find_section(fmap, ".debug_abbrev", SHT_NULL, &debug_abbrev_sect);
982 elf_find_section(fmap, ".debug_line", SHT_NULL, &debug_line_sect);
983 elf_find_section(fmap, ".debug_loc", SHT_NULL, &debug_loclist_sect);
985 dw2_debug = (const BYTE*)elf_map_section(&debug_sect);
986 dw2_debug_abbrev = (const BYTE*)elf_map_section(&debug_abbrev_sect);
987 dw2_debug_str = (const BYTE*)elf_map_section(&debug_str_sect);
988 dw2_debug_line = (const BYTE*)elf_map_section(&debug_line_sect);
989 dw2_debug_loclist = (const BYTE*)elf_map_section(&debug_loclist_sect);
990 if (dw2_debug != ELF_NO_MAP && dw2_debug_abbrev != ELF_NO_MAP && dw2_debug_str != ELF_NO_MAP)
992 /* OK, now just parse dwarf2 debug infos. */
993 lret = dwarf2_parse(module, load_offset, thunks,
994 dw2_debug, elf_get_map_size(&debug_sect),
995 dw2_debug_abbrev, elf_get_map_size(&debug_abbrev_sect),
996 dw2_debug_str, elf_get_map_size(&debug_str_sect),
997 dw2_debug_line, elf_get_map_size(&debug_line_sect),
998 dw2_debug_loclist, elf_get_map_size(&debug_loclist_sect));
1001 WARN("Couldn't correctly read dwarf2\n");
1004 elf_unmap_section(&debug_sect);
1005 elf_unmap_section(&debug_abbrev_sect);
1006 elf_unmap_section(&debug_str_sect);
1007 elf_unmap_section(&debug_line_sect);
1008 elf_unmap_section(&debug_loclist_sect);
1011 if (strstrW(module->module.ModuleName, S_ElfW) ||
1012 !strcmpW(module->module.ModuleName, S_WineLoaderW))
1014 /* add the thunks for native libraries */
1015 if (!(dbghelp_options & SYMOPT_PUBLICS_ONLY))
1016 elf_new_wine_thunks(module, ht_symtab, thunks);
1018 /* add all the public symbols from symtab */
1019 if (elf_new_public_symbols(module, ht_symtab) && !ret) ret = TRUE;
1024 /******************************************************************
1025 * elf_load_debug_info
1027 * Loads ELF debugging information from the module image file.
1029 BOOL elf_load_debug_info(struct module* module, struct elf_file_map* fmap)
1033 struct hash_table ht_symtab;
1034 struct elf_file_map my_fmap;
1036 if (module->type != DMT_ELF || !module->elf_info)
1038 ERR("Bad elf module '%s'\n", debugstr_w(module->module.LoadedImageName));
1042 pool_init(&pool, 65536);
1043 hash_table_init(&pool, &ht_symtab, 256);
1048 ret = elf_map_file(module->module.LoadedImageName, fmap);
1051 ret = elf_load_debug_info_from_map(module, fmap, &pool, &ht_symtab);
1055 module->elf_info->file_map = *fmap;
1056 elf_reset_file_map(fmap);
1059 pool_destroy(&pool);
1060 if (fmap == &my_fmap) elf_unmap_file(fmap);
1064 /******************************************************************
1065 * elf_fetch_file_info
1067 * Gathers some more information for an ELF module from a given file
1069 BOOL elf_fetch_file_info(const WCHAR* name, DWORD* base,
1070 DWORD* size, DWORD* checksum)
1072 struct elf_file_map fmap;
1074 if (!elf_map_file(name, &fmap)) return FALSE;
1075 if (base) *base = fmap.elf_start;
1076 *size = fmap.elf_size;
1077 *checksum = calc_crc32(fmap.fd);
1078 elf_unmap_file(&fmap);
1082 /******************************************************************
1085 * Loads the information for ELF module stored in 'filename'
1086 * the module has been loaded at 'load_offset' address
1088 * -1 if the file cannot be found/opened
1089 * 0 if the file doesn't contain symbolic info (or this info cannot be
1093 static BOOL elf_load_file(struct process* pcs, const WCHAR* filename,
1094 unsigned long load_offset, struct elf_info* elf_info)
1097 struct elf_file_map fmap;
1099 TRACE("Processing elf file '%s' at %08lx\n", debugstr_w(filename), load_offset);
1101 if (!elf_map_file(filename, &fmap)) return ret;
1103 /* Next, we need to find a few of the internal ELF headers within
1104 * this thing. We need the main executable header, and the section
1107 if (!fmap.elf_start && !load_offset)
1108 ERR("Relocatable ELF %s, but no load address. Loading at 0x0000000\n",
1109 debugstr_w(filename));
1110 if (fmap.elf_start && load_offset)
1112 WARN("Non-relocatable ELF %s, but load address of 0x%08lx supplied. "
1113 "Assuming load address is corrupt\n", debugstr_w(filename), load_offset);
1117 if (elf_info->flags & ELF_INFO_DEBUG_HEADER)
1119 struct elf_section_map esm;
1121 if (elf_find_section(&fmap, ".dynamic", SHT_DYNAMIC, &esm))
1124 char* ptr = (char*)fmap.sect[esm.sidx].shdr.sh_addr;
1129 if (!ReadProcessMemory(pcs->handle, ptr, &dyn, sizeof(dyn), &len) ||
1132 if (dyn.d_tag == DT_DEBUG)
1134 elf_info->dbg_hdr_addr = dyn.d_un.d_ptr;
1138 } while (dyn.d_tag != DT_NULL);
1139 if (dyn.d_tag == DT_NULL) goto leave;
1141 elf_end_find(&fmap);
1144 if (elf_info->flags & ELF_INFO_MODULE)
1146 struct elf_module_info *elf_module_info =
1147 HeapAlloc(GetProcessHeap(), 0, sizeof(struct elf_module_info));
1148 if (!elf_module_info) goto leave;
1149 elf_info->module = module_new(pcs, filename, DMT_ELF, FALSE,
1150 (load_offset) ? load_offset : fmap.elf_start,
1151 fmap.elf_size, 0, calc_crc32(fmap.fd));
1152 elf_info->module->module_remove = elf_module_remove;
1153 if (!elf_info->module)
1155 HeapFree(GetProcessHeap(), 0, elf_module_info);
1158 elf_info->module->elf_info = elf_module_info;
1159 elf_info->module->elf_info->elf_addr = load_offset;
1161 if (dbghelp_options & SYMOPT_DEFERRED_LOADS)
1163 elf_info->module->module.SymType = SymDeferred;
1166 else ret = elf_load_debug_info(elf_info->module, &fmap);
1168 elf_info->module->elf_info->elf_mark = 1;
1169 elf_info->module->elf_info->elf_loader = 0;
1172 if (elf_info->flags & ELF_INFO_NAME)
1175 ptr = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(filename) + 1) * sizeof(WCHAR));
1178 strcpyW(ptr, filename);
1179 elf_info->module_name = ptr;
1184 elf_unmap_file(&fmap);
1189 /******************************************************************
1190 * elf_load_file_from_path
1191 * tries to load an ELF file from a set of paths (separated by ':')
1193 static BOOL elf_load_file_from_path(HANDLE hProcess,
1194 const WCHAR* filename,
1195 unsigned long load_offset,
1197 struct elf_info* elf_info)
1201 WCHAR* pathW = NULL;
1204 if (!path) return FALSE;
1206 len = MultiByteToWideChar(CP_UNIXCP, 0, path, -1, NULL, 0);
1207 pathW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1208 if (!pathW) return FALSE;
1209 MultiByteToWideChar(CP_UNIXCP, 0, path, -1, pathW, len);
1211 for (s = pathW; s && *s; s = (t) ? (t+1) : NULL)
1213 t = strchrW(s, ':');
1215 fn = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(filename) + 1 + lstrlenW(s) + 1) * sizeof(WCHAR));
1218 strcatW(fn, S_SlashW);
1219 strcatW(fn, filename);
1220 ret = elf_load_file(hProcess, fn, load_offset, elf_info);
1221 HeapFree(GetProcessHeap(), 0, fn);
1223 s = (t) ? (t+1) : NULL;
1226 HeapFree(GetProcessHeap(), 0, pathW);
1230 /******************************************************************
1231 * elf_load_file_from_dll_path
1233 * Tries to load an ELF file from the dll path
1235 static BOOL elf_load_file_from_dll_path(HANDLE hProcess,
1236 const WCHAR* filename,
1237 unsigned long load_offset,
1238 struct elf_info* elf_info)
1241 unsigned int index = 0;
1244 while (!ret && (path = wine_dll_enum_load_path( index++ )))
1249 len = MultiByteToWideChar(CP_UNIXCP, 0, path, -1, NULL, 0);
1251 name = HeapAlloc( GetProcessHeap(), 0,
1252 (len + lstrlenW(filename) + 2) * sizeof(WCHAR) );
1255 MultiByteToWideChar(CP_UNIXCP, 0, path, -1, name, len);
1256 strcatW( name, S_SlashW );
1257 strcatW( name, filename );
1258 ret = elf_load_file(hProcess, name, load_offset, elf_info);
1259 HeapFree( GetProcessHeap(), 0, name );
1264 /******************************************************************
1265 * elf_search_and_load_file
1267 * lookup a file in standard ELF locations, and if found, load it
1269 static BOOL elf_search_and_load_file(struct process* pcs, const WCHAR* filename,
1270 unsigned long load_offset,
1271 struct elf_info* elf_info)
1274 struct module* module;
1275 static WCHAR S_libstdcPPW[] = {'l','i','b','s','t','d','c','+','+','\0'};
1277 if (filename == NULL || *filename == '\0') return FALSE;
1278 if ((module = module_is_already_loaded(pcs, filename)))
1280 elf_info->module = module;
1281 module->elf_info->elf_mark = 1;
1282 return module->module.SymType;
1285 if (strstrW(filename, S_libstdcPPW)) return FALSE; /* We know we can't do it */
1286 ret = elf_load_file(pcs, filename, load_offset, elf_info);
1287 /* if relative pathname, try some absolute base dirs */
1288 if (!ret && !strchrW(filename, '/'))
1290 ret = elf_load_file_from_path(pcs, filename, load_offset,
1291 getenv("PATH"), elf_info) ||
1292 elf_load_file_from_path(pcs, filename, load_offset,
1293 getenv("LD_LIBRARY_PATH"), elf_info);
1294 if (!ret) ret = elf_load_file_from_dll_path(pcs, filename, load_offset, elf_info);
1300 /******************************************************************
1301 * elf_enum_modules_internal
1303 * Enumerate ELF modules from a running process
1305 static BOOL elf_enum_modules_internal(const struct process* pcs,
1306 const WCHAR* main_name,
1307 enum_modules_cb cb, void* user)
1309 struct r_debug dbg_hdr;
1313 WCHAR bufstrW[MAX_PATH];
1315 if (!pcs->dbg_hdr_addr ||
1316 !ReadProcessMemory(pcs->handle, (void*)pcs->dbg_hdr_addr,
1317 &dbg_hdr, sizeof(dbg_hdr), NULL))
1320 /* Now walk the linked list. In all known ELF implementations,
1321 * the dynamic loader maintains this linked list for us. In some
1322 * cases the first entry doesn't appear with a name, in other cases it
1325 for (lm_addr = (void*)dbg_hdr.r_map; lm_addr; lm_addr = (void*)lm.l_next)
1327 if (!ReadProcessMemory(pcs->handle, lm_addr, &lm, sizeof(lm), NULL))
1330 if (lm.l_prev != NULL && /* skip first entry, normally debuggee itself */
1331 lm.l_name != NULL &&
1332 ReadProcessMemory(pcs->handle, lm.l_name, bufstr, sizeof(bufstr), NULL))
1334 bufstr[sizeof(bufstr) - 1] = '\0';
1335 MultiByteToWideChar(CP_UNIXCP, 0, bufstr, -1, bufstrW, sizeof(bufstrW) / sizeof(WCHAR));
1336 if (main_name && !bufstrW[0]) strcpyW(bufstrW, main_name);
1337 if (!cb(bufstrW, (unsigned long)lm.l_addr, user)) break;
1345 struct process* pcs;
1346 struct elf_info elf_info;
1349 static BOOL elf_enum_sync_cb(const WCHAR* name, unsigned long addr, void* user)
1351 struct elf_sync* es = user;
1353 elf_search_and_load_file(es->pcs, name, addr, &es->elf_info);
1357 /******************************************************************
1358 * elf_synchronize_module_list
1360 * this functions rescans the debuggee module's list and synchronizes it with
1361 * the one from 'pcs', ie:
1362 * - if a module is in debuggee and not in pcs, it's loaded into pcs
1363 * - if a module is in pcs and not in debuggee, it's unloaded from pcs
1365 BOOL elf_synchronize_module_list(struct process* pcs)
1367 struct module* module;
1370 for (module = pcs->lmodules; module; module = module->next)
1372 if (module->type == DMT_ELF && !module->is_virtual)
1373 module->elf_info->elf_mark = 0;
1377 es.elf_info.flags = ELF_INFO_MODULE;
1378 if (!elf_enum_modules_internal(pcs, NULL, elf_enum_sync_cb, &es))
1381 module = pcs->lmodules;
1384 if (module->type == DMT_ELF && !module->is_virtual &&
1385 !module->elf_info->elf_mark && !module->elf_info->elf_loader)
1387 module_remove(pcs, module);
1388 /* restart all over */
1389 module = pcs->lmodules;
1391 else module = module->next;
1396 /******************************************************************
1399 * Lookup in a running ELF process the loader, and sets its ELF link
1400 * address (for accessing the list of loaded .so libs) in pcs.
1401 * If flags is ELF_INFO_MODULE, the module for the loader is also
1402 * added as a module into pcs.
1404 static BOOL elf_search_loader(struct process* pcs, struct elf_info* elf_info)
1409 /* All binaries are loaded with WINELOADER (if run from tree) or by the
1412 if ((ptr = getenv("WINELOADER")))
1414 WCHAR tmp[MAX_PATH];
1415 MultiByteToWideChar(CP_ACP, 0, ptr, -1, tmp, sizeof(tmp) / sizeof(WCHAR));
1416 ret = elf_search_and_load_file(pcs, tmp, 0, elf_info);
1420 ret = elf_search_and_load_file(pcs, S_WineW, 0, elf_info);
1425 /******************************************************************
1426 * elf_read_wine_loader_dbg_info
1428 * Try to find a decent wine executable which could have loaded the debuggee
1430 BOOL elf_read_wine_loader_dbg_info(struct process* pcs)
1432 struct elf_info elf_info;
1434 elf_info.flags = ELF_INFO_DEBUG_HEADER | ELF_INFO_MODULE;
1435 if (!elf_search_loader(pcs, &elf_info)) return FALSE;
1436 elf_info.module->elf_info->elf_loader = 1;
1437 module_set_module(elf_info.module, S_WineLoaderW);
1438 return (pcs->dbg_hdr_addr = elf_info.dbg_hdr_addr) != 0;
1441 /******************************************************************
1444 * Enumerates the ELF loaded modules from a running target (hProc)
1445 * This function doesn't require that someone has called SymInitialize
1446 * on this very process.
1448 BOOL elf_enum_modules(HANDLE hProc, enum_modules_cb cb, void* user)
1451 struct elf_info elf_info;
1454 memset(&pcs, 0, sizeof(pcs));
1456 elf_info.flags = ELF_INFO_DEBUG_HEADER | ELF_INFO_NAME;
1457 if (!elf_search_loader(&pcs, &elf_info)) return FALSE;
1458 pcs.dbg_hdr_addr = elf_info.dbg_hdr_addr;
1459 ret = elf_enum_modules_internal(&pcs, elf_info.module_name, cb, user);
1460 HeapFree(GetProcessHeap(), 0, (char*)elf_info.module_name);
1466 struct process* pcs;
1467 struct elf_info elf_info;
1472 /******************************************************************
1475 * Callback for elf_load_module, used to walk the list of loaded
1478 static BOOL elf_load_cb(const WCHAR* name, unsigned long addr, void* user)
1480 struct elf_load* el = user;
1483 /* memcmp is needed for matches when bufstr contains also version information
1484 * el->name: libc.so, name: libc.so.6.0
1486 p = strrchrW(name, '/');
1488 if (!memcmp(p, el->name, lstrlenW(el->name) * sizeof(WCHAR)))
1490 el->ret = elf_search_and_load_file(el->pcs, name, addr, &el->elf_info);
1496 /******************************************************************
1499 * loads an ELF module and stores it in process' module list
1500 * Also, find module real name and load address from
1501 * the real loaded modules list in pcs address space
1503 struct module* elf_load_module(struct process* pcs, const WCHAR* name, unsigned long addr)
1507 TRACE("(%p %s %08lx)\n", pcs, debugstr_w(name), addr);
1509 el.elf_info.flags = ELF_INFO_MODULE;
1512 if (pcs->dbg_hdr_addr) /* we're debugging a life target */
1515 /* do only the lookup from the filename, not the path (as we lookup module
1516 * name in the process' loaded module list)
1518 el.name = strrchrW(name, '/');
1519 if (!el.name++) el.name = name;
1522 if (!elf_enum_modules_internal(pcs, NULL, elf_load_cb, &el))
1528 el.ret = elf_search_and_load_file(pcs, el.name, addr, &el.elf_info);
1530 if (!el.ret) return NULL;
1531 assert(el.elf_info.module);
1532 return el.elf_info.module;
1535 #else /* !__ELF__ */
1537 BOOL elf_synchronize_module_list(struct process* pcs)
1542 BOOL elf_fetch_file_info(const WCHAR* name, DWORD* base,
1543 DWORD* size, DWORD* checksum)
1548 BOOL elf_read_wine_loader_dbg_info(struct process* pcs)
1553 BOOL elf_enum_modules(HANDLE hProc, enum_modules_cb cb, void* user)
1558 struct module* elf_load_module(struct process* pcs, const WCHAR* name, unsigned long addr)
1563 BOOL elf_load_debug_info(struct module* module, struct elf_file_map* fmap)
1568 int elf_is_in_thunk_area(unsigned long addr,
1569 const struct elf_thunk_area* thunks)
1573 #endif /* __ELF__ */