Lines Matching refs:phdr
185 static bool elf_is_phdr_sane(const struct elf_phdr *phdr, size_t buf_len) in elf_is_phdr_sane() argument
188 if (phdr->p_offset + phdr->p_filesz < phdr->p_offset) { in elf_is_phdr_sane()
191 } else if (phdr->p_offset + phdr->p_filesz > buf_len) { in elf_is_phdr_sane()
194 } else if (phdr->p_paddr + phdr->p_memsz < phdr->p_paddr) { in elf_is_phdr_sane()
207 struct elf_phdr *phdr = (struct elf_phdr *) &elf_info->proghdrs[idx]; in elf_read_phdr() local
215 phdr->p_type = elf32_to_cpu(elf_info->ehdr, buf_phdr->p_type); in elf_read_phdr()
216 phdr->p_flags = elf32_to_cpu(elf_info->ehdr, buf_phdr->p_flags); in elf_read_phdr()
220 phdr->p_offset = elf64_to_cpu(ehdr, buf_phdr->p_offset); in elf_read_phdr()
221 phdr->p_paddr = elf64_to_cpu(ehdr, buf_phdr->p_paddr); in elf_read_phdr()
222 phdr->p_vaddr = elf64_to_cpu(ehdr, buf_phdr->p_vaddr); in elf_read_phdr()
223 phdr->p_filesz = elf64_to_cpu(ehdr, buf_phdr->p_filesz); in elf_read_phdr()
224 phdr->p_memsz = elf64_to_cpu(ehdr, buf_phdr->p_memsz); in elf_read_phdr()
225 phdr->p_align = elf64_to_cpu(ehdr, buf_phdr->p_align); in elf_read_phdr()
229 phdr->p_offset = elf32_to_cpu(ehdr, buf_phdr->p_offset); in elf_read_phdr()
230 phdr->p_paddr = elf32_to_cpu(ehdr, buf_phdr->p_paddr); in elf_read_phdr()
231 phdr->p_vaddr = elf32_to_cpu(ehdr, buf_phdr->p_vaddr); in elf_read_phdr()
232 phdr->p_filesz = elf32_to_cpu(ehdr, buf_phdr->p_filesz); in elf_read_phdr()
233 phdr->p_memsz = elf32_to_cpu(ehdr, buf_phdr->p_memsz); in elf_read_phdr()
234 phdr->p_align = elf32_to_cpu(ehdr, buf_phdr->p_align); in elf_read_phdr()
242 return elf_is_phdr_sane(phdr, len) ? 0 : -ENOEXEC; in elf_read_phdr()
401 const struct elf_phdr *phdr; in kexec_elf_load() local
403 phdr = &elf_info->proghdrs[i]; in kexec_elf_load()
404 if (phdr->p_type != PT_LOAD) in kexec_elf_load()
407 size = phdr->p_filesz; in kexec_elf_load()
408 if (size > phdr->p_memsz) in kexec_elf_load()
409 size = phdr->p_memsz; in kexec_elf_load()
411 kbuf->buffer = (void *) elf_info->buffer + phdr->p_offset; in kexec_elf_load()
413 kbuf->memsz = phdr->p_memsz; in kexec_elf_load()
414 kbuf->buf_align = phdr->p_align; in kexec_elf_load()
415 kbuf->buf_min = phdr->p_paddr; in kexec_elf_load()