Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/libexec/ld.elf_so/arch/sparc64 Pull up following revision...
details: https://anonhg.NetBSD.org/src/rev/e7fe51dd759d
branches: netbsd-8
changeset: 434157:e7fe51dd759d
user: snj <snj%NetBSD.org@localhost>
date: Tue Jul 25 02:19:03 2017 +0000
description:
Pull up following revision(s) (requested by martin in ticket #156):
libexec/ld.elf_so/arch/sparc64/mdreloc.c: 1.62, 1.63
Simplify and fix the offset calculation when doing a %pc relative
branch from the PLT slot to the target.
--
Fix thinko in previous: even if the address is an unsigned value and we
have verified the range before, we still need to mask the bit pattern
to the target instruction field.
diffstat:
libexec/ld.elf_so/arch/sparc64/mdreloc.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diffs (53 lines):
diff -r f920012e17c1 -r e7fe51dd759d libexec/ld.elf_so/arch/sparc64/mdreloc.c
--- a/libexec/ld.elf_so/arch/sparc64/mdreloc.c Tue Jul 25 02:17:16 2017 +0000
+++ b/libexec/ld.elf_so/arch/sparc64/mdreloc.c Tue Jul 25 02:19:03 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mdreloc.c,v 1.59.6.1 2017/07/04 12:47:58 martin Exp $ */
+/* $NetBSD: mdreloc.c,v 1.59.6.2 2017/07/25 02:19:03 snj Exp $ */
/*-
* Copyright (c) 2000 Eduardo Horvath.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.59.6.1 2017/07/04 12:47:58 martin Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.59.6.2 2017/07/25 02:19:03 snj Exp $");
#endif /* not lint */
#include <errno.h>
@@ -579,7 +579,7 @@
Elf_Word *where = (Elf_Word *)(obj->relocbase + rela->r_offset);
const Elf_Sym *def;
const Obj_Entry *defobj;
- Elf_Addr value, offset;
+ Elf_Addr value, offset, offBAA;
unsigned long info = rela->r_info;
assert(ELF_R_TYPE(info) == R_TYPE(JMP_SLOT));
@@ -625,6 +625,7 @@
*/
offset = ((Elf_Addr)where) - value;
+ offBAA = value - (((Elf_Addr)where) +4); /* ba,a at where[1] */
if (rela->r_addend) {
Elf_Addr *ptr = (Elf_Addr *)where;
/*
@@ -634,7 +635,7 @@
*/
ptr[0] += value - (Elf_Addr)obj->pltgot;
- } else if (offset <= (1L<<20) && (Elf_SOff)offset >= -(1L<<20)) {
+ } else if (offBAA <= (1L<<20) && (Elf_SOff)offBAA >= -(1L<<20)) {
/*
* We're within 1MB -- we can use a direct branch insn.
*
@@ -650,7 +651,7 @@
* nop
*
*/
- where[1] = BAA | ((offset >> 2) & 0x7ffff);
+ where[1] = BAA | ((offBAA >> 2) & 0x7ffff);
__asm volatile("iflush %0+4" : : "r" (where));
} else if (value < (1L<<32)) {
/*
Home |
Main Index |
Thread Index |
Old Index