Merge commit '44b94201113baeac54736e6ea488566d4a01ce48'
[unleashed.git] / kernel / krtld / kobj_lm.c
blob03f70f308c73505ae023be5715684299023b4acb
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * krtld link maps
33 #include <sys/kobj.h>
34 #include <sys/kobj_impl.h>
35 #include <sys/modctl.h>
36 #include <sys/types.h>
38 #pragma weak primaries = kobj_linkmaps /* backwards compatibility */
39 struct modctl_list *kobj_linkmaps[] = {
40 NULL,
41 NULL,
42 NULL
45 #define KOBJ_LM_NENT (sizeof (kobj_linkmaps) / sizeof (struct modctl *) - 1)
47 struct modctl_list *
48 kobj_lm_lookup(int lmid)
50 if (lmid < 0 || lmid >= KOBJ_LM_NENT)
51 return (NULL);
53 return (kobj_linkmaps[lmid]);
56 void
57 kobj_lm_append(int lmid, struct modctl *modp)
59 struct modctl_list **lpp, *lp;
61 if (lmid < 0 || lmid >= KOBJ_LM_NENT)
62 return;
64 lpp = &kobj_linkmaps[lmid];
66 lp = kobj_zalloc(sizeof (struct modctl_list), KM_WAIT);
67 lp->modl_modp = modp;
69 if (*lpp == NULL) {
70 *lpp = lp;
71 } else {
72 struct modctl_list *last;
74 for (last = *lpp; last->modl_next != NULL;
75 last = last->modl_next)
76 /* */;
78 last->modl_next = lp;
82 void
83 kobj_lm_dump(int lmid)
85 struct modctl_list *lp;
87 for (lp = kobj_lm_lookup(lmid); lp; lp = lp->modl_next) {
88 struct module *mp = lp->modl_modp->mod_mp;
90 _kobj_printf(ops, "module %s: ", mp->filename);
91 _kobj_printf(ops, "text at [0x%p, ", mp->text);
92 _kobj_printf(ops, "0x%lx] ", (uintptr_t)mp->text +
93 mp->text_size - 1);
94 _kobj_printf(ops, "data at 0x%p\n", mp->data);