Lines Matching +full:parent +full:- +full:module
2 Copyright (C) 2008-2010, 2013, 2015 Red Hat, Inc.
49 This implementation is pessimal for non-mmap cases and should
52 elf_begin_rand (Elf *parent, off_t offset, off_t size, off_t *next) in elf_begin_rand() argument
54 if (parent == NULL) in elf_begin_rand()
57 off_t min = (parent->kind == ELF_K_ELF ? in elf_begin_rand()
58 (parent->class == ELFCLASS32 in elf_begin_rand()
60 : parent->kind == ELF_K_AR ? SARMAG in elf_begin_rand()
64 || unlikely (offset >= (off_t) parent->maximum_size)) in elf_begin_rand()
69 if (parent->kind == ELF_K_AR) in elf_begin_rand()
71 /* File size, in ASCII decimal, right-padded with ASCII spaces. in elf_begin_rand()
79 if (unlikely (parent->maximum_size - offset < sizeof (struct ar_hdr))) in elf_begin_rand()
82 if (parent->map_address != NULL) in elf_begin_rand()
83 memcpy (ar_size, parent->map_address + parent->start_offset + offset, in elf_begin_rand()
85 else if (unlikely (pread_retry (parent->fildes, in elf_begin_rand()
87 parent->start_offset + offset in elf_begin_rand()
97 || unlikely ((off_t) parent->maximum_size - offset < size)) in elf_begin_rand()
101 if (unlikely ((off_t) parent->maximum_size - offset < size)) in elf_begin_rand()
109 && unlikely (size == (off_t) parent->maximum_size)) in elf_begin_rand()
110 return elf_clone (parent, parent->cmd); in elf_begin_rand()
112 /* Note the image is guaranteed live only as long as PARENT in elf_begin_rand()
116 Elf_Data *data = elf_getdata_rawchunk (parent, offset, size, ELF_T_BYTE); in elf_begin_rand()
119 assert ((off_t) data->d_size == size); in elf_begin_rand()
120 return elf_memory (data->d_buf, size); in elf_begin_rand()
128 return -1; in dwfl_report_core_segments()
133 notes->p_type = PT_NULL; in dwfl_report_core_segments()
142 return -1; in dwfl_report_core_segments()
144 switch (phdr->p_type) in dwfl_report_core_segments()
190 if (core->map_address == NULL) in core_file_read_eagerly()
197 (*elfp)->flags |= ELF_F_MALLOCED; in core_file_read_eagerly()
204 *elfp = elf_begin_rand (core, *buffer - core->map_address, whole, NULL); in core_file_read_eagerly()
222 requires find_elf hook re-doing the magic to fall back if no file found in core_file_read_eagerly()
225 if (whole > MAX_EAGER_COST && mod->build_id_len > 0) in core_file_read_eagerly()
233 but we don't have a build-id. */ in core_file_read_eagerly()
235 if (core->map_address != NULL) in core_file_read_eagerly()
247 *pend = (pphdr->p_offset + pphdr->p_filesz + align - 1) & -align; in update_end()
248 *pend_vaddr = (pphdr->p_vaddr + pphdr->p_memsz + align - 1) & -align; in update_end()
257 while (*pend <= start || *pend - start < size) in do_more()
259 if (pphdr->p_filesz < pphdr->p_memsz) in do_more()
266 if (pphdr->p_type == PT_LOAD) in do_more()
268 if (pphdr->p_offset > *pend in do_more()
269 || pphdr->p_vaddr > *pend_vaddr) in do_more()
290 if (ndx == -1) in dwfl_elf_phdr_memory_callback()
293 if (elf->map_address == NULL) in dwfl_elf_phdr_memory_callback()
300 const GElf_Off align = dwfl->segment_align ?: 1; in dwfl_elf_phdr_memory_callback()
307 || ((phdr.p_vaddr + phdr.p_memsz + align - 1) & -align) <= vaddr); in dwfl_elf_phdr_memory_callback()
309 GElf_Off start = vaddr - phdr.p_vaddr + phdr.p_offset; in dwfl_elf_phdr_memory_callback()
323 if (elf->map_address != NULL && start < elf->maximum_size) in dwfl_elf_phdr_memory_callback()
324 (void) more (elf->maximum_size - start); in dwfl_elf_phdr_memory_callback()
328 if (unlikely (end > elf->maximum_size)) in dwfl_elf_phdr_memory_callback()
329 end = elf->maximum_size; in dwfl_elf_phdr_memory_callback()
335 if (end - start < minread) in dwfl_elf_phdr_memory_callback()
338 if (elf->map_address != NULL) in dwfl_elf_phdr_memory_callback()
340 void *contents = elf->map_address + elf->start_offset + start; in dwfl_elf_phdr_memory_callback()
341 size_t size = end - start; in dwfl_elf_phdr_memory_callback()
348 size = eos + 1 - contents; in dwfl_elf_phdr_memory_callback()
368 MAX (4096, MIN (end - start, in dwfl_elf_phdr_memory_callback()
378 ssize_t nread = pread_retry (elf->fildes, into, *buffer_available, start); in dwfl_elf_phdr_memory_callback()
397 nread = eos + 1 - into; in dwfl_elf_phdr_memory_callback()
413 while (r_debug_info->module != NULL) in clear_r_debug_info()
415 struct r_debug_info_module *module = r_debug_info->module; in clear_r_debug_info() local
416 r_debug_info->module = module->next; in clear_r_debug_info()
417 elf_end (module->elf); in clear_r_debug_info()
418 if (module->fd != -1) in clear_r_debug_info()
419 close (module->fd); in clear_r_debug_info()
420 free (module); in clear_r_debug_info()
437 if (phdr->p_type == PT_DYNAMIC) in __libdwfl_dynamic_vaddr_get()
439 *vaddrp = phdr->p_vaddr; in __libdwfl_dynamic_vaddr_get()
454 return -1; in dwfl_core_file_report()
458 if (dwfl->user_core != NULL) in dwfl_core_file_report()
459 free (dwfl->user_core->executable_for_core); in dwfl_core_file_report()
462 if (dwfl->user_core != NULL) in dwfl_core_file_report()
463 dwfl->user_core->executable_for_core = NULL; in dwfl_core_file_report()
467 if (dwfl->user_core == NULL) in dwfl_core_file_report()
470 dwfl->user_core = calloc (1, sizeof (struct Dwfl_User_Core)); in dwfl_core_file_report()
471 if (dwfl->user_core == NULL) in dwfl_core_file_report()
474 return -1; in dwfl_core_file_report()
476 dwfl->user_core->fd = -1; in dwfl_core_file_report()
478 dwfl->user_core->executable_for_core = strdup (executable); in dwfl_core_file_report()
479 if (dwfl->user_core->executable_for_core == NULL) in dwfl_core_file_report()
483 free (dwfl->user_core); in dwfl_core_file_report()
484 dwfl->user_core = NULL; in dwfl_core_file_report()
487 return -1; in dwfl_core_file_report()
498 free (dwfl->user_core->executable_for_core); in dwfl_core_file_report()
499 free (dwfl->user_core); in dwfl_core_file_report()
500 dwfl->user_core = NULL; in dwfl_core_file_report()
513 /* PT_NOTE -> NT_AUXV -> AT_PHDR -> PT_DYNAMIC -> DT_DEBUG */ in dwfl_core_file_report()
530 && !memcmp (notes->d_buf + name_pos, "CORE", sizeof "CORE")) in dwfl_core_file_report()
534 auxv = notes->d_buf + desc_pos; in dwfl_core_file_report()
539 note_file = notes->d_buf + desc_pos; in dwfl_core_file_report()
565 elf->maximum_size, in dwfl_core_file_report()
586 Dwfl_Module **lastmodp = &dwfl->modulelist; in dwfl_core_file_report()
588 lastmodp = &(*lastmodp)->next; in dwfl_core_file_report()
589 for (struct r_debug_info_module *module = r_debug_info.module; in dwfl_core_file_report() local
590 module != NULL; module = module->next) in dwfl_core_file_report()
592 if (module->elf == NULL) in dwfl_core_file_report()
595 if (! __libdwfl_dynamic_vaddr_get (module->elf, &file_dynamic_vaddr)) in dwfl_core_file_report()
598 mod = __libdwfl_report_elf (dwfl, basename (module->name), module->name, in dwfl_core_file_report()
599 module->fd, module->elf, in dwfl_core_file_report()
600 module->l_ld - file_dynamic_vaddr, in dwfl_core_file_report()
605 module->elf = NULL; in dwfl_core_file_report()
606 module->fd = -1; in dwfl_core_file_report()
607 /* Move this module to the end of the list, so that we end in dwfl_core_file_report()
609 if (mod->next != NULL) in dwfl_core_file_report()
613 lastmodp = &dwfl->modulelist; in dwfl_core_file_report()
615 lastmodp = &(*lastmodp)->next; in dwfl_core_file_report()
617 *lastmodp = mod->next; in dwfl_core_file_report()
618 mod->next = NULL; in dwfl_core_file_report()
620 lastmodp = &(*lastmodp)->next; in dwfl_core_file_report()
623 lastmodp = &mod->next; in dwfl_core_file_report()
629 If we found none, we return -1 instead of 0 if there was an in dwfl_core_file_report()