Lines Matching full:elf
1 /* Free resources associated with Elf descriptor.
42 elf_end (Elf *elf) in elf_end() argument
44 Elf *parent; in elf_end()
46 if (elf == NULL) in elf_end()
51 rwlock_wrlock (elf->lock); in elf_end()
53 if (elf->ref_count != 0 && --elf->ref_count != 0) in elf_end()
56 int result = elf->ref_count; in elf_end()
57 rwlock_unlock (elf->lock); in elf_end()
61 if (elf->kind == ELF_K_AR) in elf_end()
65 symbol table since this is only available via the archive ELF in elf_end()
67 the archive headers for the ELF files in the archive point in elf_end()
69 if (elf->state.ar.ar_sym != (Elf_Arsym *) -1l) in elf_end()
70 free (elf->state.ar.ar_sym); in elf_end()
71 elf->state.ar.ar_sym = NULL; in elf_end()
73 if (elf->state.ar.children != NULL) in elf_end()
78 parent = elf->parent; in elf_end()
86 rwlock_unlock (elf->lock); in elf_end()
88 rwlock_wrlock (elf->lock); in elf_end()
90 if (parent->state.ar.children == elf) in elf_end()
91 parent->state.ar.children = elf->next; in elf_end()
94 struct Elf *child = parent->state.ar.children; in elf_end()
96 while (child->next != elf) in elf_end()
99 child->next = elf->next; in elf_end()
106 switch (elf->kind) in elf_end()
109 if (elf->state.ar.long_names != NULL) in elf_end()
110 free (elf->state.ar.long_names); in elf_end()
116 = (elf->class == ELFCLASS32 in elf_end()
117 || (offsetof (struct Elf, state.elf32.rawchunks) in elf_end()
118 == offsetof (struct Elf, state.elf64.rawchunks)) in elf_end()
119 ? elf->state.elf32.rawchunks in elf_end()
120 : elf->state.elf64.rawchunks); in elf_end()
130 Elf_ScnList *list = (elf->class == ELFCLASS32 in elf_end()
131 || (offsetof (struct Elf, state.elf32.scns) in elf_end()
132 == offsetof (struct Elf, state.elf64.scns)) in elf_end()
133 ? &elf->state.elf32.scns in elf_end()
134 : &elf->state.elf64.scns); in elf_end()
167 if (elf->map_address == NULL in elf_end()
189 if (oldp != (elf->class == ELFCLASS32 in elf_end()
190 || (offsetof (struct Elf, state.elf32.scns) in elf_end()
191 == offsetof (struct Elf, state.elf64.scns)) in elf_end()
192 ? &elf->state.elf32.scns in elf_end()
193 : &elf->state.elf64.scns)) in elf_end()
200 if (elf->state.elf.shdr_malloced != 0) in elf_end()
201 free (elf->class == ELFCLASS32 in elf_end()
202 || (offsetof (struct Elf, state.elf32.shdr) in elf_end()
203 == offsetof (struct Elf, state.elf64.shdr)) in elf_end()
204 ? (void *) elf->state.elf32.shdr in elf_end()
205 : (void *) elf->state.elf64.shdr); in elf_end()
208 if ((elf->state.elf.phdr_flags & ELF_F_MALLOCED) != 0) in elf_end()
209 free (elf->class == ELFCLASS32 in elf_end()
210 || (offsetof (struct Elf, state.elf32.phdr) in elf_end()
211 == offsetof (struct Elf, state.elf64.phdr)) in elf_end()
212 ? (void *) elf->state.elf32.phdr in elf_end()
213 : (void *) elf->state.elf64.phdr); in elf_end()
220 if (elf->map_address != NULL && parent == NULL) in elf_end()
223 if ((elf->flags & ELF_F_MALLOCED) != 0) in elf_end()
224 free (elf->map_address); in elf_end()
225 else if ((elf->flags & ELF_F_MMAPPED) != 0) in elf_end()
226 munmap (elf->map_address, elf->maximum_size); in elf_end()
229 rwlock_unlock (elf->lock); in elf_end()
230 rwlock_fini (elf->lock); in elf_end()
233 free (elf); in elf_end()