Skip to content

Analysis-tier: Go pclntab function-name recovery (GolangSymbolAnalyzer) - #33

Closed
mahaloz wants to merge 1 commit into
mainfrom
go-pclntab
Closed

mahaloz wants to merge 1 commit into
mainfrom
go-pclntab

Conversation

@mahaloz

@mahaloz mahaloz commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Port the name-recovery half of Ghidra's GolangSymbolAnalyzer. A new AnalysisPass (s1_pclntab::GoPclntabPass, id gopclntab, default-ON, Go-gated) that, when the binary is Go, locates and parses the embedded pclntab and emits a SymFact{Function} per Go function — so main.main / main.compute / runtime.* render NAMED instead of sub_. The pclntab survives stripping, so this works even on a -ldflags=-s -w binary that has no .symtab.

  • Locate: .gopclntab/gopclntab section -> runtime.pclntab symbol ->
    validated byte scan of .rodata/.data.rel.ro/.noptrdata/.data
    (GoPcHeader.getPcHeaderAddress + findPcHeaderAddress). Endianness via the
    LE-then-BE magic probe.
  • Parse all four magics: go1.2 0xfffffffb (legacy direct-functab), go1.16 0xfffffffa (absolute entry), go1.18 0xfffffff0 / go1.20 0xfffffff1 (32-bit PC-relative entryoff from textStart). Byte layouts from Ghidra's GoPcHeader/GoModuledata/GoFunctabEntry/GoFuncData, cross-checked against the Go runtime source at go1.18. Inline sentinels + go:buildid names skipped. Defensive: any malformation => empty output, never panic.
  • Gate: registered in passes_for only for Compiler::Go (the same .go.buildinfo gate the Go no-return list uses, Increment 15), so non-Go binaries are structurally unaffected. Reuses the EXISTING symbol commit arm (idempotent: a real .symtab name still wins). Settable --option gopclntab on|off (stages.toml + KUNA_OPTION_NAMES + architecture flag + engine analysis_pass_enabled + kuna_live_value), default-on. settable_count 36 -> 37; catalog fixture + docs/assertions.md regenerated; count fixtures updated.

Tests (both ran, not skipped): 12 hermetic parser units (no go — the merge gate: go1.18/1.16/1.2 decode, LE+BE, malformation/defensiveness) + a real-Go e2e (verify_go_pclntab.rs) that go build -ldflags=-s -ws a compute()-calls-main() program at runtime (hermetic, skips if no go) and asserts main.main/main.compute/runtime.main are recovered as NAMED on the STRIPPED binary, and that --option gopclntab off suppresses it.

Gates: make test 675/675 PARITY OK; make test-stages 159/159 PARITY OK; make rust-test green; kuna catalog --check OK. golang-symbols reclassified ⛔->✅ in docs/analysis-port-log.md (Increment 34). No divergence to the parity oracles (Go-gated, real-ELF-path-only).

Claude-Session: https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb

Port the name-recovery half of Ghidra's GolangSymbolAnalyzer. A new
AnalysisPass (s1_pclntab::GoPclntabPass, id `gopclntab`, default-ON,
Go-gated) that, when the binary is Go, locates and parses the embedded
pclntab and emits a SymFact{Function} per Go function — so main.main /
main.compute / runtime.* render NAMED instead of sub_<addr>. The pclntab
survives stripping, so this works even on a `-ldflags=-s -w` binary that
has no .symtab.

- Locate: .gopclntab/gopclntab section -> runtime.pclntab symbol ->
  validated byte scan of .rodata/.data.rel.ro/.noptrdata/.data
  (GoPcHeader.getPcHeaderAddress + findPcHeaderAddress). Endianness via the
  LE-then-BE magic probe.
- Parse all four magics: go1.2 0xfffffffb (legacy direct-functab), go1.16
  0xfffffffa (absolute entry), go1.18 0xfffffff0 / go1.20 0xfffffff1
  (32-bit PC-relative entryoff from textStart). Byte layouts from Ghidra's
  GoPcHeader/GoModuledata/GoFunctabEntry/GoFuncData, cross-checked against
  the Go runtime source at go1.18. Inline sentinels + go:buildid names
  skipped. Defensive: any malformation => empty output, never panic.
- Gate: registered in passes_for only for Compiler::Go (the same
  .go.buildinfo gate the Go no-return list uses, Increment 15), so non-Go
  binaries are structurally unaffected. Reuses the EXISTING symbol commit
  arm (idempotent: a real .symtab name still wins). Settable
  `--option gopclntab on|off` (stages.toml + KUNA_OPTION_NAMES +
  architecture flag + engine analysis_pass_enabled + kuna_live_value),
  default-on. settable_count 36 -> 37; catalog fixture + docs/assertions.md
  regenerated; count fixtures updated.

