Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ Support: Can't rebuild output of retrowrite on g++ Hello World #26

Open
ScoreUnder opened this issue May 6, 2021 · 1 comment
Open
Assignees
Labels
enhancement New feature or request

Comments

@ScoreUnder
Copy link

ScoreUnder commented May 6, 2021

Background

  • x86_64
  • Linux 5.11.11
  • Arch Linux
  • GCC 10.2.0
  • Retrowrite at commit 9e2e633

Input file

hello.cpp

#include <iostream>

int main() {
    std::cout << "Hello, world!" << std::endl;
}

Repro

  1. g++ -pie -o hello hello.cpp

  2. ./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
    
  3. 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.

@diagprov diagprov self-assigned this Jul 16, 2021
@diagprov
Copy link
Contributor

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.

@diagprov diagprov changed the title Can't rebuild output of retrowrite on g++ Hello World C++ Support: Can't rebuild output of retrowrite on g++ Hello World Jul 16, 2021
@diagprov diagprov added the enhancement New feature or request label Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants