Last active
February 2, 2024 01:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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