4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
48 if (--elf
->ed_activ
!= 0) {
54 while (elf
->ed_activ
== 0) {
55 for (s
= elf
->ed_hdscn
; s
!= 0; s
= s
->s_next
) {
56 if (s
->s_myflags
& SF_ALLOC
) {
59 trail
= (Elf_Void
*)s
;
62 if ((s
->s_myflags
& SF_READY
) == 0)
64 for (d
= s
->s_hdnode
; d
!= 0; ) {
69 if ((t
= d
->db_raw
) != 0) {
72 if (t
->db_myflags
& DBF_ALLOC
)
76 if (d
->db_myflags
& DBF_ALLOC
)
90 for (l
= elf
->ed_memlist
; l
; l
= (Memlist
*)trail
) {
91 trail
= (Elf_Void
*)l
->m_next
;
92 for (i
= (Memident
*)(l
+ 1); i
< l
->m_free
;
98 if (elf
->ed_myflags
& EDF_EHALLOC
)
100 if (elf
->ed_myflags
& EDF_PHALLOC
)
102 if (elf
->ed_myflags
& EDF_SHALLOC
)
104 if (elf
->ed_myflags
& EDF_RAWALLOC
)
106 if (elf
->ed_myflags
& EDF_ASALLOC
)
108 if (elf
->ed_myflags
& EDF_ASTRALLOC
)
112 * Don't release the image until the last reference dies.
113 * If the image was introduced via elf_memory() then
114 * we don't release it at all, it's not ours to release.
117 if (elf
->ed_parent
== 0) {
120 else if ((elf
->ed_myflags
& EDF_MEMORY
) == 0)
121 _elf_unmap(elf
->ed_image
, elf
->ed_imagesz
);
123 trail
= (Elf_Void
*)elf
;
124 elf
= elf
->ed_parent
;
130 * If parent is inactive we close
131 * it too, so we need to lock it too.