Lines Matching full:elf
106 __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum) in __elfw2()
110 /* We need the ELF header several times. */ in __elfw2()
111 ElfW2(LIBELFBITS,Ehdr) *ehdr = elf->state.ELFW(elf,LIBELFBITS).ehdr; in __elfw2()
113 /* Write out the ELF header. */ in __elfw2()
114 if ((elf->state.ELFW(elf,LIBELFBITS).ehdr_flags | elf->flags) & ELF_F_DIRTY) in __elfw2()
123 /* Today there is only one version of the ELF header. */ in __elfw2()
133 (*fctp) ((char *) elf->map_address + elf->start_offset, ehdr, in __elfw2()
136 else if (elf->map_address + elf->start_offset != ehdr) in __elfw2()
137 memcpy (elf->map_address + elf->start_offset, ehdr, in __elfw2()
140 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags &= ~ELF_F_DIRTY; in __elfw2()
142 /* We start writing sections after the ELF header only if there is in __elfw2()
144 previous_scn_changed = elf->state.ELFW(elf,LIBELFBITS).phdr == NULL; in __elfw2()
148 if (unlikely (__elf_getphdrnum_rdlock (elf, &phnum) != 0)) in __elfw2()
152 if (elf->state.ELFW(elf,LIBELFBITS).phdr != NULL in __elfw2()
153 && ((elf->state.ELFW(elf,LIBELFBITS).phdr_flags | elf->flags) in __elfw2()
161 /* Maybe the user wants a gap between the ELF header and the program in __elfw2()
164 memset (elf->map_address + elf->start_offset + ehdr->e_ehsize, in __elfw2()
169 /* Today there is only one version of the ELF header. */ in __elfw2()
179 (*fctp) (elf->map_address + elf->start_offset + ehdr->e_phoff, in __elfw2()
180 elf->state.ELFW(elf,LIBELFBITS).phdr, in __elfw2()
184 memcpy (elf->map_address + elf->start_offset + ehdr->e_phoff, in __elfw2()
185 elf->state.ELFW(elf,LIBELFBITS).phdr, in __elfw2()
188 elf->state.ELFW(elf,LIBELFBITS).phdr_flags &= ~ELF_F_DIRTY; in __elfw2()
197 char *last_position = ((char *) elf->map_address + elf->start_offset in __elfw2()
208 Elf_ScnList *list = &elf->state.ELFW(elf,LIBELFBITS).scns; in __elfw2()
210 char *const shdr_start = ((char *) elf->map_address + elf->start_offset in __elfw2()
231 if (!elf->state.ELFW(elf,LIBELFBITS).shdr_malloced in __elfw2()
235 assert ((char *) elf->map_address + elf->start_offset in __elfw2()
238 < ((char *) elf->map_address + elf->start_offset in __elfw2()
239 + elf->maximum_size)); in __elfw2()
253 if (((char *) elf->map_address + elf->start_offset in __elfw2()
256 < ((char *) elf->map_address + elf->start_offset in __elfw2()
257 + elf->maximum_size)) in __elfw2()
258 && (((char *) elf->map_address + elf->start_offset in __elfw2()
291 char *scn_start = ((char *) elf->map_address in __elfw2()
292 + elf->start_offset + shdr->sh_offset); in __elfw2()
328 || ((scn->flags | dl->flags | elf->flags) in __elfw2()
335 if ((scn->flags | dl->flags | elf->flags) & ELF_F_DIRTY) in __elfw2()
380 /* If the previous section (or the ELF/program in __elfw2()
397 if ((elf->flags & ELF_F_DIRTY) in __elfw2()
398 && last_position < ((char *) elf->map_address + elf->start_offset in __elfw2()
401 (char *) elf->map_address + elf->start_offset + ehdr->e_shoff in __elfw2()
409 if ((scn->shdr_flags | elf->flags) & ELF_F_DIRTY) in __elfw2()
423 if (!elf->state.ELFW(elf,LIBELFBITS).shdr_malloced in __elfw2()
433 elf->flags &= ~ELF_F_DIRTY; in __elfw2()
436 char *msync_start = ((char *) elf->map_address in __elfw2()
437 + (elf->start_offset & ~(sysconf (_SC_PAGESIZE) - 1))); in __elfw2()
438 char *msync_end = ((char *) elf->map_address in __elfw2()
439 + elf->start_offset + ehdr->e_shoff in __elfw2()
492 __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum) in __elfw2()
498 /* We need the ELF header several times. */ in __elfw2()
499 ElfW2(LIBELFBITS,Ehdr) *ehdr = elf->state.ELFW(elf,LIBELFBITS).ehdr; in __elfw2()
501 /* Write out the ELF header. */ in __elfw2()
502 if ((elf->state.ELFW(elf,LIBELFBITS).ehdr_flags | elf->flags) & ELF_F_DIRTY) in __elfw2()
514 /* Today there is only one version of the ELF header. */ in __elfw2()
523 /* Write the converted ELF header in a temporary buffer. */ in __elfw2()
530 /* Write out the ELF header. */ in __elfw2()
531 if (unlikely (pwrite_retry (elf->fildes, out_ehdr, in __elfw2()
539 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags &= ~ELF_F_DIRTY; in __elfw2()
541 /* We start writing sections after the ELF header only if there is in __elfw2()
543 previous_scn_changed = elf->state.ELFW(elf,LIBELFBITS).phdr == NULL; in __elfw2()
552 if (unlikely (__elf_getphdrnum_rdlock (elf, &phnum) != 0)) in __elfw2()
556 if (elf->state.ELFW(elf,LIBELFBITS).phdr != NULL in __elfw2()
557 && ((elf->state.ELFW(elf,LIBELFBITS).phdr_flags | elf->flags) in __elfw2()
561 ElfW2(LIBELFBITS,Phdr) *out_phdr = elf->state.ELFW(elf,LIBELFBITS).phdr; in __elfw2()
563 /* Maybe the user wants a gap between the ELF header and the program in __elfw2()
566 && unlikely (fill (elf->fildes, ehdr->e_ehsize, in __elfw2()
573 /* Today there is only one version of the ELF header. */ in __elfw2()
591 /* Write the converted ELF header in a temporary buffer. */ in __elfw2()
592 (*fctp) (tmp_phdr, elf->state.ELFW(elf,LIBELFBITS).phdr, in __elfw2()
599 /* Write out the ELF header. */ in __elfw2()
601 if (unlikely ((size_t) pwrite_retry (elf->fildes, out_phdr, in __elfw2()
612 elf->state.ELFW(elf,LIBELFBITS).phdr_flags &= ~ELF_F_DIRTY; in __elfw2()
622 if (elf->state.ELFW(elf,LIBELFBITS).phdr == NULL) in __elfw2()
634 off_t shdr_offset = elf->start_offset + ehdr->e_shoff; in __elfw2()
643 if (change_bo || elf->state.ELFW(elf,LIBELFBITS).shdr == NULL in __elfw2()
644 || (elf->flags & ELF_F_DIRTY)) in __elfw2()
648 shdr_data = elf->state.ELFW(elf,LIBELFBITS).shdr; in __elfw2()
649 int shdr_flags = elf->flags; in __elfw2()
652 Elf_ScnList *list = &elf->state.ELFW(elf,LIBELFBITS).scns; in __elfw2()
671 off_t scn_start = elf->start_offset + shdr->sh_offset; in __elfw2()
681 || ((scn->flags | dl->flags | elf->flags) in __elfw2()
684 if (unlikely (fill (elf->fildes, last_offset, in __elfw2()
691 if ((scn->flags | dl->flags | elf->flags) & ELF_F_DIRTY) in __elfw2()
728 ssize_t n = pwrite_retry (elf->fildes, buf, in __elfw2()
755 /* If the previous section (or the ELF/program in __elfw2()
759 if (unlikely (fill (elf->fildes, last_offset, in __elfw2()
775 else if (elf->state.ELFW(elf,LIBELFBITS).shdr == NULL in __elfw2()
776 || (elf->flags & ELF_F_DIRTY)) in __elfw2()
786 if ((elf->flags & ELF_F_DIRTY) && last_offset < shdr_offset in __elfw2()
787 && unlikely (fill (elf->fildes, last_offset, in __elfw2()
794 && unlikely ((size_t) pwrite_retry (elf->fildes, shdr_data, in __elfw2()
805 elf->flags &= ~ELF_F_DIRTY; in __elfw2()