Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b142d1c
ROADMAP: rows D640 to D659; doc/adr-memory-places.md
0verflowme Nov 21, 2026
185447f
D640: scripts/memory_sites.py counts body memory sites
0verflowme Nov 21, 2026
f87ef0b
Lift: D664, AArch64 logical immediates whose imms fills the element a…
0verflowme Nov 21, 2026
b2b1fdc
Image: D662, init, fini and preinit arrays read through PT_DYNAMIC
0verflowme Nov 21, 2026
51c42ff
D654 step 0: one join for the frame refusals; the rule moves nothing
0verflowme Nov 21, 2026
d21c33c
D654 step 0: the record states what the traces show
0verflowme Nov 21, 2026
d243fc5
D546: a site passes each argument at its callee formal's home
0verflowme Nov 21, 2026
30b3403
Image: D663, `static` is what the container states, three valued
0verflowme Nov 21, 2026
63d809f
D653: optarg and optind typed where the loader's copy and a glibc row…
0verflowme Nov 21, 2026
6dd5aac
ROADMAP: D647 and D655 held on measured facts; D637 punctuation
0verflowme Nov 21, 2026
0dc4d02
D641 step 0: places and records counted from engine facts over DecBench
0verflowme Nov 21, 2026
b59d86a
D659 step 0: the 1,390 gap residuals are registers an unrendered call…
0verflowme Nov 21, 2026
aff5c24
D656 step 0: a global floor of 914 sites; D657 held on the index's cost
0verflowme Nov 21, 2026
26db428
D642: MemoryPlaces states each access's base and place in r2ssa
0verflowme Nov 21, 2026
59b34cf
D654 step 0 and D647: the record matches the traces
0verflowme Nov 21, 2026
1c56531
Gates: D665, the judged table states what the pin prints
0verflowme Nov 21, 2026
693196e
D661: pdd never prints (void) when formals exist
0verflowme Nov 21, 2026
ae09a53
Comments: D662 and D663's doc comments to two lines
0verflowme Nov 21, 2026
64254c0
D660: AArch64 v0 is a result lane
0verflowme Nov 21, 2026
96a7b5a
D656, D653: the floor per image, the aa path's cost, and D653's open …
0verflowme Nov 21, 2026
e6cb808
Values: D648, a sign test at or above a non-negative bound clears the…
0verflowme Nov 21, 2026
b372468
ROADMAP: D646 stops on r8's callee fact; D632 re-probed; D680 claimed
0verflowme Nov 21, 2026
78ddb8c
ROADMAP: D350 step 0 re-counted after D546, D661 and D660; D456 not s…
0verflowme Nov 21, 2026
1acb3a6
D643: Constraint::Field solves parameter records, one refusal per span
0verflowme Nov 21, 2026
3532c94
D660: a resolved integer lane stays observed beside the float lane
0verflowme Nov 21, 2026
e5579c0
D644: a pointer loaded from a record's field has a record
0verflowme Nov 21, 2026
22ba890
ROADMAP: D642 to D644 timing and gates; D643's bash pdf cause line
0verflowme Nov 21, 2026
dbeedbe
Gates: D490 on the chain's head, libshella's px judged, elf axt 237 t…
0verflowme Nov 22, 2026
199dbdf
Gates: D648's cost line, the 0pack stats it moves, D663's message cor…
0verflowme Nov 26, 2026
b8f20c2
Revert D660 at the chain: AArch64 equivalence leaves equal at 3 records
0verflowme Nov 26, 2026
021000d
ROADMAP: D350's result side judged, no stop fact; D456 not started; D…
0verflowme Nov 26, 2026
30d1a5a
Merge rd18-gate-objects (round 18)
0verflowme Nov 26, 2026
922bbe1
Merge rd18-surface-pads (round 18)
0verflowme Nov 26, 2026
ed45b4c
Merge rd18-prototypes (round 18)
0verflowme Nov 26, 2026
17fe074
Merge rd18-frame-objects (round 18)
0verflowme Nov 26, 2026
d2e9160
Merge rd18-places-records (round 18)
0verflowme Nov 26, 2026
f75ae3e
Exit: D661's proof test passes D644's laid-out triple
0verflowme Nov 26, 2026
0127c27
Exit: round 18's structure rises paid at their owners
0verflowme Nov 26, 2026
842be3e
Structure: bless round 18's exit, long_comments 2,383 to 2,381
0verflowme Nov 26, 2026
51fb15a
ROADMAP: round 18's exit; cost_causes on the merged head
0verflowme Nov 26, 2026
0bc0b25
ROADMAP: round 18's stack row is #424
0verflowme Nov 26, 2026
963671c
Records: two classes one instruction roots get two tags (Codex on #424)
0verflowme Nov 26, 2026
a180234
Records: a duplicate tag is refused, and a pipeline test (Codex on #4…
0verflowme Nov 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 83 additions & 10 deletions ROADMAP.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions crates/r2abi/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ and `struct __dirstream` (`dirent.h`), libSystem's `struct __sFILE` (`_stdio.h`)
`struct __sFILE` (`stdio.h`) and `struct DIR` (`dirent.h`). libSystem's `DIR` is a typedef of an
anonymous struct, so it has no row and the name stays an opaque typedef.

## Objects

`objects.txt` states the type a C library's header declares a data object at
(`stderr`, `optarg`), one row per library and name, each citing the header line. A row is read
only into its own library's tables, and a program binds it only where its loader copies that
object (`R_*_COPY`) under the same symbol at the type's size: the name alone proves nothing
(ROADMAP D653). A library with no row keeps the object untyped.

## Effects

A cited row may state `func.<name>.effects=`, what the function does through its parameters,
Expand Down
13 changes: 13 additions & 0 deletions crates/r2abi/data/objects.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# The type a C library's header declares a data object at. A program binds one only where its
# loader copies that object here (`R_*_COPY`) under the same symbol, at the type's size (D653).
#
# library | name | type | header line that declares it

# ISO C17 7.21.1p3: stdin, stdout and stderr are expressions of type `FILE *`.
glibc | stdin | FILE * | glibc 2.39 <stdio.h>, libio/stdio.h:149
glibc | stdout | FILE * | glibc 2.39 <stdio.h>, libio/stdio.h:150
glibc | stderr | FILE * | glibc 2.39 <stdio.h>, libio/stdio.h:151

# POSIX.1-2017 getopt: `extern char *optarg; extern int optind;`.
glibc | optarg | char * | glibc 2.39 <getopt.h>, posix/bits/getopt_core.h:36
glibc | optind | int | glibc 2.39 <getopt.h>, posix/bits/getopt_core.h:50
2 changes: 1 addition & 1 deletion crates/r2abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub use declarations::{DataObject, Declarations};
pub use effects::{Effect, Effects, Extent};
pub use library::{
CLibrary, Dll, FlagBits, FlagTest, FormatKind, Halt, Handle, Kernel, LibraryId, LibraryRow,
LibraryRows, PrototypeId, RowResult, Tail,
LibraryRows, ObjectRow, PrototypeId, RowResult, Tail,
};
pub use loader::{LoaderCall, ResultRead, loader_call};
pub use mangled::Passing;
Expand Down
46 changes: 46 additions & 0 deletions crates/r2abi/src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ pub struct LibraryRows {
graph: TypeGraph,
prototypes: Vec<Prototype>,
rows: BTreeMap<LibraryId, BTreeMap<Box<str>, LibraryRow>>,
/// The data objects this C library's headers declare, by name (`data/objects.txt`).
objects: BTreeMap<Box<str>, ObjectRow>,
}

/// The type a C library's header declares one data object at, and the line it cites.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ObjectRow {
pub ty: crate::TypeId,
pub citation: Box<str>,
}

const PORTABLE: &str = include_str!("../data/types.sdb.txt");
Expand All @@ -263,6 +272,8 @@ const KERNEL32: &str = include_str!("../data/types-kernel32.sdb.txt");
const UCRT: &str = include_str!("../data/types-ucrt.sdb.txt");
/// Whether a mangled member takes `this` where its name leaves it open, by the header declaring it.
const CXX_OBJECTS: &str = include_str!("../data/cxx-objects.txt");
/// The type each C library's header declares a data object at, with the line (D653).
const OBJECTS: &str = include_str!("../data/objects.txt");

/// One embedded table: whose rows, whether each row cites its source, and the text.
struct Embedded {
Expand Down Expand Up @@ -320,6 +331,7 @@ impl Default for LibraryRows {
graph: TypeGraph::default(),
prototypes: Vec::new(),
rows: BTreeMap::new(),
objects: BTreeMap::new(),
}
}
}
Expand Down Expand Up @@ -359,10 +371,43 @@ impl LibraryRows {
for embedded in shared.iter().chain(own) {
rows.read_text(embedded, embedded.text);
}
rows.read_objects(library);
rows.quotient();
rows
}

