* feat(native): recover ELF function ranges from unwind tables inspect_elf_unwind_ranges and inspect-elf-unwind-ranges read .eh_frame and .eh_frame_hdr from one local ELF32 or ELF64 image and list the function ranges its FDEs name, with CIE facts, LSDA and personality, the containing section and an exact symbol where one starts at the address. Nothing is executed and no disassembler is needed. Pointer encodings follow the DW_EH_PE rules with raw zero as null, discarded FDEs are counted and skipped, the .eh_frame_hdr search table is compared with the decoded FDEs, and record, row and symbol budgets are bounded. verify:elf:unwind-ranges compares the reported starts with llvm-dwarfdump or readelf on a compiled C++ program. * fix(elf): keep unresolved unwind facts out of reported ranges Skip FDEs whose initial location is indirect and do not locate .eh_frame through an indirect eh_frame_ptr, since pointer slots are not functions. Stop an unbounded header-located scan at a CIE with an unrecognized augmentation, report ignored duplicate PT_GNU_EH_FRAME headers as incomplete coverage, and accept a null personality stored under an indirect encoding. Keep only symbols at decoded FDE starts, cache name observations per string-table offset, and decode names only for the returned page under a fixed 16 MiB text allowance, so repeated or long names no longer grow memory with the symbol count. * fix(scripts): run the ELF unwind verifier under owned process trees Launch probes, compiler drivers, the stripper, the frame dump and the inspection through createVerifierCommands, as verify-binary-hardening does, so a timeout or interrupt stops the whole tree. The temporary directory is removed only after the owned commands have closed. * docs(elf): move ELF unwind ranges guide under docs/guides/native The documentation guide assigns analyst workflows to docs/guides/<domain>/. Move the guide there, place its navigation and directory entries in the Native binaries group, and update links from the docs index, CLI guide, spec and authored skill. The public /elf-unwind-ranges route is unchanged. * fix(elf): give unwind text limits their own recovery and skip indirect tables Throw a dedicated failure when a page's symbol names exceed the 16 MiB text allowance, and map it to a resource error that tells the caller to request a smaller limit rather than raise max_ranges. Read a CIE augmentation with one bounded NUL search and keep it as a byte view, decoded only for returned CIEs, so a long augmentation is never built up character by character. Leave an .eh_frame_hdr search table with an indirect encoding unread: the header is incomplete, the comparison is unavailable, and the table no longer bounds a header-located .eh_frame scan. * fix(elf): resolve header count and table forms and name IFUNC resolvers Leave a non-zero .eh_frame_hdr FDE count under an indirect encoding unresolved, since it is the address of a slot that is not followed, and mark the header incomplete without reading the table. Treat a DW_EH_PE_omit table encoding as an omitted search table before testing the indirect bit, so a header that declares a count without a table stays present with complete coverage, and accept that form in output validation. Match STT_GNU_IFUNC symbols at exact FDE starts after function symbols, with a limitation that the name is the resolver, not the implementation it selects at run time. * fix(elf): require allocated unwind pointer bases * fix(elf): map unwind header relative base * fix(elf): validate unwind load mappings * test(elf): cover mapped nonallocated frame agreement --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
5.1 KiB
ELF unwind function ranges
Problem and outcome
A stripped ELF often has no symbol table, but its .eh_frame still names the
start and end of nearly every function so exceptions can unwind. REA can list
symbols and disassemble with a provider, but it cannot recover function
boundaries from unwind tables, so an agent without a disassembler has no
function list for a stripped binary.
This feature adds inspect_elf_unwind_ranges and
inspect-elf-unwind-ranges. They read .eh_frame and .eh_frame_hdr from one
selected local ELF32 or ELF64 image and list the function ranges those tables
name, without executing the image.
ELF unwind function ranges describes the current behavior and limitations. This directory is the feature specification, implementation plan and task list. The guide does not replace these files.
Requirements
.eh_framecomes from section headers, or fromPT_GNU_EH_FRAMEwhen section headers are missing. The source and examined file range are reported.SHT_NOBITS, out-of-file and truncated tables areincomplete. Program headers come from the shared section directory, which rejects an unreadable program-header table, so a missingPT_GNU_EH_FRAMEis observed absence. An.eh_framelocated only through the header'seh_frame_ptris read no further than the last FDE a decoded search table names. Without a usable table it stops at the first undecodable record, including a CIE with an unrecognized augmentation and its FDEs, or at the end of itsPT_LOADwithout a terminator, and coverage isincomplete.- CIEs report version, augmentation, alignment factors, return-address
register, pointer and LSDA encodings, personality, and signal-frame and
B-key flags. A page returns only the CIEs its ranges name, so CIE output is
bounded by
limit, andcoverage.total_ciescounts every decoded CIE. CFA programs are counted, not evaluated. A CIE with an unrecognized augmentation letter is not decoded, its FDEs are skipped with a counted limitation, and coverage isincomplete. - FDEs become ranges with start, end, size, containing
SHF_ALLOCsection, an exact symbol name when one starts at that address (a function, then anSTT_GNU_IFUNCresolver, then an untyped symbol), CIE index, LSDA and personality, paged byoffsetandlimit. - Encoded pointers follow the
DW_EH_PErules. A raw zero is a null pointer. Resolved addresses and FDE ends wrap at the ELF32 or ELF64 address width.datarelin.eh_frameresolves againstDT_PLTGOT, then.got.pltor.got, and an unresolved base leaves the record out with coverageincomplete. Indirect pointers are not dereferenced: an FDE with an indirect initial location is skipped with a counted limitation, and an indirecteh_frame_ptrdoes not locate.eh_frame, and a search table with an indirect encoding is neither compared nor used as a scan bound. Each leaves coverageincomplete. - A 64-bit extended length keeps the
.eh_frameCIE ID and pointer at 4 bytes. - An FDE with a zero initial location is a discarded function. It is counted as examined, not reported, and a limitation gives the count.
.eh_frame_hdris decoded and its search table compared with the decoded FDEs asagree,disagreeorunavailable. The table is read for at mostmax_rangesrows and no more rows than its bytes hold. A larger declared count makes the headerincompletewith a limitation. A declared count with an omitted table is apresentheader with comparisonunavailable. A non-zero indirect count is not followed, so the count is unknown and the headerincomplete..debug_framepresence is reported but not decoded.- Budgets bound the file size, CIE and FDE counts, page size and the symbol
lookup across
.symtaband.dynsym. Only symbols at decoded FDE starts are kept, names are decoded only for the returned page, and that text has a fixed 16 MiB allowance whose recovery is a smallerlimit. Only the firstPT_GNU_EH_FRAMEis read; a duplicate one that supplies the header makes coverageincomplete. Section and symbol lookups use indexes built once per image, so cost does not grow as sections times entries. Address translation usesSHF_ALLOCsections, thenPT_LOAD; a non-ALLOC section'ssh_addris never used. - Symbol names, section names and augmentation strings are marked target-derived and untrusted. MCP requires an absolute path.
Acceptance
- Unit tests cover CIE and FDE decoding for both widths and endiannesses, pointer encodings, extended lengths, zero pointers, discarded FDEs, header agreement and caps, and the GOT base.
- Service tests validate the report shape, including incomplete headers and null LSDAs.
- CLI acceptance, filesystem boundary and MCP boundary tests exercise the public contract.
npm run verify:elf:unwind-rangescompares the reported FDE starts withreadelforllvm-dwarfdumpon a compiled C++ program.
Non-goals
- Decoding
.debug_frameor evaluating CFA programs. - Applying relocations in relocatable objects.
- Following indirect EH pointers.