xrefcode.com / docs / cli / layout
$ xref layout
On this page
Reconstructed struct field layout accessed via an argument register (and optionally callees receiving it).
Usage
xref layout [OPTIONS] <ADDR>
Arguments and options
Arguments
<ADDR>Function address or symbol name.
Options
--reg <REG>Parameter or general-purpose register holding the struct pointer.
--calleesFollow direct/slot calls one hop where the struct pointer is forwarded.
Examples
All examples were recorded on public binaries; see Provenance.
--reg rdi
Command
$ xref -b xref.stripped layout 0xc7d60 --reg rdi
Output
layout of rdi in 0xc7d60..0xc7fbf: +0 size 8 u64 r:0 w:1 +8 size 8 u64 r:0 w:1 +10 size 8 u64 r:0 w:1 3 fields (min span 0x18) other pointer args: rsi (1 fields) (use --reg <REG>)
stderr
xref: load 458.9µs, total 1.5ms
--reg rdi --callees
Command
$ xref -b xref.stripped layout 0xc7d60 --reg rdi --callees
Output
layout of rdi in 0xc7d60..0xc7fbf: +0 size 8 u64 r:0 w:1 +8 size 8 u64 r:0 w:1 +10 size 8 u64 r:0 w:1 3 fields (min span 0x18) other pointer args: rsi (1 fields) (use --reg <REG>)
stderr
xref: load 605.6µs, total 1.7ms
--reg rsi
Command
$ xref -b xref.stripped layout 0xc7d60 --reg rsi
Output
layout of rsi in 0xc7d60..0xc7fbf: +18 size 0 &sub r:0 w:0 lea:1 1 fields (min span 0x19) other pointer args: rdi (3 fields) (use --reg <REG>)
stderr
xref: load 471.6µs, total 1.5ms
--reg rdi
Command
$ xref -b xref.stripped layout 0x9a8a0 --reg rdi
Output
layout of rdi in 0x9a8a0..0x9a97a: +0 size 8 u64 r:1 w:0 stride=0x8 +8 size 8 u64 r:1 w:0 +10 size 8 u64 r:1 w:0 +18 size 8 u64 r:1 w:0 4 fields (min span 0x20)
stderr
xref: load 478.3µs, total 1.6ms
Reading the output
- The header names the register and function; each row is one field offset (hex), its access size, an inferred scalar type and the read/write counts (
r:0 w:1). N fields (min span …)is how many distinct offsets were seen and the minimum extent they cover;other pointer argslists registers that also look like structure pointers.- With
--callees, offsets that a callee receiving the same pointer accesses are added and marked.
Limits
- The layout is what this function touches; fields it never accesses are invisible, and the real size is unknown.
- Types are inferred from access widths and use, not from debug information.
Provenance
Recorded with a development build of xref after 0.4.0 on Linux x86-64, on xref.stripped = a stripped xref build (the binary of the home-page examples). Output is unchanged except that whitespace at the end of each line and empty lines at the end of the output are removed; long outputs are cut where marked.
Source: docs/cli/layout.md · generated for the site; edit the Markdown, not this page.