plt64_resolution.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <proc_service.h>
#include <link.h>
#include <rtld_db.h>
#include <_rtld_db.h>
#include <msg.h>
/*
* A un-initialized SPARCV9 PLT look like so:
*
* .PLT
* sethi (. - .PLT0), %g1
* ba,a %xcc, .PLT1
* nop
* nop
* nop
* nop
* nop
* nop
*
* To test to see if this is an uninitialized PLT we check
* the second instruction and confirm that it's a branch.
*/
/* ARGSUSED 2 */
{
int pltbound = 0;
if (rtld_db_version >= RD_VERSION3) {
}
/*
* Handle far PLT's
*
* .PLT#
* 0 mov %o7, %g5
* 1 call . + 8
* 2 nop
* 3 ldx [%o7 + (.PLTP# - .PLT#+4)], %g1
* 4 jmpl %o7 + %g1, %g1
* 5 mov %g5, %o7
*/
M64_PLT_FENTSIZE) != PS_OK) {
return (RD_ERR);
}
if (instr[0] != M_MOVO7TOG5) {
return (RD_ERR);
}
/*
* the offset is a positive displacement from the
* ldx [%o7 + #], %g1 instruction. So - we don't
* need to worry about the sign bit :)
*/
/*
* Load the pltptr to determine whether it is
* pointing to .PLT0 or to the final
* destination.
*/
sizeof (long long)) != PS_OK) {
return (RD_ERR);
}
return (rerr);
}
} else {
if (rtld_db_version >= RD_VERSION3) {
pltbound++;
}
}
} else {
M64_PLT_ENTSIZE) != PS_OK) {
return (RD_ERR);
}
/*
* ELF64 NEAR PLT's
*/
/*
* Unbound PLT
*/
return (rerr);
}
/*
* Resolved 64-bit PLT entry format (b+-8mb):
* .PLT
* 0 nop
* 1 ba,a <dest>
* 2 nop
* 3 nop
* 4 nop
* 5 nop
* 6 nop
* 7 nop
*/
if (rtld_db_version >= RD_VERSION3) {
/* LINTED */
/* LINTED */
pltbound++;
}
/*
* Resolved 64-bit PLT entry format (b+-2mb):
* .PLT
* 0 nop
* 1 ba,a,pt %icc, <dest>
* 2 nop
* 3 nop
* 4 nop
* 5 nop
* 6 nop
* 7 nop
*/
if (rtld_db_version >= RD_VERSION3) {
/* LINTED */
/* LINTED */
pltbound++;
}
/*
* Resolved 64-bit PLT entry format (abs-64):
* .PLT
* 0 nop
* 1 sethi %hh(dest), %g1
* 2 sethi %lm(dest), %g5
* 3 or %g1, %hm(dest), %g1
* 4 sllx %g1, 32, %g1
* 5 or %g1, %g5, %g5
* 6 jmpl %g5 + %lo(dest), %g0
* 7 nop
*/
if (rtld_db_version >= RD_VERSION3) {
pltbound++;
}
/*
* Resolved 64-bit PLT entry format (top-32):
*
* .PLT:
* 0 nop
* 1 sethi %hi(~dest), %g5
* 2 xnor %g5, %lo(~dest), %g1
* 3 jmpl %g1, %g0
* 4 nop
* 5 nop
* 6 nop
* 7 nop
*/
if (rtld_db_version >= RD_VERSION3) {
pltbound++;
}
/*
* Resolved 64-bit PLT entry format (top-44):
*
* .PLT:
* 0 nop
* 1 sethi %h44(~dest), %g5
* 2 xnor %g5, %m44(~dest), %g1
* 3 slxx %g1, 12, %g1
* 4 jmpl %g1 + %l44(dest), %g0
* 5 nop
* 6 nop
* 7 nop
*/
if (rtld_db_version >= RD_VERSION3) {
<< 10);
<< 41) >> 41;
<< 41) >> 41;
+ l44_bits;
pltbound++;
}
} else
}
}
return (RD_OK);
}