/// `library`'s `data/objects.txt` rows, each type read into this table's graph. O(lines).
fn read_objects(&mut self, library: CLibrary) {
for line in OBJECTS.lines().map(str::trim) {
if line.is_empty() || line.starts_with('#') {
continue;
}
let [of, name, spelling, citation] =
line.split('|').map(str::trim).collect::<Vec<_>>()[..]
else {
continue;
};
let of = match of {
"glibc" => CLibrary::Glibc,
"bionic" => CLibrary::Bionic,
"musl" => CLibrary::Musl,
"libsystem" => CLibrary::LibSystem,
_ => continue,
};
if of != library || !citation.contains(".h") {
continue;
}
let ty = crate::spelling::read(spelling, &mut self.graph, &self.reading);
let citation = citation.into();
self.objects.insert(name.into(), ObjectRow { ty, citation });
}
}

/// The type this C library's header declares the data object `name` at.
pub fn object(&self, name: &str) -> Option<&ObjectRow> {
self.objects.get(name)
}

/// One uncited table's rows under `library`, for a test that states its own.
pub fn parse(library: LibraryId, text: &str) -> Self {
let mut rows = Self::default();
Expand Down Expand Up @@ -393,6 +438,7 @@ impl LibraryRows {
fn quotient(&mut self) {
let classes = self.graph.quotient();
(self.prototypes.iter_mut()).for_each(|prototype| prototype.retype(&classes));
(self.objects.values_mut()).for_each(|object| object.ty = classes[object.ty.index()]);
}

/// The parameters only: a mangled name states no result, so the return type is refused.
Expand Down
11 changes: 6 additions & 5 deletions crates/r2abi/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ pub struct Posture {
pub relro: Option<Relro>,
/// The dynamic linker `PT_INTERP` names (empty where the header holds no readable path).
pub interpreter: Option<String>,
/// No `PT_INTERP` and no `PT_DYNAMIC`: nothing relocates this image but its own start-up.
pub statically_linked: bool,
/// `Some(true)`: no `PT_INTERP`, and no `PT_DYNAMIC` or no `DT_NEEDED` with `DF_1_PIE`; `Some(false)`:
/// `PT_INTERP`, `DT_NEEDED` or `DT_SONAME`; otherwise unstated. Read only by `i`.
pub statically_linked: Option<bool>,
}

/// Where the loader places an image, as its header states it (gABI chapter 5, "Base Address").
Expand Down Expand Up @@ -861,9 +862,9 @@ pub enum WriteKind {
/// A word the psABI reserves for the dynamic loader's link map or lazy
/// resolver (x86-64 psABI 5.2, AAELF64 GOT[1..2]): never an address of this image.
Reserved,
/// Another image's object copied here (`R_*_COPY`): its relocated bytes, which name this image
/// only through definitions it exports, never a function only this image names.
Copy,
/// Another image's object copied here (`R_*_COPY`), naming this image only through its exports;
/// `symbol` is the object's where its symbol states a size, the write's width (D653).
Copy { symbol: Option<String> },
/// Written, with no value the container states: a whole table a psABI
/// reserves, a signed pointer, or a format this reader does not decode.
#[default]
Expand Down
26 changes: 26 additions & 0 deletions crates/r2abi/tests/cited_rows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,3 +590,29 @@ fn the_rows_a_header_states_are_cited_where_they_bind() {
assert!(count("types-linux.sdb.txt,") <= 3);
assert!(count("types-cxx.sdb.txt,") <= 42);
}

/// Each data object row cites the header line that declares it, and binds only in its library.
#[test]
fn every_object_row_cites_its_header_line() {
let text = table("objects.txt");
let rows = (text.lines().map(str::trim))
.filter(|line| !line.is_empty() && !line.starts_with('#'))
.collect::<Vec<_>>();
assert!(rows.len() >= 5, "{rows:?}");
for row in &rows {
let fields = row.split('|').map(str::trim).collect::<Vec<_>>();
assert_eq!(fields.len(), 4, "{row}");
assert!(fields[3].contains(".h:"), "{row}");
}
let glibc = LibraryRows::embedded(CLibrary::Glibc);
assert!(
glibc
.object("stderr")
.is_some_and(|row| row.citation.contains("stdio.h:151"))
);
assert!(
LibraryRows::embedded(CLibrary::Musl)
.object("stderr")
.is_none()
);
}
2 changes: 1 addition & 1 deletion crates/r2dec/src/render/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl<'a> Globals<'a> {
.zip(declared.clone())
.map(|(fact, ty)| DataObjectTypeFact {
ty,
provenance: fact.provenance,
provenance: fact.provenance.clone(),
}),
type_refusal: self.types.refused().get(&address).cloned(),
});
Expand Down
14 changes: 3 additions & 11 deletions crates/r2dec/src/render/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,9 @@ impl<'a> RenderInput<'a> {
.collect()
}

pub fn inferred_aggregates(
&self,
) -> &'a std::collections::BTreeMap<String, r2types::AggregateDefinition> {
&self.facts.report().type_facts().inferred_aggregates
}

/// Each parameter that points to an inferred structure, with the member at each offset.
pub fn parameter_structures(
&self,
) -> &'a std::collections::BTreeMap<usize, r2types::ParameterStructure> {
&self.facts.report().type_facts().parameter_structures
/// The records the parameters' accesses lay out: definitions by tag, and each parameter's.
pub fn records(&self) -> &'a r2types::Records {
&self.facts.report().type_facts().records
}

