From owner-freebsd-alpha@FreeBSD.ORG Wed Jun 1 17:24:17 2005 Return-Path: X-Original-To: freebsd-alpha@FreeBSD.org Delivered-To: freebsd-alpha@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5BC7D16A41C for ; Wed, 1 Jun 2005 17:24:17 +0000 (GMT) (envelope-from rth@twiddle.net) Received: from are.twiddle.net (are.twiddle.net [64.81.246.98]) by mx1.FreeBSD.org (Postfix) with ESMTP id EE6E143D49 for ; Wed, 1 Jun 2005 17:24:16 +0000 (GMT) (envelope-from rth@twiddle.net) Received: from are.twiddle.net (localhost.localdomain [127.0.0.1]) by are.twiddle.net (8.12.11/8.12.11) with ESMTP id j51HOGqi004217 for ; Wed, 1 Jun 2005 10:24:16 -0700 Received: (from rth@localhost) by are.twiddle.net (8.12.11/8.12.11/Submit) id j51HOGPE004216 for freebsd-alpha@FreeBSD.org; Wed, 1 Jun 2005 10:24:16 -0700 X-Authentication-Warning: are.twiddle.net: rth set sender to rth@twiddle.net using -f Date: Wed, 1 Jun 2005 10:24:16 -0700 From: Richard Henderson To: freebsd-alpha@FreeBSD.org Message-ID: <20050601172416.GA4197@twiddle.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i Cc: Subject: reloc_non_plt_obj buggy X-BeenThere: freebsd-alpha@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the Alpha List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2005 17:24:17 -0000 >From src/libexec/rtld-elf/alpha/reloc.c: --------------------- #define load64(p) ({ \ Elf_Addr __res; \ __asm__("ldq_u %0,%1" : "=r"(__res) : "m"(*(p))); \ __res; }) #define store64(p, v) \ __asm__("stq_u %1,%0" : "=m"(*(p)) : "r"(v)) --------------------- case R_ALPHA_REFQUAD: { const Elf_Sym *def; const Obj_Entry *defobj; def = find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, false, cache); if (def == NULL) return -1; store64(where, (Elf_Addr) (defobj->relocbase + def->st_value) + load64(where) + rela->r_addend); } --------------------- Someone wasn't very clear on what ldq_u/stq_u actually does. You're not actually modifying the unaligned address, you're modifying (address & ~7), and corrupting the dwarf2 data in the process. You need to use struct ualong { Elf_Addr x __attribute__((packed)); }; #define load64(p) (((struct ualong *)(p))->x) #define store64(p,v) (((struct ualong *)(p))->x = (v)) r~