This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch v2 1/2] Enable ILP32 mode in gdb on aarch64


On Tue, Mar 7, 2017 at 7:55 PM, Steve Ellcey <sellcey@caviumnetworks.com> wrote:
> I have been looking at the code and offsets used in aarch64_linux_sigframe_init
> but I haven't had much luck in understanding the layout of the frames or the
> changes needed between the 32 and 64 bit ABIs.
>
> The code has these magic numbers:
> /* These magic numbers need to reflect the layout of the kernel
>    defined struct rt_sigframe and ucontext.  */
> #define AARCH64_SIGCONTEXT_REG_SIZE             8
> #define AARCH64_RT_SIGFRAME_UCONTEXT_OFFSET     128
> #define AARCH64_UCONTEXT_SIGCONTEXT_OFFSET      176
> #define AARCH64_SIGCONTEXT_XO_OFFSET            8
>
> I think AARCH64_SIGCONTEXT_REG_SIZE is OK, registers are still 8 bytes long
> in ILP32 mode.
>
> I am not sure what AARCH64_RT_SIGFRAME_UCONTEXT_OFFSET is supposed to
> represent.  Is it the size of the rt_sigframe structure?  Or the
> offset from rt_sigframe to the sigframe structure inside of rt_sigframe?
> (i.e. the size of sigframe).  I have the same problem with the other

probably because they are magic, :)  the comments above these
macros are

  The handler then needs to recover the saved register set from
  ucontext.uc_mcontext.

to your question, they are about offsets.  That is how I get the
offsets (I am not the author of this piece of code), load vmlinux
into gdb, and examine the offsets,

(gdb) ptype struct ucontext
type = struct ucontext {
    unsigned long uc_flags;
    struct ucontext *uc_link;
    stack_t uc_stack;
    sigset_t uc_sigmask;
    __u8 __unused[120];
    struct sigcontext uc_mcontext;
}

(gdb) p/d  &((struct rt_sigframe *) 0)->uc
$8 = 128

it is AARCH64_RT_SIGFRAME_UCONTEXT_OFFSET.

(gdb) p/d  &((struct rt_sigframe *) 0)->uc->uc_mcontext
$9 = 304

it is AARCH64_RT_SIGFRAME_UCONTEXT_OFFSET
+ AARCH64_UCONTEXT_SIGCONTEXT_OFFSET,

> magic numbers, I am just not sure what they represent.  I am also not
> sure if just changing the offset numbers is all that is needed or if
> there is some copying that needs to be done to massage the ILP32 formats
> into the expected layout.  I have never done any kernel work and was not
> around when the original aarch64 ILP32 work was done so I am not very
> familiar with the history of all this.
>

Assuming ILP32 kernel patches is correct, you can get these
magic number by loading ILP32 kernel vmlinux, and doing these
steps I do above.

-- 
Yao (齐尧)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]