Skip to content

[AUTOMATED] Seed library prototypes for untyped ELF code imports - #1069

Merged
mahaloz merged 4 commits into
Noelo-Lab:mainfrom
thotypous:fix/notype-import-prototypes
Oct 14, 2026
Merged

mahaloz merged 4 commits into
Noelo-Lab:mainfrom
thotypous:fix/notype-import-prototypes

Conversation

@thotypous

Copy link
Copy Markdown
Contributor

Known library calls in ELF relocatable objects lose their standard prototypes when imports have the usual STT_NOTYPE metadata. This wrapper consequently loses its pointer parameter and return type:

cat > /tmp/clear.c <<'C'
extern void *memset(void *, int, unsigned int);
void *clear(void *p) { return memset(p, 0, 168); }
C
clang --target=sparc-linux-gnu -O0 -fno-builtin -c /tmp/clear.c -o /tmp/clear.o
kuna decompile /tmp/clear.o clear

Current output:

unsigned int clear(unsigned int a0)
{
  return memset(a0,0,0xa8);
}

Fixed output:

void * clear(void *a0)
{
  return memset(a0,0,0xa8);
}
  • Reuse the loader's proven ELF code imports for existing library signatures, including exact synthetic call-target addresses.
  • Preserve linked-image matching and import/definition ambiguity checks; exclude data-only references.
  • Keep existing signature options: this repairs missing authoritative prototype metadata, with no new argument-inference policy.

Generated ELF tests cover SPARC32/x86-64 pointer parameters and returns, real x86 addend −4, text-section data-address relocations and versioned name collisions. ELF loader behavior needs an object-based console test; XML stages do not reach this path.

Compiler-built controls: 12 corrected calls across six ABI variants; all 32 data-address controls unchanged. Matched development builds: median CPU +0.93% over five alternating runs (12 functions per run).

Debian linked-ELF controls: 10,133 matching successful functions from 48 executables on 12 architectures; 20 matching errors excluded, no stable output changes.

thotypous and others added 4 commits October 13, 2026 20:37
Reuse proven ELF code imports and exact synthetic addresses in existing library prototype passes while preserving linked-image matching and ambiguity guards. Cover generated SPARC32/x86-64 imports, data-address negatives, and known/undeclared floating and status-return contracts.
…idence

The libproto, libcsigs and libctypes passes now also type a relocatable
object's proven external code targets. Turning the three off restores the
previous output on such objects; the chapter says so, and records the
neighbouring-call cascades the new typing can expose.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015sdZpNU5odw5dVyaxeSvvz
@mahaloz mahaloz added the full-ci Run the full cargo workspace suite on this PR before merge (internal PRs skip it by default) label Oct 14, 2026
@mahaloz
mahaloz merged commit 4aac7a2 into Noelo-Lab:main Oct 14, 2026
2 of 4 checks passed
@mahaloz

mahaloz commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

[AUTOMATED] Before merging we added one commit on top (ae476d3) that only edits the spec text in docs/spec/01-program-prep.md. The code is unchanged.

The new relocatable-object evidence has no option of its own. The existing libproto, libcsigs and libctypes options cover it: with all three off, an object decompiles exactly as before. We checked this on 32 Lua 5.3 objects for x86-64, i386, AArch64 and ARMv7 at O0 and O2.

The chapter now also notes a known side effect. Once one callee is typed, the argument inference of an untyped call next to it can shift:

  • On i386 at -O0, stale outgoing stack slots get passed along: mkstemp64(v3) becomes mkstemp64(v3,0x400a6f,0x400a6f).
  • On AArch64, the x8 result register can show up as a leading 0 argument.
  • In i386 PIC objects, GOTOFF addresses the loader leaves unresolved now print as string literals once the parameter is char *.

These issues already exist in the argument inference and the loader, and we are tracking them separately.

@thotypous
thotypous deleted the fix/notype-import-prototypes branch October 14, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Run the full cargo workspace suite on this PR before merge (internal PRs skip it by default)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants