From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiJxL-0003Lg-3r for qemu-devel@nongnu.org; Thu, 08 May 2014 04:45:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WiJxF-0004BL-1s for qemu-devel@nongnu.org; Thu, 08 May 2014 04:45:31 -0400 Message-ID: <536B4424.1040908@suse.de> Date: Thu, 08 May 2014 10:45:24 +0200 From: Alexander Graf MIME-Version: 1.0 References: <1399537603-6905-1-git-send-email-dougkwan@google.com> <1399537603-6905-2-git-send-email-dougkwan@google.com> <536B421C.7010609@suse.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/3] linux-user: Handle ELFv2 PPC64 binaries in user mode. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?IkRvdWcgS3dhbiAo6Zec5oyv5b63KSI=?= Cc: Ulrich Weigand , riku.voipio@iki.fi, "qemu-ppc@nongnu.org" , QEMU Developers On 05/08/2014 10:43 AM, Doug Kwan (=E9=97=9C=E6=8C=AF=E5=BE=B7) wrote: > Hi > > > On Thu, May 8, 2014 at 1:36 AM, Alexander Graf > wrote: 3 > > > Please write bitmasks in hex. > > Will fix. > > + > /* PowerPC relocations defined by the ABIs */ > #define R_PPC_NONE 0 > #define R_PPC_ADDR32 1 /* 32bit absolute > address */ > diff --git a/linux-user/elfload.c b/linux-user/elfload.c > index 995f999..b96d64a 100644 > --- a/linux-user/elfload.c > +++ b/linux-user/elfload.c > @@ -777,12 +777,18 @@ static uint32_t get_elf_hwcap(void) > NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC); \ > } while (0) > +static inline uint32_t get_ppc64_abi(struct image_info *info= p); > + > static inline void init_thread(struct target_pt_regs *_regs, > struct image_info *infop) > { > _regs->gpr[1] =3D infop->start_stack; > #if defined(TARGET_PPC64) && !defined(TARGET_ABI32) > - _regs->gpr[2] =3D ldq_raw(infop->entry + 8) + infop->load_= bias; > - infop->entry =3D ldq_raw(infop->entry) + infop->load_bias; > + if (get_ppc64_abi(infop) < 2) { > + _regs->gpr[2] =3D ldq_raw(infop->entry + 8) + > infop->load_bias; > + infop->entry =3D ldq_raw(infop->entry) + infop->load_bia= s; > + } else { > + _regs->gpr[12] =3D infop->entry; /* r12 set to global > entry address */ > > > Uli, is this correct? Also, why don't w need to adjust for the > load_bias with ELFv2 anymore? > > No. This is a bug. It was not caught by testing because load_bias is=20 > 0 I guess. > > > + } > #endif > _regs->nip =3D infop->entry; > } > @@ -1152,6 +1158,13 @@ static inline void init_thread(struct > target_pt_regs *regs, struct image_info *i > #include "elf.h" > +#ifdef TARGET_PPC > +static inline uint32_t get_ppc64_abi(struct image_info *infop) > +{ > + return infop->elf_flags & EF_PPC64_ABI; > +} > +#endif > > > I'm not sure this is more readable than doing it inline ... :). > > > This is done so because the elf header is not yet included before the=20 > callee. To eliminate this I need to move the include before ppc's=20 > init_thread. Is that okay? Ah, I see. I don't have strong feelings either way. Riku, what would you=20 prefer? Alex