Skip to content

Instantly share code, notes, and snippets.

@ALSchwalm
Last active February 2, 2024 01:39
Show Gist options
  • Save ALSchwalm/05dd2e3b56c29105680f to your computer and use it in GitHub Desktop.
Save ALSchwalm/05dd2e3b56c29105680f to your computer and use it in GitHub Desktop.
Proof of concept that llvm bytecode can be used as an intermediary to compile many languages using movfuscator
# Compile c++ to llvm bytecode
clang++ -S -emit-llvm -o bytecode.ll $1
# Convert bytecode to C
llc -march=c -o code.c bytecode.ll
# 'fix' static inline. This is a workaround for a bug
# in one of the parsers, I think.
sed -i 's/static inline.*//' code.c
# hack
sed -i 's/extern unsigned char \*__dso_handle;/unsigned char \*__dso_handle=0;/' code.c
# Compile the resulting C as usual (but with the c++ stdlib)
movcc code.c -lstdc++
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment