retrowrite
retrowrite copied to clipboard
C++ Support: Can't rebuild output of retrowrite on g++ Hello World
Background
- x86_64
- Linux 5.11.11
- Arch Linux
- GCC 10.2.0
- Retrowrite at commit 9e2e633e9ab165681733f3255e648a62b22e6368
Input file
hello.cpp
#include <iostream>
int main() {
std::cout << "Hello, world!" << std::endl;
}
Repro
-
g++ -pie -o hello hello.cpp
-
./retro/bin/retrowrite hello hello.s
noting output:
[*] Relocations for a section that's not loaded: .rela.dyn [*] Relocations for a section that's not loaded: .rela.plt [x] Could not replace value in .init_array [x] Couldn't find valid section 3db0 [x] Couldn't find valid section 3fc8 [x] Couldn't find valid section 3fd0 [x] Couldn't find valid section 3fd8 [x] Couldn't find valid section 3fe0 [x] Couldn't find valid section 3fe8 [x] Couldn't find valid section 3ff0 [x] Couldn't find valid section 3ff8
-
g++ hello.s
fails with output:
hello.s: Assembler messages: hello.s:76: Error: unrecognized symbol type "GLIBCXX_3.4_4080" hello.s:76: Error: junk at end of line, first unrecognized character is `,' hello.s:77: Error: junk at end of line, first unrecognized character is `@' hello.s:78: Error: invalid character '@' in mnemonic
It looks like it has generated some syntax that as
doesn't like. Cleaning that up (not sure of the consequences but I just removed it), it then fails on an undefined label:
$ g++ hello.s
/usr/bin/ld: /tmp/ccaM02YR.o:(.init_array+0x0): undefined reference to `.LC1160'
collect2: error: ld returned 1 exit status
.LC1160
seems to be necessary for something (otherwise the program segfaults at startup), but I can't tell what it needs to point to.
Hi, thanks for your report.
The problem here is that you are using C++ - and at the moment retrowrite doesn't support it (we support well behaved (i.e. compiled with a compiler) C PIE binaries and shared libraries and kernel modules at the moment). However, we are working on C++ support. I can't give an ETA publicly for when this will be released, but we'd like to do it as soon as we can :)
I'll leave this open and we'll post back once we have working C++ support you can use.