From: Alexander Graf <agraf@suse.de>
To: Doug Kwan <dougkwan@google.com>
Cc: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
riku.voipio@iki.fi, qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/3] linux-user: Handle ELFv2 PPC64 binaries in user mode.
Date: Thu, 08 May 2014 10:36:44 +0200 [thread overview]
Message-ID: <536B421C.7010609@suse.de> (raw)
In-Reply-To: <1399537603-6905-2-git-send-email-dougkwan@google.com>
On 05/08/2014 10:26 AM, Doug Kwan wrote:
> Look at ELF header to determin ABI version on PPC64. This is required
> for executing the first instruction correctly.
>
> Signed-off-by: Doug Kwan <dougkwan@google.com>
> ---
> include/elf.h | 5 +++++
> linux-user/elfload.c | 17 +++++++++++++++--
> 2 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/include/elf.h b/include/elf.h
> index 1599ab2..b39f5db 100644
> --- a/include/elf.h
> +++ b/include/elf.h
> @@ -561,6 +561,11 @@ typedef struct {
> #define SHF_ALPHA_GPREL 0x10000000
>
>
> +/* PowerPC specific definitions. */
> +
> +/* Processor specific flags for the ELF header e_flags field. */
> +#define EF_PPC64_ABI 3
Please write bitmasks in hex.
> +
> /* 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 *infop);
> +
> static inline void init_thread(struct target_pt_regs *_regs, struct image_info *infop)
> {
> _regs->gpr[1] = infop->start_stack;
> #if defined(TARGET_PPC64) && !defined(TARGET_ABI32)
> - _regs->gpr[2] = ldq_raw(infop->entry + 8) + infop->load_bias;
> - infop->entry = ldq_raw(infop->entry) + infop->load_bias;
> + if (get_ppc64_abi(infop) < 2) {
> + _regs->gpr[2] = ldq_raw(infop->entry + 8) + infop->load_bias;
> + infop->entry = ldq_raw(infop->entry) + infop->load_bias;
> + } else {
> + _regs->gpr[12] = 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?
> + }
> #endif
> _regs->nip = 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 ... :).
Alex
next prev parent reply other threads:[~2014-05-08 8:37 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-08 8:26 [Qemu-devel] [PATCH 0/3] Adding new user mode target ppc64el-linux-user Doug Kwan
2014-05-08 8:26 ` [Qemu-devel] [PATCH 1/3] linux-user: Handle ELFv2 PPC64 binaries in user mode Doug Kwan
2014-05-08 8:36 ` Alexander Graf [this message]
2014-05-08 8:43 ` Doug Kwan (關振德)
2014-05-08 8:45 ` Alexander Graf
2014-05-08 13:30 ` Ulrich Weigand
2014-05-08 8:26 ` [Qemu-devel] [PATCH 2/3] PPC: Allow little-endian " Doug Kwan
2014-05-08 8:39 ` Alexander Graf
2014-05-08 8:49 ` Doug Kwan (關振德)
2014-05-08 8:55 ` Alexander Graf
2014-05-08 9:05 ` Doug Kwan (關振德)
2014-05-08 9:11 ` Alexander Graf
2014-05-08 9:24 ` Doug Kwan (關振德)
2014-05-08 12:39 ` Peter Maydell
2014-05-08 12:44 ` Alexander Graf
2014-05-08 8:26 ` [Qemu-devel] [PATCH 3/3] configure: Add new target ppc64el-linux-user Doug Kwan
2014-05-08 8:41 ` Alexander Graf
2014-05-08 8:46 ` Doug Kwan (關振德)
2014-05-08 8:56 ` Alexander Graf
2014-05-08 9:09 ` Doug Kwan (關振德)
2014-05-08 12:18 ` Andreas Färber
2014-05-08 12:28 ` Peter Maydell
2014-05-08 12:45 ` Alexander Graf
2014-05-08 15:57 ` Doug Kwan (關振德)
2014-05-08 14:41 ` Tom Musta
2014-05-08 15:19 ` Doug Kwan (關振德)
2014-05-08 15:25 ` Peter Maydell
2014-05-08 15:32 ` Doug Kwan (關振德)
2014-05-08 15:41 ` Peter Maydell
2014-05-08 15:51 ` Doug Kwan (關振德)
2014-05-08 15:56 ` Peter Maydell
2014-05-08 15:39 ` Tom Musta
2014-05-08 15:43 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=536B421C.7010609@suse.de \
--to=agraf@suse.de \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=dougkwan@google.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=riku.voipio@iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.