From f6a359f27f50f964c3f17007e2da7b6c281d5eba Mon Sep 17 00:00:00 2001 From: pk Date: Fri, 26 Feb 1999 22:07:47 +0000 Subject: [PATCH] Completely construct the first PLT entry and correctly compute the PC relative offset in the call insn. --- libexec/ld.elf_so/reloc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libexec/ld.elf_so/reloc.c b/libexec/ld.elf_so/reloc.c index e27fe06764c0..7c9ac9934d0c 100644 --- a/libexec/ld.elf_so/reloc.c +++ b/libexec/ld.elf_so/reloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: reloc.c,v 1.12 1999/02/25 21:49:04 tv Exp $ */ +/* $NetBSD: reloc.c,v 1.13 1999/02/26 22:07:47 pk Exp $ */ /* * Copyright 1996 John D. Polstra. @@ -584,14 +584,20 @@ _rtld_relocate_objects( /* * PLTGOT is the PLT on the sparc. * The first entry holds the call the dynamic linker. - * We construct a `call' instruction that transfers + * We construct a `call' sequence that transfers * to `_rtld_bind_start()'. * The second entry holds the object identification. * Note: each PLT entry is three words long. */ - obj->pltgot[1] = 0x40000000 | +#define SAVE 0x9de3bfc0 /* i.e. `save %sp,-64,%sp' */ +#define CALL 0x40000000 +#define NOP 0x01000000 + obj->pltgot[0] = SAVE; + obj->pltgot[1] = CALL | ((Elf_Addr)&_rtld_bind_start - - (Elf_Addr)&obj->pltgot[1]); + (Elf_Addr)&obj->pltgot[1]) >> 2; + obj->pltgot[2] = NOP; + obj->pltgot[3] = (Elf_Addr) obj; #endif }