HexHive / HexHive/retrowrite

[BUG] cannot use retrowrite with binary compiled with gcc or g++

Open
#34 0 comments 0 reactions 0 assignees View on GitHub
analysis-needed bug
Dominant language
Python
Stars
750
Forks
87
PR merge metrics
No merged PRs in 30d

Description

**Description**
retrowrite print no issue when runned on binary compiled with gcc but when I try to assemble the generated assembly with gcc I get this error:
```
/usr/bin/ld:hello.asm: file format not recognized; treating as linker script
/usr/bin/ld:hello.asm:1: syntax error
collect2: error: ld returned 1 exit status
```

**Environment:**

OS: 5.14.21-2-MANJARO x86_64 GNU/Linux
GCC: gcc (GCC) 11.2.0
clang:13.0.1
retrowrite at commit: 7c230bc

I tried with a simple hello world program:
```
#include
#include

int main(int argc, char *argv[])
{
printf("Hello, World!\n");

return 0;
}
```
And compile it with gcc: ```gcc -O0 -ggdb -Wall -Wpedantic -Wextra -fPIC -fPIE -pie hello.c -o hello ```
then ```./retrowrite hello hello.asm```
``` gcc hello.asm -o hello_instrumented``` => error
note that ``` clang hello.asm -o hello_instrumented``` seems to work on some files

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the issue with hello.c, the reported GCC command, and retrowrite hello hello.asm. Compare the behavior of gcc hello.asm and clang hello.asm, then trace the retrowrite command's generated hello.asm output. Done means GCC and G++ can assemble and link the generated assembly for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
compilers, reverse-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.