/// The types the function's declaration states, as one graph: its aggregates' layouts.
Expand Down
14 changes: 12 additions & 2 deletions crates/r2dec/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ pub fn render(
crate::ast::respell_nonconforming_main(&mut c, input.function().entry);
let ledger = close_ledger(input, values.as_ref());
let unassigned = values.as_ref().map(values::Values::unassigned);
let clauses = proof::ProofClauses::of(&c, unassigned.as_deref().unwrap_or_default());
let unclassed = values.as_ref().and_then(values::Values::unclassed);
let clauses = proof::ProofClauses::of(&c, unassigned.as_deref().unwrap_or_default(), unclassed);
open_proof_line(&mut c, input, &ledger, &clauses, &tags);
let mut ready = ready_with_carriers(c, &tags);
// Each marker names the instruction its statement was written for, so each line names its own.
Expand Down Expand Up @@ -164,7 +165,15 @@ fn open_proof_line(
(input.open_second_result(), input.integer_lane_unread_only()),
&input.body_disputed_lanes(),
),
input.inferred_aggregates().len(),
{
let records = input.records();
let laid = records.classes.iter().flatten().count();
(
records.parameters.len(),
laid - records.parameters.len(),
records.recursive,
)
},
&tags.conflicting(),
&input.unproven_parameters(),
),
Expand Down Expand Up @@ -214,6 +223,7 @@ fn declare(c: &mut CFunction, input: &RenderInput<'_>, values: Option<&values::V
match values {
Some(values) => {
c.params = values.params();
c.params_known = values.unclassed().is_none();
c.variadic = input.variadic();
c.locals = values.locals();
c.externs = values.externs();
Expand Down
Loading
Loading