[Bug] Emit compilable pointer and indirect-memory recovery

Aperta
#4 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
22/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c, cpp

Direzione di ricerca

Start with the memory-operand rendering in src/decompiler/decompiler.cpp (around lines 141-199) and the ABI argument declarations near lines 463-467, then run the reproducer through the strict flags -std=c11 -Wall -Wextra -Werror. Done means that compile succeeds, no undeclared memory[...] placeholder remains, and pointer arguments use compatible types. The fix needs a decision on how the recovery IR represents pointer types, so discuss the approach with maintainers before writing code.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Summary

Pointer arguments and indirect memory operands are emitted as an undeclared pseudo-array, while recovered parameters are always declared as int. A simple pointer dereference therefore produces source that cannot compile.

Evidence

src/decompiler/decompiler.cpp:141-199 renders non-stack/non-RIP memory operands as memory[...], but the project renderer does not declare a memory object. src/decompiler/decompiler.cpp:463-467 declares every inferred ABI argument as int.

Reproducer:

__attribute__((noinline)) int first(int *p) { return *p; }
int main(void) {
    int x = 42;
    return first(&x) == 42 ? 0 : 1;
}

The generated function includes output equivalent to:

static int first(int arg0) {
    rax = memory[local_0x8];
}

and the call site passes &local_0x4 to an int parameter. Strict compilation reports that memory is undeclared and that the pointer argument has an incompatible type.

Impact

Functions that read or write through pointers, access heap objects, or use register-relative memory cannot be represented as compilable recovered C. This is a common pattern outside the checked-in arithmetic sample.

Expected behavior

The recovery IR should distinguish pointer values from integers and render indirect memory as typed dereferences or as an explicitly declared byte-memory abstraction. Stack locals and function parameters should preserve enough type information to pass pointer values without incompatible conversions.

Acceptance criteria

  • The reproducer compiles with -std=c11 -Wall -Wextra -Werror.
  • No undeclared memory[...] placeholder remains in compilable output.
  • Pointer arguments and pointer-valued locals are emitted with compatible types.
  • Unsupported memory cases remain clearly annotated without generating misleading compilable expressions.
Lingua principale
C++
Stelle
0
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TiElixir/caraxes

Tutte le issue di TiElixir/caraxes

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.