angr.analyses.decompiler.known_patterns.linked_list¶
Doubly-linked-list idioms shared by Windows LIST_ENTRY (Flink/Blink) and
Linux kernel list_head (next/prev): the same two-pointer layout, so one
set of templates matches both WDK drivers and kernel/Boost-intrusive code.
Covers the empty test, head init, unlink (RemoveEntryList / __list_del_entry),
head/tail insertion (InsertHeadList / list_add, InsertTailList /
list_add_tail), the two unlink supersets the kernel actually calls,
list_del (unlink + LIST_POISON1/2 stores) and list_del_init (unlink +
re-init), and the hlist_del diamond. The supersets rely on the finder
preferring the largest match, so they win over the bare unlink they contain.
The link offsets are word-scaled from the PatternContext, so the same
definitions work on 32- and 64-bit. Opt-in (genericish C idioms). Calibrated
against tests/x86_64/windows/known_patterns_wdk_list.exe and
tests/x86_64/decompiler/known_patterns_linux_list (both -O2, SLP off); the
compiler orders the link loads/stores freely, so the multi-statement idioms use
unordered statement-set matching (hlist_del excepted: PGraphPat block bodies
only support ordered matching).
hlist_add_head is absent on purpose: its last two stores land in the
diamond’s join block, and _outline_graph requires every interior block to be
fully consumed, so the idiom cannot be outlined without misrepresenting it.