[Bug] Declare recovered internal functions before call sites

Abierto
#2 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
62/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
c, cpp

Línea de trabajo

Start with the function emission loop in src/decompiler/project.cpp (lines 316-337) and the call emission in src/decompiler/decompiler.cpp (lines 558-590), then check how analysis.functions is used to name callees. Save the issue's reproducer as C, decompile it, and compile the output with gcc -std=c11 -Wall -Wextra -Werror to see the implicit-declaration error. Done means the reproducer compiles cleanly, and forward and mutually recursive calls also compile with matching prototypes and static linkage.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

Summary

Generated C-like output calls recovered internal functions before declaring them. When a caller is located before its callee in the binary, the generated source fails under C11 with -Werror.

Evidence

src/decompiler/project.cpp:316-337 emits recovered function definitions in analysis/address order, while src/decompiler/decompiler.cpp:558-590 emits calls using the recovered callee name. No forward declarations are emitted for functions in analysis.functions.

Reproducer:

int callee(int);
__attribute__((noinline)) int caller(int x) { return callee(x); }
__attribute__((noinline)) int callee(int x) { return x; }
int main(void) { return caller(0); }

After compiling at -O0 -g, decompiling, and compiling the recovered source with gcc -std=c11 -Wall -Wextra -Werror, GCC reports:

error: implicit declaration of function ‘callee’
error: static declaration of ‘callee’ follows non-static declaration

Impact

Whether recovered output compiles depends on the link/order layout of functions. Forward calls, mutually recursive functions, and some stripped binaries fail even when the underlying recovered call is otherwise representable.

Expected behavior

The renderer should emit a consistent prototype for every recovered internal function before any function body, or otherwise order declarations safely while preserving recursion and the static linkage used by generated definitions.

Acceptance criteria

  • The reproducer compiles with -std=c11 -Wall -Wextra -Werror.
  • Forward calls and recursive/mutually recursive calls do not produce implicit-declaration or linkage-conflict diagnostics.
  • Prototypes use the same generated identifiers and compatible parameter/return types as their definitions.
Lenguaje dominante
C++
Estrellas
0
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TiElixir/caraxes

Todos los issues de TiElixir/caraxes

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.