revng
revng copied to clipboard
`Exception: __libc_start_main` in translated hello world using glibc
I followed the tutorial for installation in https://rev.ng/blog/open-sourcing-renvg-decompiler-ui-closed-beta. After installation, in this site has an example that says:
OK, let's now decompile a simple program. Consider example.c:
int main(int argc, char *argv[]) { return argc * 3; }You can compile and decompile it:
$ gcc example.c -o example -O2 $ revng artifact \ --analyze \ --progress \ decompile-to-single-file \ example \ | revng ptml --color \ | grep -A2 -B1 '[^_]main\b' \ > decompiled.cYou should obtain:
_ABI(SystemV_x86_64) generic64_t main(generic64_t _argument0) { return _argument0 * 3 & 0xFFFFFFFF; }
I follow this, and there is no error, but my decompiled.c is:
_ABI(SystemV_x86_64)
[38;5;85mgeneric64_t[0m [91mmain[0m([38;5;85mgeneric64_t[0m [38;5;214m_argument0[0m) {
[38;5;33mreturn[0m [38;5;214m_argument0[0m [38;5;33m*[0m [38;5;87m3[0m [38;5;33m&[0m [38;5;87m0xFFFFFFFF[0m;
}
I'm sorry. I found the problem because I didn't follow the newest tutorial : https://docs.rev.ng/user-manual/analyses/. That works on the new tutorial site.
But I found another 2 problems.
- When I use
revng translate -o example.gen.out exampleand./example.gen.outit has error :
[orchestra] (base) bash-4.2$ ./example.gen.out
Exception: __libc_start_main ({ 0x0, 0x0, 0x0, 0x0 }
-> { 0x0, 0x0, 0x0, 0x0 }
)
Aborted (core dumped)
- Besides, when I try
revng lift example example.gen.lland/llvm-16.0.1/bin/clang example.gen.ll, it has lots of undefined error:
[orchestra] (base) bash-4.2$ llvm-16.0.1/bin/clang example.gen.ll
/opt/BinaryTranslation/bt-tools/revng/root/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/binutils-bin/2.39/ld: error: cannot open Scrt1.o: No such file or directory
/opt/BinaryTranslation/bt-tools/revng/root/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/binutils-bin/2.39/ld: error: cannot open crti.o: No such file or directory
/opt/BinaryTranslation/bt-tools/revng/root/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/binutils-bin/2.39/ld: error: cannot open crtbeginS.o: No such file or directory
/opt/BinaryTranslation/bt-tools/revng/root/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/binutils-bin/2.39/ld: error: cannot open crtendS.o: No such file or directory
/opt/BinaryTranslation/bt-tools/revng/root/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/binutils-bin/2.39/ld: error: cannot open crtn.o: No such file or directory
/opt/BinaryTranslation/bt-tools/revng/root/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/binutils-bin/2.39/ld: error: cannot find -lgcc
/opt/BinaryTranslation/bt-tools/revng/root/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/binutils-bin/2.39/ld: error: cannot find -lgcc_s
/opt/BinaryTranslation/bt-tools/revng/root/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/binutils-bin/2.39/ld: error: cannot find -lc
/opt/BinaryTranslation/bt-tools/revng/root/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/binutils-bin/2.39/ld: error: cannot find -lgcc
/opt/BinaryTranslation/bt-tools/revng/root/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/binutils-bin/2.39/ld: error: cannot find -lgcc_s
/tmp/quicksort-6e1460.o:null:function rcu_init: error: undefined reference to 'pthread_atfork'
/tmp/quicksort-6e1460.o:null:function qemu_mutex_init: error: undefined reference to 'pthread_mutex_init'
/tmp/quicksort-6e1460.o:null:function rcu_register_thread: error: undefined reference to '__assert_fail'
/tmp/quicksort-6e1460.o:null:function error_exit: error: undefined reference to 'stderr'
-
When I use revng translate -o example.gen.out example and ./example.gen.out it has error :
Please attach the binary you're translating. Please consider that we no longer focus that much on static binary translation, but simple examples should work.
-
Besides, when I try revng lift example example.gen.ll and /llvm-16.0.1/bin/clang example.gen.ll
You can't directly compile the output of lift. revng translate or revng artifact --analyze recompile is the right workflow.
For the first problem, I just translated the example from the tutorial. The source code is:
int main(int argc, char *argv[]) {
return argc * 3;
}
I think the translation result is correct, but I don't know what's wrong with my machine. If you haven't met this problem before, that's fine, I will try to figure it out by myself; thanks a lot.
Bug reports must always attach the binary, explaining how to rebuild the binary is problematic.
Please attach the binary.
OK here are the binaries. The example is I compile the source code by gcc example.c and theexample.gen.out is the rev.ng translated result. When I run example.gen.out it will cause Exception.
https://drive.google.com/drive/folders/1dLoAXYtwchly7k3tx18tW9TmRzSH_tXK?usp=sharing