[Bug] Declare recovered internal functions before call sites
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 62/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- compilers, reverse-engineering
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- C++
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TiElixir/caraxes
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 12/100
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
bug good first issue
Difficulty 3/5 Half a day Newbie friendliness 68/100
All issues in TiElixir/caraxes
Similar issues
-
std::fdim drops partial derivative w.r.t second argument in forward and reverse modePossibly taken @ADITYASINGH1206 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
vgvassilev/clad#2534 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 3 days
-
HAP.cpp fixOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100