Skip to content

[LLDB] s390x, incorrect byte order issues with Cast and p/x $pc #135707

Open
@patryk4815

Description

@patryk4815

Version: lldb 20.1.1

Reproduction:

qemu-s390x -g 1234 ./hello

Other terminal:

(lldb) file ./hello
(lldb) gdb-remote 0:1234
(lldb) b main
Breakpoint 1: where = hello`main, address = 0x0000000001002228
(lldb) c
Process 3281862 resuming
Process 3281862 stopped
* thread #1, stop reason = breakpoint 1.1
    frame #0: 0x0000000001002228 hello`main
hello`main:
    0x1002228 <+0>:  ear    %r1, %a0
    0x100222c <+4>:  sllg   %r4, %r1, 32
    0x1002232 <+10>: stmg   %r6, %r15, 48(%r15)
    0x1002238 <+16>: ear    %r4, %a1
(lldb) register read pc
    pswa = 0x0000000001002228  hello`main
(lldb) p/x $pc
(unsigned long) 0x2822000100000000
(lldb)

The bug occurs for all registers, not just the $pc
p/x $pc should show 0x0000000001002228, but instead I see: 0x2822000100000000

We discovered this bug while implementing s390x support in Pwndbg

In [20]: value = pwndbg.regs.by_name('r14')

In [21]: hex(int(value))
Out[21]: '0x7fb84143554a'

In [22]: hex(int(value.cast(pwndbg.aglib.typeinfo.unsigned)))
Out[22]: '0x4a554341b87f0000'

In [23]: pwndbg.aglib.typeinfo.unsigned.inner
Out[23]: unsigned long long

Basically internal lldb.SBValue Cast function mess-up byte-ordering somehow.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions