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
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]
24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 #pragma ident "%Z%%M% %I% %E% SMI"
33 * look up an address in a sorted-by-address namelist
34 * this deals with misses by mapping them to the next lower
37 static int searchmsg
= 0; /* Emit the diagnostic only once */
40 nllookup(mod_info_t
*module
, pctype address
, pctype
*nxtsym
)
42 size_t low
= 0, middle
, high
= module
->nname
- 1;
44 nltype
*mnl
= module
->nl
;
47 * If this is the program executable in which we are looking up
48 * a symbol, then the actual load address will be the same as the
49 * address specified in the ELF file. For shared objects, the
50 * load address may differ from what is specified in the file. In
51 * this case, we may need to look for a different value altogether.
53 keyval
= module
->txt_origin
+ (address
- module
->load_base
);
55 if (keyval
< mnl
[low
].value
) {
57 *nxtsym
= module
->load_base
+
58 (mnl
[low
].value
- module
->txt_origin
);
63 if (keyval
>= mnl
[high
].value
) {
65 *nxtsym
= module
->load_end
;
70 middle
= (high
+ low
) >> 1;
72 if (mnl
[middle
].value
<= keyval
&&
73 mnl
[middle
+ 1].value
> keyval
) {
75 *nxtsym
= module
->load_base
+
76 (mnl
[middle
+ 1].value
-
79 return (&mnl
[middle
]);
82 if (mnl
[middle
].value
> keyval
) {
90 (void) fprintf(stderr
, "[nllookup] binary search fails???\n");
92 /* must never reach here! */
97 arclookup(nltype
*parentp
, nltype
*childp
)
101 if (parentp
== 0 || childp
== 0) {
102 (void) fprintf(stderr
,
103 "[arclookup] parentp == 0 || childp == 0\n");
107 if (debug
& LOOKUPDEBUG
) {
108 (void) printf("[arclookup] parent %s child %s\n",
109 parentp
->name
, childp
->name
);
113 for (arcp
= parentp
->children
; arcp
; arcp
= arcp
->arc_childlist
) {
115 if (debug
& LOOKUPDEBUG
) {
117 "[arclookup]\t arc_parent %s arc_child %s\n",
118 arcp
->arc_parentp
->name
,
119 arcp
->arc_childp
->name
);
122 if (arcp
->arc_childp
== childp
) {