Adjust for the fact that the GOT is all 0s in new binutils -- do the trick of

disassembling a call to _DYNAMIC to determine its real address, and using the
first entry of the GOT as its base-relative address.

It's evil, but it works.
This commit is contained in:
mycroft 2003-02-27 05:39:42 +00:00
parent 6d45c1cd99
commit eea1001a73
2 changed files with 23 additions and 26 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtld_start.S,v 1.13 2002/09/26 02:05:41 mycroft Exp $ */
/* $NetBSD: rtld_start.S,v 1.14 2003/02/27 05:39:42 mycroft Exp $ */
/*-
* Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@ -40,12 +40,6 @@
.section ".text"
.align 4
.LLGETPC0:
retl
add %o7,%l7,%l7
.section ".text"
.align 4
.global _rtld_start
.type _rtld_start,@function
_rtld_start:
@ -54,16 +48,20 @@ _rtld_start:
sub %sp, 32+8, %sp /* room for return args and save area */
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7
call .LLGETPC0
call 0f
add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7
ld [%l7+_DYNAMIC], %o0
ld [%l7+_GLOBAL_OFFSET_TABLE_], %l0
call _DYNAMIC+8
0: add %l7, %o7, %l7 /* real &_GLOBAL_OFFSET_TABLE_ */
ld [%o7+8], %o0 /* load stub call instruction */
ld [%l7], %l0 /* base-relative &_DYNAMIC */
sll %o0, 2, %o0 /* extract PC offset */
sub %l7, %l0, %o1 /* relocbase */
add %o0, %o7, %o0 /* real &_DYNAMIC */
sub %o0, %l0, %l0 /* relocbase */
call _rtld_relocate_nonplt_self
add %o0, %o1, %o0 /* &_DYNAMIC */
mov %l0, %o1 /* relocbase */
sub %l7, %l0, %o1 /* relocbase */
mov %l0, %o1 /* relocbase */
call _rtld
add %sp, 96, %o0 /* &argc - 8 */

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtld_start.S,v 1.14 2002/09/26 02:25:57 mycroft Exp $ */
/* $NetBSD: rtld_start.S,v 1.15 2003/02/27 05:39:43 mycroft Exp $ */
/*-
* Copyright (c) 2000 Eduardo Horvath.
@ -60,12 +60,6 @@
/* Offset of ARGC from bottom of stack */
#define ARGC 176
.section ".text"
.align 4
.LLGETPC0:
retl
add %o7,%l7,%l7
.section ".text"
.align 4
.global _rtld_start
@ -76,16 +70,21 @@ _rtld_start:
sub %sp, 48+16, %sp /* Make room for return args */
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7
call .LLGETPC0
call 0f
add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7
ldx [%l7+_DYNAMIC], %o0
ldx [%l7+_GLOBAL_OFFSET_TABLE_], %l0
call _DYNAMIC+8
0: add %l7, %o7, %l7 /* real &_GLOBAL_OFFSET_TABLE_ */
ld [%o7+8], %o0 /* load stub call instruction */
ldx [%l7], %l0 /* base-relative &_DYNAMIC */
sll %o0, 2, %o0 /* extract PC offset */
sra %o0, 0, %o0 /* sign-extend */
sub %l7, %l0, %o1 /* relocbase */
add %o0, %o7, %o0 /* real &_DYNAMIC */
sub %o0, %l0, %l0 /* relocbase */
call _rtld_relocate_nonplt_self
add %o0, %o1, %o0 /* &_DYNAMIC */
mov %l0, %o1 /* relocbase */
sub %l7, %l0, %o1 /* relocbase */
mov %l0, %o1 /* relocbase */
call _rtld
add %sp, BIAS + ARGC, %o0 /* &argc - 16 */