Lines Matching refs:elf

42 write_file (Elf *elf, int64_t size, int change_bo, size_t shnum)
44 int class = elf->class;
48 if (unlikely (fstat (elf->fildes, &st) != 0))
59 if (elf->parent == NULL
60 && (elf->maximum_size == ~((size_t) 0)
61 || (size_t) size > elf->maximum_size)
62 && unlikely (ftruncate (elf->fildes, size) != 0))
69 if (elf->map_address == NULL && elf->cmd == ELF_C_WRITE_MMAP)
71 elf->map_address = mmap (NULL, size, PROT_READ | PROT_WRITE,
72 MAP_SHARED, elf->fildes, 0);
73 if (unlikely (elf->map_address == MAP_FAILED))
74 elf->map_address = NULL;
76 elf->flags |= ELF_F_MMAPPED;
79 if (elf->map_address != NULL)
92 if (elf->parent == NULL
93 && (elf->maximum_size == ~((size_t) 0)
94 || (size_t) size > elf->maximum_size))
96 if (unlikely (posix_fallocate (elf->fildes, 0, size) != 0))
104 if (elf->cmd == ELF_C_RDWR_MMAP
105 && (size_t) size > elf->maximum_size)
108 if (mremap (elf->map_address, elf->maximum_size,
115 elf->maximum_size = size;
122 ? __elf32_updatemmap (elf, change_bo, shnum)
123 : __elf64_updatemmap (elf, change_bo, shnum)) != 0)
131 ? __elf32_updatefile (elf, change_bo, shnum)
132 : __elf64_updatefile (elf, change_bo, shnum)) != 0)
139 && elf->parent == NULL
140 && elf->maximum_size != ~((size_t) 0)
141 && (size_t) size < elf->maximum_size
142 && unlikely (ftruncate (elf->fildes, size) != 0))
154 && unlikely (fchmod (elf->fildes, st.st_mode) != 0))
160 if (size != -1 && elf->parent == NULL)
161 elf->maximum_size = size;
168 elf_update (Elf *elf, Elf_Cmd cmd)
182 if (elf == NULL)
185 if (elf->kind != ELF_K_ELF)
191 rwlock_wrlock (elf->lock);
194 if (elf->state.elf.ehdr == NULL)
202 shnum = (elf->state.elf.scns_last->cnt == 0
204 : 1 + elf->state.elf.scns_last->data[elf->state.elf.scns_last->cnt - 1].index);
209 size = (elf->class == ELFCLASS32
210 ? __elf32_updatenull_wrlock (elf, &change_bo, shnum)
211 : __elf64_updatenull_wrlock (elf, &change_bo, shnum));
216 if (elf->cmd != ELF_C_RDWR
217 && elf->cmd != ELF_C_RDWR_MMAP
218 && elf->cmd != ELF_C_WRITE
219 && unlikely (elf->cmd != ELF_C_WRITE_MMAP))
224 else if (unlikely (elf->fildes == -1))
231 size = write_file (elf, size, change_bo, shnum);
235 rwlock_unlock (elf->lock);