This is the mail archive of the gdb@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: AArch64 calling convention in assembly code


>>Pushing LR on the stack resolves a problem
FP of course, not LR.
So the correct code must be like this:

_cpu_init_hook:
    stp        x29, x30, [sp, #-16]!
    mov        x29, sp
    bl        _init_vectors
    bl        _flat_map
    ldp        x29, x30, [sp], #16
    ret

But still my point is that GDB should catch such an error and do not hang.

Alex

On Tue, Jul 31, 2018 at 9:34 PM, Alexander Fedotov <alfedotov@gmail.com> wrote:
> Hello dear AArch64 maintainers
> Please look into code snippet below from newlib/libgloss/aarch64/rdimon-aem-el3.
>
> Seems to me this code violates AArch64 calling convention and actually
> breaks debugging in GDB. GDB tries to unwind call stack and got
> endless reentrancy...
>
> FUNCTION (_cpu_init_hook):
>     sub    sp, sp, #16
>     str    x30, [sp, xzr]
>     bl    _init_vectors
>     bl    _flat_map
>     ldr    x30, [sp, xzr]
>     add    sp, sp, #16
>     ret
>
>
> We have couple of calls there (_init_vectors, _flat_map). If you'll
> try to step into any subroutine you will found that GDB hangs and
> can't step anymore.
>
> Pushing LR on the stack resolves a problem.
>
> So my message is that:
> 1. Current code in _cpu_init_hook is incorrect
> 2. GDB should handle this and do not hang
>
> Alex



-- 
Best regards,
AF


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