Home | History | Annotate | Download | only in libelf

Lines Matching refs:elf

44 write_file (Elf *elf, off_t size, int change_bo, size_t shnum)
46 int class = elf->class;
50 if (unlikely (fstat (elf->fildes, &st) != 0))
61 if (elf->parent == NULL
62 && (elf->maximum_size == ~((size_t) 0)
63 || (size_t) size > elf->maximum_size)
64 && unlikely (ftruncate (elf->fildes, size) != 0))
71 if (elf->map_address == NULL && elf->cmd == ELF_C_WRITE_MMAP)
73 elf->map_address = mmap (NULL, size, PROT_READ | PROT_WRITE,
74 MAP_SHARED, elf->fildes, 0);
75 if (unlikely (elf->map_address == MAP_FAILED))
76 elf->map_address = NULL;
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)
95 && unlikely (posix_fallocate (elf->fildes, 0, size) != 0))
104 ? __elf32_updatemmap (elf, change_bo, shnum)
105 : __elf64_updatemmap (elf, change_bo, shnum)) != 0)
113 ? __elf32_updatefile (elf, change_bo, shnum)
114 : __elf64_updatefile (elf, change_bo, shnum)) != 0)
121 && elf->parent == NULL
122 && elf->maximum_size != ~((size_t) 0)
123 && (size_t) size < elf->maximum_size
124 && unlikely (ftruncate (elf->fildes, size) != 0))
136 && unlikely (fchmod (elf->fildes, st.st_mode) != 0))
142 if (size != -1 && elf->parent == NULL)
143 elf->maximum_size = size;
150 elf_update (Elf *elf, Elf_Cmd cmd)
164 if (elf == NULL)
167 if (elf->kind != ELF_K_ELF)
173 rwlock_wrlock (elf->lock);
175 /* Make sure we have an ELF header. */
176 if (elf->state.elf.ehdr == NULL)
184 shnum = (elf->state.elf.scns_last->cnt == 0
186 : 1 + elf->state.elf.scns_last->data[elf->state.elf.scns_last->cnt - 1].index);
188 /* Update the ELF descriptor. First, place the program header. It
189 will come right after the ELF header. The count the size of all
191 size = (elf->class == ELFCLASS32
192 ? __elf32_updatenull_wrlock (elf, &change_bo, shnum)
193 : __elf64_updatenull_wrlock (elf, &change_bo, shnum));
198 if (elf->cmd != ELF_C_RDWR
199 && elf->cmd != ELF_C_RDWR_MMAP
200 && elf->cmd != ELF_C_WRITE
201 && unlikely (elf->cmd != ELF_C_WRITE_MMAP))
206 else if (unlikely (elf->fildes == -1))
213 size = write_file (elf, size, change_bo, shnum);
217 rwlock_unlock (elf->lock);