Repository navigation
[AUTOMATED] Name Itanium constructors and destructors from their vptr stores - #1606
Conversation
… stores
On a stripped GCC/Clang C++ ELF, itaniumrtti named every class and virtual
slot but left constructors as sub_<addr> and destructors under their
slot-index name. With the Listing built, the same option now names them
C::C and C::~C, the names a symbol table gives them.
A constructor or destructor of C is the function that stores C's vptr into
the object it was called on. Candidates are the functions whose decoded
operand names a vptr value (or its 4 KiB page, for adrp/add pairs); each is
lifted to p-code and walked along its fall-through path with a small
symbolic state (first parameter = this from the default prototype model,
stack pointer = frame base, frame spills followed, calls keep only
unaffected registers). Only a STORE of a vptr constant through this+off
counts, so an -O2 factory that inlines `new C` (stores through operator
new's result) or a caller building a C in its frame is not a constructor.
- A function in C's own primary vtable that stores C's vptr is C::~C; the
next slot (the deleting destructor) is named too only when it calls it,
because at -O2 the deleting destructor may be the only one that stores.
- A function in no vtable that stores C's vptr is C::C, only when C or a
base has such a virtual destructor: a non-virtual destructor stores the
vptr exactly as a constructor does.
- The Function-symbol commit now replaces a slot-index name (the kind
is_vtable_slot_name already ranks as structural) in the same scope with
a real, non-placeholder name, so the destructor name reaches call sites.
The recovery is a Listing consumer (ItaniumCtorsPass, id itaniumrtti): the
load-time pass runs before the Listing exists and before the image is
attached to the decoder.
Measured against unstripped twins (symbol-only truth): the new fixture
11 correct / 0 wrong at -O0, 0 / 0 at -O2; an STL-heavy program with
shared_ptr, std::function and virtual inheritance 44 / 0 at -O0 and
12 / 0 at -O2; libicuuc.so.74 152 names, 142 at exported symbols, all of
the matching kind, 0 wrong. decompile-all over the in-repo C++ fixtures
changes names only (0 non-name line differences). Load time with the
Listing: libapt-pkg +1.9%, libicuuc +1.5%.
Tests: tests/stages/kuna-itaniumctors.xml (two-pass, plus the -O2 factory
and the no-virtual-destructor class as negatives), verify_itaniumctors,
unit tests in kuna_itaniumctors and for the commit rule. New fixtures
itaniumctors_O{0,2}_x86_64.so with source.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
[AUTOMATED] The stall test injects its fault at 0x14ea of the itaniumrtti fixture and expected the lost record under sub_14ea. That function is Circle's constructor, which decompile-all now reports as shapes::Circle::Circle. Co-Authored-By: Claude Fable 5.2 <[email protected]>
d3f594f to
e4e6a87
Compare
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…beside a symbol-table name
In optimized code a helper that a constructor or destructor was inlined into
stores the vptr through its first parameter exactly as a constructor does: a
by-value factory's return slot, a placement-new helper, the constructor of a
class whose first member is polymorphic, a `delete p` wrapper. Each was named
`C::C`. A function in no vtable is now a constructor only when every vptr store
goes through `this` read back from the function's own frame spill. Facts for a
function the symbol table already names are dropped, so a recovered name never
becomes a second name beside a real one. The pass returns at once on an image
without recovered classes. New fixture itaniumctors_wrap_{O2,O0sym}_x86_64.so.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…erging main Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
|
[AUTOMATED] Pushed 3 commits on top of e4e6a87: a merge of current main (the stage count in b754fdd narrows constructor naming. In optimized code, a helper that a constructor or destructor was inlined into stores the vptr through its first parameter exactly as Cases seen: a by-value factory, placement new, the constructor or destructor of a class whose first member is polymorphic, On an unstripped image, a recovered name could also be added beside the real symbol and become the primary name ( New fixture |
…y stores like one
Four shapes still drew a wrong name. A pure virtual destructor sits in no
vtable slot and stores its class's vptr through `this` at -O0, so it was
named `C::C`; a constructor of a class with a base calls the base
constructor before its own store, a destructor stores first. An
always_inline constructor inlined at -O0 reads `this` back from its
parameter's own frame slot, which is now not `this` unless a call follows
(the compiler's own spill across that call). At -O2 a COM-style `Release`
(`delete this` behind the count test) or a destroy-and-rebuild `reset` in
the class's vtable was named `C::~C`: a destructor's store must now come
before any call or conditional branch. A `delete this` method of a final
class has the deleting destructor's code, so a class with more than two such
slots, or two that are not neighbours, names none. New fixture
itaniumctors_impostor_{O0,O2}_x86_64.so with two e2e tests.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
[AUTOMATED] main gained the Itanium vfunc_ slot naming (Noelo-Lab#1607). Conflicts: the stage corpus count (now 768), the stages baseline (both sets of assertions kept), the itaniumrtti row in phases.toml (vfunc_ wording plus the constructor/destructor text), and the two files generated from it. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…d a D1/D0 pair
A virtual method that rebuilds `*this` by placement new stores its class's
vptr first, as a destructor does. Counting only the stores made before the
first call or branch named `Grow::reset` (destroy and rebuild, with a
polymorphic member whose vptr follows a call) and `Fill::reinit` as `~Grow`
and `~Fill`; the owner must now be the class both over every store and over
those first ones. A lone such slot (`reinit() { new (this) C(); }`,
`destroy() { delete this; }` with a non-virtual destructor) names nothing
unless the next slot calls it, as a deleting destructor does, or only traps,
as clang's deleting destructor of an abstract class does; two neighbouring
slots name nothing when the slot after them calls the second. An indirect call
through a constant counts as a call (AArch64 clang at -O0). New fixtures
itaniumctors_rebuild_{,clang_}O2_x86_64.so with an e2e test.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
A virtual method returning its own polymorphic class by value builds the
result in a return slot passed as its first parameter and reads `this` from
the second, so it stores the class's vptr first, as a destructor does:
`virtual Color darker() const` and its neighbour `brighter` were named
`Color::~Color`, at every -O1..-O3/-Os with g++ 11/15 and clang 14 on x86-64
and i386. A destructor takes only `this`, so a slot that loads or stores
through a second parameter, or returns `this` in a pointer return register
of its own (x86-64's RAX), is no longer destructor-shaped.
An optimized function returning a class by value can spill its return slot
across calls and store the vptr through the reloaded slot as unoptimized code
does: TagLib's `Ogg::Page::paginate` was named `List<Page*>::List`. An
unoptimized constructor calls nothing before its vptr store but its bases'
constructors, each passed `this`, so a store preceded only by other calls
names nothing.
New fixtures itaniumctors_byvalue_O2_{x86_64,i386}.so with two e2e tests.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Brings the fork up to upstream main a42c036: the option-catalog restructuring (Noelo-Lab#1522-Noelo-Lab#1532, 127 options made unconditional or folded into their parents), the library-friendly bootstrap (Noelo-Lab#1602, LoadOptions/Languages), the mmap'd image bytes (Noelo-Lab#1506), FID strict/evidence (Noelo-Lab#1547/Noelo-Lab#1549/Noelo-Lab#1550), FLIRT through the flirt-sig crate (Noelo-Lab#1548/Noelo-Lab#1564), the Itanium ctor/dtor naming (Noelo-Lab#1606/Noelo-Lab#1607), the MIPS relocation/$gp rework (Noelo-Lab#1520), Octeon atomics (Noelo-Lab#1516) and the rest. Conflict resolutions that are more than taking both sides: - fid/flirt: upstream's reviewed FID/FLIRT lineage replaces the fork's in-tree .sig reader and FID callee arbitration (`fidcallees`, `flirtsites` options dropped; FLIRT site checks are unconditional upstream). - `callothernoreturn` dropped: upstream's `brktrap` ends the flow at the compiler-trap immediates only, and keeps the resumable `brk`s. - `gortti` now defaults off: upstream's `gotypeglobals` (default on) names the same descriptors and itabs; both on named every address twice. - `calleeretpurge` no longer runs under a Windows cspec, where upstream's `calleepurge` reads the callee's purge (and settles the other calls first). - the prelinked-kernelcache peel declines upstream's mmap path, which has no owned bytes to rebase. - stage tests that upstream pinned under its defaults turn the fork's default-on options off where those change the output (alloca, repstring, itaniumeh, tailcontract); fork tests re-pinned to upstream's renderings (partial global reads, libcnames stack objects, relocatable-object symbol names, the one-case switch RuleSwitchSingle folds). Generated files re-derived: docs/options.md, phase_catalog.json, the catalog counts (305 options), the stage corpus count (875 files + 83 datatests), docs/baseline-stages.json (4958 assertions), and the AARCH64 slacomp digest over the merged AARCH64neon.sinc. docs/baseline.json is untouched (PARITY OK 675/675).
On a stripped GCC/Clang C++ ELF,
itaniumrttinames every class and virtual slot. Constructors are still left assub_<addr>, and destructors keep only their slot index.With this change:
Fix
C's vptr into the object it was called on is a constructor or destructor ofC. Candidates are the functions whose decoded operand names a vptr value. Each one is lifted to p-code and followed along its fall-through path, with the first parameter asthisand frame spills tracked. Only a store of the vptr throughthis + offcounts. At-O2, a factory that inlinesnew Cstores throughoperator new's result, so it keeps its own name.C's own vtable that stores the vptr isC::~C. The next slot is the deleting destructor, and it is named only when it calls that function, because at-O2the deleting destructor may be the only one that stores. A function in no vtable isC::C, but only whenCor a base has a virtual destructor. A non-virtual destructor stores the vptr exactly as a constructor does, so such a function is left alone.vtable_<i>,vfunc_<i>, the names the function inventory already ranks as structural), it replaces that name. This is how~Creaches call sites.itaniumrttioption. Without the Listing, nothing changes.Tests
tests/stages/kuna-itaniumctors.xml: with the option off, the calls aresub_names. With it on, they are named. A class without a virtual destructor and an inlining-O2factory stay unnamed.verify_itaniumctorsadds an end-to-end test, and there are unit tests for the ownership rule. New fixtures:itaniumctors_O{0,2}_x86_64.so(with source).libicuuc.so.74(142 of 142 of the right kind). These counts were taken before constructor naming was narrowed to unoptimized code; see this comment for what changed and why.decompile-allon the in-repo C++ fixtures changes only names. Load time with the Listing goes up 1.5–1.9% (libicuuc, libapt-pkg).🤖 Generated with Claude Code