From patchwork Wed Oct 26 16:59:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 121949 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 332561007D2 for ; Thu, 27 Oct 2011 04:00:42 +1100 (EST) Received: from localhost ([::1]:54308 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJ6pz-0002nc-Gp for incoming@patchwork.ozlabs.org; Wed, 26 Oct 2011 13:00:23 -0400 Received: from eggs.gnu.org ([140.186.70.92]:55364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJ6pn-0002gk-Am for qemu-devel@nongnu.org; Wed, 26 Oct 2011 13:00:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJ6ph-0007nF-Gz for qemu-devel@nongnu.org; Wed, 26 Oct 2011 13:00:11 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:51344) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJ6ph-0007lq-4S for qemu-devel@nongnu.org; Wed, 26 Oct 2011 13:00:05 -0400 Received: by wyh15 with SMTP id 15so2090182wyh.4 for ; Wed, 26 Oct 2011 10:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=IZh+qKFNvVdSGrOSUtE+9VoFQ+wdZScEGZMac8ubspI=; b=VjtQCo1RZRjeVaRApATjSMrmKCpK3dC3d/2YC2xECv6YU/TRCUD4uMS7UzAeilgTfZ /38SguOXwpiykEwvMRyOmvA+VYxZrZ+6XYW9dn/dFJD84NF4FLZ0a/vkai4DnvNVJvCR 9DFvqlw01P1d9kvJCJ3urEZe38pLnLWUeJBaE= Received: by 10.216.229.85 with SMTP id g63mr5776254weq.53.1319648403823; Wed, 26 Oct 2011 10:00:03 -0700 (PDT) Received: from localhost.localdomain (c-98-203-235-125.hsd1.wa.comcast.net. [98.203.235.125]) by mx.google.com with ESMTPS id fi11sm4242888wbb.9.2011.10.26.10.00.01 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Oct 2011 10:00:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Oct 2011 09:59:17 -0700 Message-Id: <1319648358-18812-2-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.6.4 In-Reply-To: <1319648358-18812-1-git-send-email-rth@twiddle.net> References: <1319648358-18812-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.173 Cc: riku.voipio@iki.fi, agraf@suse.de Subject: [Qemu-devel] [PATCH 1/2] ppc64-linux-user: Properly interpret the entry function descriptor. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Don't confuse the load address with the load bias. They're equal for ET_DYN objects (i.e. ld.so) but different for ET_EXEC objects (i.e. statically linked). Signed-off-by: Richard Henderson Acked-by: Alexander Graf --- linux-user/elfload.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 8677bba..a413976 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -618,8 +618,8 @@ static inline void init_thread(struct target_pt_regs *_regs, struct image_info * { _regs->gpr[1] = infop->start_stack; #if defined(TARGET_PPC64) && !defined(TARGET_ABI32) - _regs->gpr[2] = ldq_raw(infop->entry + 8) + infop->load_addr; - infop->entry = ldq_raw(infop->entry) + infop->load_addr; + _regs->gpr[2] = ldq_raw(infop->entry + 8) + infop->load_bias; + infop->entry = ldq_raw(infop->entry) + infop->load_bias; #endif _regs->nip = infop->entry; } @@ -1884,11 +1884,11 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, info->start_stack = bprm->p; /* If we have an interpreter, set that as the program's entry point. - Copy the load_addr as well, to help PPC64 interpret the entry + Copy the load_bias as well, to help PPC64 interpret the entry point as a function descriptor. Do this after creating elf tables so that we copy the original program entry point into the AUXV. */ if (elf_interpreter) { - info->load_addr = interp_info.load_addr; + info->load_bias = interp_info.load_bias; info->entry = interp_info.entry; free(elf_interpreter); }