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]
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 #include <proc_service.h>
38 * A un-initialized PLT look like so:
41 * sethi (.-.PLT0), %g1
45 * To test to see if this is an uninitialized PLT we check
46 * the second instruction and confirm that it's a branch.
50 plt32_resolution(rd_agent_t
*rap
, psaddr_t pc
, lwpid_t lwpid
,
51 psaddr_t pltbase
, rd_plt_info_t
*rpi
)
53 unsigned int instr
[4];
55 psaddr_t destaddr
= 0;
56 psaddr_t pltoff
, pltaddr
;
59 pltoff
= pc
- pltbase
;
61 ((pltoff
/ M32_PLT_ENTSIZE
) * M32_PLT_ENTSIZE
);
63 if (ps_pread(rap
->rd_psp
, pltaddr
, (char *)instr
,
64 M32_PLT_ENTSIZE
) != PS_OK
) {
65 LOG(ps_plog(MSG_ORIG(MSG_DB_READFAIL_2
), EC_ADDR(pltaddr
)));
69 if (rtld_db_version
>= RD_VERSION3
) {
74 if ((instr
[0] != M_NOP
) &&
75 ((instr
[1] & (~(S_MASK(22)))) == M_BA_A
)) {
79 if ((rerr
= rd_binder_exit_addr(rap
, MSG_ORIG(MSG_SYM_RTBIND
),
80 &(rpi
->pi_target
))) != RD_OK
) {
83 rpi
->pi_skip_method
= RD_RESOLVE_TARGET_STEP
;
85 } else if ((instr
[2] & (~(S_MASK(13)))) == M_JMPL
) {
87 * Resolved 32-bit PLT entry format (full-32):
90 * 0 sethi (.-PLT0), %g1
91 * 1 sethi %hi(dest), %g1
92 * 2 jmpl %g1 + lo(dest), %g0
95 rpi
->pi_skip_method
= RD_RESOLVE_STEP
;
98 if (rtld_db_version
>= RD_VERSION3
) {
101 hi_bits
= instr
[1] & S_MASK(22); /* 31..10 */
102 lo_bits
= instr
[2] & S_MASK(10); /* 09..00 */
103 destaddr
= (hi_bits
<< 10) | lo_bits
;
106 } else if ((instr
[0] == M_NOP
) &&
107 ((instr
[1] & (~(S_MASK(22)))) == M_BA_A
)) {
109 * Resolved 32-bit PLT entry format (b+-8mb):
116 rpi
->pi_skip_method
= RD_RESOLVE_STEP
;
119 if (rtld_db_version
>= RD_VERSION3
) {
121 d22
= instr
[1] & S_MASK(22);
122 destaddr
= ((int)pltaddr
+ 4) +
123 (((int)d22
<< 10) >> 8);
126 } else if ((instr
[0] == M_NOP
) &&
127 ((instr
[1] & (~(S_MASK(19)))) == M_BA_A_PT
)) {
129 * Resolved 32-bit PLT entry format (b+-2mb):
132 * 1 ba,a,pt %icc, <dest>
136 rpi
->pi_skip_method
= RD_RESOLVE_STEP
;
139 if (rtld_db_version
>= RD_VERSION3
) {
141 d19
= instr
[1] & S_MASK(22);
142 destaddr
= ((int)pltaddr
+ 4) +
143 (((int)d19
<< 13) >> 11);
147 rpi
->pi_skip_method
= RD_RESOLVE_NONE
;
149 if ((rtld_db_version
>= RD_VERSION3
) && pltbound
) {
150 rpi
->pi_flags
|= RD_FLG_PI_PLTBOUND
;
151 rpi
->pi_baddr
= destaddr
;