angr.analyses.decompiler.known_patterns.stl_containers

C++ STL std::vector accessors beyond size()/capacity(): empty / operator[].

The three-pointer vector layout is shared by libstdc++ and the MSVC STL, so a single template per accessor, with word-scaled offsets and pointer-sized loads from the PatternContext, covers 32- and 64-bit on either runtime.

capacity() lives in std_vector_size with size(): the two are one expression against different fields, and both need a template per element size.

Calibrated against the known_patterns_stl binaries (libstdc++ ELF, MSVC x64/x86).

angr.analyses.decompiler.known_patterns.stl_containers.make_std_vector_index_template(elt_name, elt_size, returnty)

A std::vector<elt_name>::operator[] template: *(_M_start + i * sizeof(T)).

One per element size. Only the 4-byte (int) template existed, which covers 5% of the corpus’ DWARF sites for this accessor: 78% of them are 8-byte elements (unsigned long long alone is 30%, pointers another 14%).

The scale is matched as Mul or Shl: a power-of-two element size lifts from lea (%rax,%rdx,8) either way depending on how the index reached the address, and pinning one spelling silently halves the coverage.

Parameters:
  • elt_name (str)

  • elt_size (int)

  • returnty (str)