1 /*
2 * CDDL HEADER START
3 *
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.
8 *
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.
13 *
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]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * krtld link maps
29 */
30
31 #include <sys/kobj.h>
32 #include <sys/kobj_impl.h>
33 #include <sys/modctl.h>
34 #include <sys/types.h>
35
36 #pragma weak primaries = kobj_linkmaps /* backwards compatibility */
37 struct modctl_list *kobj_linkmaps[] = {
38 NULL,
39 NULL,
40 NULL
41 };
42
43 #define KOBJ_LM_NENT (sizeof (kobj_linkmaps) / sizeof (struct modctl *) - 1)
44
45 struct modctl_list *
kobj_lm_lookup(int lmid)46 kobj_lm_lookup(int lmid)
47 {
48 if (lmid < 0 || lmid >= KOBJ_LM_NENT)
49 return (NULL);
50
51 return (kobj_linkmaps[lmid]);
52 }
53
54 void
kobj_lm_append(int lmid,struct modctl * modp)55 kobj_lm_append(int lmid, struct modctl *modp)
56 {
57 struct modctl_list **lpp, *lp;
58
59 if (lmid < 0 || lmid >= KOBJ_LM_NENT)
60 return;
61
62 lpp = &kobj_linkmaps[lmid];
63
64 lp = kobj_zalloc(sizeof (struct modctl_list), KM_WAIT);
65 lp->modl_modp = modp;
66
67 if (*lpp == NULL) {
68 *lpp = lp;
69 } else {
70 struct modctl_list *last;
71
72 for (last = *lpp; last->modl_next != NULL;
73 last = last->modl_next)
74 /* */;
75
76 last->modl_next = lp;
77 }
78 }
79
80 void
kobj_lm_dump(int lmid)81 kobj_lm_dump(int lmid)
82 {
83 struct modctl_list *lp;
84
85 for (lp = kobj_lm_lookup(lmid); lp; lp = lp->modl_next) {
86 struct module *mp = lp->modl_modp->mod_mp;
87
88 _kobj_printf(ops, "module %s: ", mp->filename);
89 _kobj_printf(ops, "text at [0x%p, ", mp->text);
90 _kobj_printf(ops, "0x%lx] ", (uintptr_t)mp->text +
91 mp->text_size - 1);
92 _kobj_printf(ops, "data at 0x%p\n", mp->data);
93 }
94 }
95