rtld_start.S (100265) | rtld_start.S (107071) |
---|---|
1/* $NetBSD: rtld_start.S,v 1.5 2001/08/14 22:17:48 eeh Exp $ */ 2 3/*- 4 * Copyright (c) 2001 Jake Burkholder. 5 * Copyright (c) 2000 Eduardo Horvath. 6 * Copyright (c) 1999 The NetBSD Foundation, Inc. 7 * All rights reserved. 8 * --- 23 unchanged lines hidden (view full) --- 32 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 * POSSIBILITY OF SUCH DAMAGE. 39 * | 1/* $NetBSD: rtld_start.S,v 1.5 2001/08/14 22:17:48 eeh Exp $ */ 2 3/*- 4 * Copyright (c) 2001 Jake Burkholder. 5 * Copyright (c) 2000 Eduardo Horvath. 6 * Copyright (c) 1999 The NetBSD Foundation, Inc. 7 * All rights reserved. 8 * --- 23 unchanged lines hidden (view full) --- 32 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 * POSSIBILITY OF SUCH DAMAGE. 39 * |
40 * $FreeBSD: head/libexec/rtld-elf/sparc64/rtld_start.S 100265 2002-07-17 22:20:41Z jake $ | 40 * $FreeBSD: head/libexec/rtld-elf/sparc64/rtld_start.S 107071 2002-11-18 22:08:50Z tmm $ |
41 */ 42 43#include <machine/asm.h> 44 45/* 46 * ELF: 47 * On startup the stack should contain 16 extended word register save 48 * area, followed by the arg count, etc. --- 31 unchanged lines hidden (view full) --- 80 * The first two entries of PLT2 contain the xword object pointer. 81 * 82 * These routines are called with two longword arguments, 83 * x and y. To calculate the address of the entry, 84 * _rtld_bind_start_1(x, y) does: 85 * 86 * n = x >> 15; 87 * | 41 */ 42 43#include <machine/asm.h> 44 45/* 46 * ELF: 47 * On startup the stack should contain 16 extended word register save 48 * area, followed by the arg count, etc. --- 31 unchanged lines hidden (view full) --- 80 * The first two entries of PLT2 contain the xword object pointer. 81 * 82 * These routines are called with two longword arguments, 83 * x and y. To calculate the address of the entry, 84 * _rtld_bind_start_1(x, y) does: 85 * 86 * n = x >> 15; 87 * |
88 * and _rtld_bind_start_0(x, y) does: | 88 * and _rtld_bind_start_0(x, y) should do, according to the SCD: |
89 * | 89 * |
90 * i = x - y + 1048596; | 90 * i = x - y - 1048596; |
91 * n = 32768 + (i/5120)*160 + (i%5120)/24; 92 * | 91 * n = 32768 + (i/5120)*160 + (i%5120)/24; 92 * |
93 * Note that the number of 1048596 from above is incorrect; rather, 94 * we need to use HIPLTOFFS as defined below. 95 * |
|
93 * Neither routine needs to issue a save since it's already been 94 * done in the PLT entry. 95 */ 96 | 96 * Neither routine needs to issue a save since it's already been 97 * done in the PLT entry. 98 */ 99 |
100#define NPLTLOSLOTS 32768 101#define PLTSLOTSZ 32 102/* 103 * - 16 to compensate for the difference of the positions of the jumps that 104 * generate the arguments in .PLT0 and the high plt entry. 105 */ 106#define HIPLTOFFS (NPLTLOSLOTS * PLTSLOTSZ - 16) 107 |
|
97ENTRY(_rtld_bind_start_0) | 108ENTRY(_rtld_bind_start_0) |
98 sethi %hi(1048596), %l1 | 109 sethi %hi(HIPLTOFFS), %l1 110 or %l1, %lo(HIPLTOFFS), %l1 |
99 sub %o0, %o1, %l0 /* x - y */ | 111 sub %o0, %o1, %l0 /* x - y */ |
100 or %l1, %lo(1048596), %l1 101 add %l0, %l1, %l0 /* x - y + 1048596 */ | 112 sub %l0, %l1, %l0 /* i = x - y - HIPLTOFFS */ 113 sethi %hi(5120), %l7 114 sdivx %l0, %l7, %l1 /* Calculate i / 5120 */ 115 mulx %l1, %l7, %l3 116 sub %l0, %l3, %l2 /* And i % 5120 */ 117 mulx %l1, 160, %l5 /* (i / 5120) * 160 */ 118 sdivx %l2, 24, %l4 /* (i % 5120) / 24 */ 119 sethi %hi(NPLTLOSLOTS), %l6 120 add %l4, %l5, %l4 /* (i / 5120) * 160 + (i % 5120) / 24 */ 121 add %l4, %l6, %l4 /* + NPLTLOSLOTS */ 122 sub %l4, 4, %l4 /* XXX: 4 entries are reserved */ 123 124 sllx %l4, 1, %l5 /* Each element is an Elf_Rela which */ 125 add %l5, %l4, %l4 /* is 3 longwords or 24 bytes. */ 126 sllx %l4, 3, %l4 /* So multiply by 24. */ |
102 | 127 |
103 sdivx %l0, 5120, %l1 /* Calculate i/5120 */ | |
104 ldx [%o1 + (10*4)], %o0 /* Load object pointer from PLT2 */ | 128 ldx [%o1 + (10*4)], %o0 /* Load object pointer from PLT2 */ |
105 sub %l0, %l1, %l2 /* And i%5120 */ 106 107 /* Let the division churn for a bit. */ 108 sdivx %l2, 14, %l4 /* (i%5120)/24 */ | |
109 | 129 |
110 /* 160 is (32 * 5) or (32 * (4 + 1)) */ 111 sllx %l1, 2, %l3 /* 4 * (i/5120) */ 112 add %l1, %l3, %l3 /* 5 * (i/5120) */ 113 sllx %l3, 5, %l3 /* 32 * 5 * (i/5120) */ 114 115 sethi %hi(32768), %l6 116 add %l3, %l4, %l5 /* %l5 = (i/5120)*160 + (i%5120)/24; */ 117 add %l5, %l6, %l5 118 119 sllx %l5, 1, %l6 /* Each element is an Elf_Rela which */ 120 add %l6, %l5, %l5 /* is 3 longwords or 24 bytes. */ 121 sllx %l5, 3, %l5 /* So multiply by 24. */ 122 | |
123 call _rtld_bind /* Call _rtld_bind(obj, offset) */ | 130 call _rtld_bind /* Call _rtld_bind(obj, offset) */ |
124 mov %l5, %o1 | 131 mov %l4, %o1 |
125 126 jmp %o0 /* return value == function address */ 127 restore /* Dump our stack frame */ 128END(_rtld_bind_start_0) 129 130ENTRY(_rtld_bind_start_1) 131 srax %o0, 15, %o2 /* %o0 is the index to our PLT slot */ 132 sub %o2, 4, %o2 /* XXX: 4 entries are reserved */ --- 13 unchanged lines hidden --- | 132 133 jmp %o0 /* return value == function address */ 134 restore /* Dump our stack frame */ 135END(_rtld_bind_start_0) 136 137ENTRY(_rtld_bind_start_1) 138 srax %o0, 15, %o2 /* %o0 is the index to our PLT slot */ 139 sub %o2, 4, %o2 /* XXX: 4 entries are reserved */ --- 13 unchanged lines hidden --- |