Tests (both ran, not skipped): 12 hermetic parser units (no `go` — the
merge gate: go1.18/1.16/1.2 decode, LE+BE, malformation/defensiveness) +
a real-Go e2e (verify_go_pclntab.rs) that `go build -ldflags=-s -w`s a
compute()-calls-main() program at runtime (hermetic, skips if no `go`) and
asserts main.main/main.compute/runtime.main are recovered as NAMED on the
STRIPPED binary, and that `--option gopclntab off` suppresses it.

Gates: make test 675/675 PARITY OK; make test-stages 159/159 PARITY OK;
make rust-test green; kuna catalog --check OK. golang-symbols reclassified
⛔->✅ in docs/analysis-port-log.md (Increment 34). No divergence to the
parity oracles (Go-gated, real-ELF-path-only).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb
@mahaloz

mahaloz commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

APPROVE

@mahaloz

mahaloz commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #31 ("Analysis-tier: Go pclntab function-name recovery"), which was merged into main on 2026-06-25. This branch is a duplicate of that work: its commit fb1654c is already upstream by patch-id (git cherry reports it as applied), the s1_pclntab/ files are byte-identical to main, and rebasing this branch onto main drops the commit and yields an empty diff — nothing left to merge. The gopclntab pass + option are live in main. (The "CONFLICTING" status was only because the branch was ~66 commits stale.)

@mahaloz mahaloz closed this Jun 26, 2026
@mahaloz
mahaloz deleted the go-pclntab branch July 29, 2026 08:01
mahaloz added a commit that referenced this pull request Oct 2, 2026
…ad, before a call

Adds e_bcall (call on a branch), e_lcall (after a loop of loads) and e_arg
(the call takes the global's old value) to storealias_x86_64.c, rebuilds the
three fixtures (SHAs in the README), round-trips them in store_alias.rs and
adds stage assertions #33-#38.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz added a commit that referenced this pull request Oct 2, 2026
…ad, before a call

Adds e_bcall (call on a branch), e_lcall (after a loop of loads) and e_arg
(the call takes the global's old value) to storealias_x86_64.c, rebuilds the
three fixtures (SHAs in the README), round-trips them in store_alias.rs and
adds stage assertions #33-#38.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012UUBmGqZTcD5N8LxpVsiQt
mahaloz added a commit to borancar/kuna that referenced this pull request Nov 14, 2026
mahaloz added a commit to borancar/kuna that referenced this pull request Nov 14, 2026
…ocal head

The fork's merge of origin/main (034a042) carries no code beyond the PR
commit and the same Noelo-Lab#33-Noelo-Lab#35 renumbering already on this head; every
conflict resolves to this head's content.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
mahaloz added a commit to borancar/kuna that referenced this pull request Nov 14, 2026
…oelo-Lab#1581

docs/baseline-stages.json is synthesized with mergebaseline.py (main's
keys plus the five CALLEEARGS Noelo-Lab#33-Noelo-Lab#37 this branch adds); every other file
merged without conflict.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
mahaloz added a commit that referenced this pull request Nov 24, 2026
…ized body

[AUTOMATED] An unplaced store forgets only the regions of its address's
coefficient-1 variable bases (havoc_store), or only mutable image memory
when it has none. A store whose address depends on the entry stack pointer
or on another variable whose region the state holds, without that variable
being a forgotten base, therefore left that memory as it was: the
exploration kept reading the value from before the store and the emitter
folded it into the program. Such a store is now marked lost
(Emulator::reaches_kept, AccessRecord::lost); the emitter records the
overlay address of each live instruction whose lost store it kept
(EmitStats::lost_stores), and warn_lost_stores, run with the other
post-decompile checks, counts those a basic block of the final function
covers: "pushan: incomplete: N stores through an address the emulation
could not place on a path of the body". No option.

The block decides, not the store op: when the stale read is folded to a
constant the decompiler removes the store as dead and the body is false
with no trace of it. Fixture f_cell before the merge fix prints
`return 1;` (the program returns 2); a count of surviving store ops stays
silent there, the block count reports 1. Code the decompiler removed counts
nothing. Unplaced loads are not counted: their unknown is never folded, so
the overlay keeps the program's own load.

48 rows (default, with the merge fix): the warning appears on curl (22),
huffman (30), cairuh (1), blaster (7) and smt_no_solve (4) themida, all
already warned, and on blaster_dolphin_themida (1: a store over the frame
pointer and a merged 0/1 context flag); on none of the 24 rows classed
SAME and none of the Tigress 30 subset; C unchanged on all 48. Without the
merge fix it fires on zlib_themida (6). Fixture f_lost (stage #33): a store
at &v ^ (a0 & 8); #19 counts it. Stage baseline 5049. Spec 02 2.11 (havoc
paragraph, header warnings, fixture list).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant