Lines Matching full:elf
1 /* Free resources associated with Elf descriptor.
43 elf_end (elf) in elf_end() argument
44 Elf *elf; in elf_end()
46 Elf *parent;
48 if (elf == NULL)
53 rwlock_wrlock (elf->lock);
55 if (elf->ref_count != 0 && --elf->ref_count != 0)
58 int result = elf->ref_count;
59 rwlock_unlock (elf->lock);
63 if (elf->kind == ELF_K_AR)
67 symbol table since this is only available via the archive ELF
69 the archive headers for the ELF files in the archive point
71 if (elf->state.ar.ar_sym != (Elf_Arsym *) -1l)
72 free (elf->state.ar.ar_sym);
73 elf->state.ar.ar_sym = NULL;
75 if (elf->state.ar.children != NULL)
80 parent = elf->parent;
88 rwlock_unlock (elf->lock);
90 rwlock_wrlock (elf->lock);
92 if (parent->state.ar.children == elf)
93 parent->state.ar.children = elf->next;
96 struct Elf *child = parent->state.ar.children;
98 while (child->next != elf)
101 child->next = elf->next;
108 switch (elf->kind)
111 if (elf->state.ar.long_names != NULL)
112 free (elf->state.ar.long_names);
118 = (elf->class == ELFCLASS32
119 || (offsetof (struct Elf, state.elf32.rawchunks)
120 == offsetof (struct Elf, state.elf64.rawchunks))
121 ? elf->state.elf32.rawchunks
122 : elf->state.elf64.rawchunks);
132 Elf_ScnList *list = (elf->class == ELFCLASS32
133 || (offsetof (struct Elf, state.elf32.scns)
134 == offsetof (struct Elf, state.elf64.scns))
135 ? &elf->state.elf32.scns
136 : &elf->state.elf64.scns);
163 if (elf->map_address == NULL)
183 if (oldp != (elf->class == ELFCLASS32
184 || (offsetof (struct Elf, state.elf32.scns)
185 == offsetof (struct Elf, state.elf64.scns))
186 ? &elf->state.elf32.scns
187 : &elf->state.elf64.scns))
194 if (elf->state.elf.shdr_malloced != 0)
195 free (elf->class == ELFCLASS32
196 || (offsetof (struct Elf, state.elf32.shdr)
197 == offsetof (struct Elf, state.elf64.shdr))
198 ? (void *) elf->state.elf32.shdr
199 : (void *) elf->state.elf64.shdr);
202 if ((elf->state.elf.phdr_flags & ELF_F_MALLOCED) != 0)
203 free (elf->class == ELFCLASS32
204 || (offsetof (struct Elf, state.elf32.phdr)
205 == offsetof (struct Elf, state.elf64.phdr))
206 ? (void *) elf->state.elf32.phdr
207 : (void *) elf->state.elf64.phdr);
214 if (elf->map_address != NULL && parent == NULL)
217 if ((elf->flags & ELF_F_MALLOCED) != 0)
218 free (elf->map_address);
219 else if ((elf->flags & ELF_F_MMAPPED) != 0)
220 munmap (elf->map_address, elf->maximum_size);
223 rwlock_unlock (elf->lock);
224 rwlock_fini (elf->lock);
227 free (elf);