Lines Matching refs:elf
334 * Load a dynamic ELF binary into memory. Layout of the memory:
336 * | ELF HEADER | SECT HEADERS | KERN SECTS | REL/RELA/SYM/STR SECTS |
338 * The ELF HEADER start address is marks[MARK_END]. We then map the rest
342 * address of the ELF HEADER. We just give the kernel a pointer to the ELF
347 ELFNAMEEND(loadfile_dynamic)(int fd, Elf_Ehdr *elf, u_long *marks, int flags)
359 internalize_ehdr(elf->e_ident[EI_DATA], elf);
361 if (elf->e_type != ET_REL) {
367 shdrsz = elf->e_shnum * sizeof(Elf_Shdr);
369 ret = ELFNAMEEND(readfile_local)(fd, elf->e_shoff, shdr, shdrsz);
375 * Load the ELF HEADER. Update the section offset, to be relative to
378 elf->e_phoff = 0;
379 elf->e_shoff = sizeof(Elf_Ehdr);
380 elf->e_phentsize = 0;
381 elf->e_phnum = 0;
383 externalize_ehdr(elf->e_ident[EI_DATA], elf);
384 BCOPY(elf, elfp, sizeof(*elf));
385 internalize_ehdr(elf->e_ident[EI_DATA], elf);
389 for (i = 0; i < elf->e_shnum; i++)
390 internalize_shdr(elf->e_ident[EI_DATA], &shdr[i]);
401 for (i = 0; i < elf->e_shnum; i++) {
444 for (i = 0; i < elf->e_shnum; i++) {
450 for (j = 0; j < elf->e_shnum; j++)
454 if (elf->e_shstrndx == i)
482 for (i = 0; i < elf->e_shnum; i++)
483 externalize_shdr(elf->e_ident[EI_DATA], &shdr[i]);
507 ELFNAMEEND(loadsym)(int fd, Elf_Ehdr *elf, Elf_Addr maxp, Elf_Addr elfp,
525 sz = elf->e_shnum * sizeof(Elf_Shdr);
527 ret = ELFNAMEEND(readfile_local)(fd, elf->e_shoff, shp, sz);
536 for (i = 0; i < elf->e_shnum; i++)
537 internalize_shdr(elf->e_ident[EI_DATA], &shp[i]);
543 if (boot_load_ctf && (elf->e_shstrndx != SHN_UNDEF)) {
544 Elf_Off shstroff = shp[elf->e_shstrndx].sh_offset;
545 shstrsz = shp[elf->e_shstrndx].sh_size;
560 shp[elf->e_shstrndx].sh_offset = maxp - elfp;
571 for (i = 1; i < elf->e_shnum; i++) {
572 if (i == elf->e_shstrndx) {
590 for (j = 1; j < elf->e_shnum; j++)
646 for (i = 0; i < elf->e_shnum; i++)
647 externalize_shdr(elf->e_ident[EI_DATA], &shp[i]);
671 * Load a static ELF binary into memory. Layout of the memory:
673 * | KERNEL SEGMENTS | ELF HEADER | SECTION HEADERS | SYMBOL SECTIONS |
679 * ELF HEADER. The shdr offset of ELF HEADER points to SECTION HEADERS.
681 * We just give the kernel a pointer to the ELF HEADER, which is enough for it
685 ELFNAMEEND(loadfile_static)(int fd, Elf_Ehdr *elf, u_long *marks, int flags)
700 internalize_ehdr(elf->e_ident[EI_DATA], elf);
702 if (elf->e_type != ET_EXEC) {
707 sz = elf->e_phnum * sizeof(Elf_Phdr);
709 ret = ELFNAMEEND(readfile_local)(fd, elf->e_phoff, phdr, sz);
715 for (i = 0; i < elf->e_phnum; i++) {
716 internalize_phdr(elf->e_ident[EI_DATA], &phdr[i]);
776 * Load the ELF HEADER, SECTION HEADERS and possibly the SYMBOL
784 if (ELFNAMEEND(loadsym)(fd, elf, maxp, elfp, marks, flags,
791 * Update the ELF HEADER to give information relative to elfp.
794 elf->e_phoff = 0;
795 elf->e_shoff = sizeof(Elf_Ehdr);
796 elf->e_phentsize = 0;
797 elf->e_phnum = 0;
798 externalize_ehdr(elf->e_ident[EI_DATA], elf);
799 BCOPY(elf, elfp, sizeof(*elf));
800 internalize_ehdr(elf->e_ident[EI_DATA], elf);
804 marks[MARK_ENTRY] = LOADADDR(elf->e_entry);
818 ELFNAMEEND(loadfile)(int fd, Elf_Ehdr *elf, u_long *marks, int flags)
821 return ELFNAMEEND(loadfile_dynamic)(fd, elf, marks, flags);
823 return ELFNAMEEND(loadfile_static)(fd, elf, marks, flags);