Re: PATCH: Also check for `movl %esp, %ebp' for x32

Mark Kettenis
2012-04-17T11:43:56Z

> Date: Tue, 10 Apr 2012 13:29:53 -0700
> From: "H.J. Lu" <hongjiu.lu@intel.com>
>
> Hi,
>
> X32 may use `movl %esp, %ebp' in prologue. This patch checks it for
> x32. Tested on Linux/x86-64. OK for trunk?

Sorry, but I'm not sure it is a good idea to mix ABIs in the code like
that. Up until now, I've made a conscious attempt to keep the i386
and amd64 ABIs seperated out as much as possible. Can you post a
complete diff of the -tdep.c related changes to support x32 in GDB,
such that I can judge where this is heading?

> diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
> index d15acea..e64de21 100644
> --- a/gdb/amd64-tdep.c
> +++ b/gdb/amd64-tdep.c
> @@ -1900,10 +1927,14 @@ amd64_analyze_prologue (struct gdbarch *gdbarch,
> if (current_pc <= pc + 1)
> return current_pc;
>
> - /* Check for `movq %rsp, %rbp'. */
> + /* Check for `movq %rsp, %rbp'. Also check for `movl %esp, %ebp'
> + if it is an x32 target. */
> read_memory (pc + 1, buf, 3);
> if (memcmp (buf, mov_rsp_rbp_1, 3) != 0
> - && memcmp (buf, mov_rsp_rbp_2, 3) != 0)
> + && memcmp (buf, mov_rsp_rbp_2, 3) != 0
> + && (gdbarch_ptr_bit (gdbarch) == 64
> + || (memcmp (buf, mov_rsp_rbp_1 + 1, 2) != 0
> + && memcmp (buf, mov_rsp_rbp_2 + 1, 2) != 0)))
> return pc + 1;
>
> /* OK, we actually have a frame. */
>