error while translating function with function pointer as parameter #784
Description
I`m testing the completeness of mcsema and I use the EEMBC benchmark(the Coremark in this case) to test it.
Till now I am still testing x86 to x86
the source code is available here https://github.com/eembc/coremark
while translating the function with function pointer as a function parameter:(cmp is a function pointer)
it seems that mcsema can`t handle it correctly.
when core_list_mergesort calls the cmp function, the ERROR LLVM IR generated by the mcsema-lift is as follows:
in the above picture, we can see the translated LLVM IR will pass the value of RSP in the State_strcuture to the child cmp function.
But when going into the child cmp function
as you can see in the above picture, the cmp function writes RSP to RSP+8, and RSP+8 to RSP+16, which changes the State_strcuture of its parent function. And when it comes back to core_list_mergesort, some important value has been changed, which causes the program to fail.
I want to know how to solve this problem, or which part of mcsema is critical to verify to solve this problem.
l use the clang11 -O0 to make the original source code ,and the translation process is as follows:
mcsema-disass-3.8 --disassembler "/opt/idapro-7.7/idat64" --arch amd64 --os linux --entrypoint main --binary /mcsema-llvm11-EEMBC_test/test/coremark_test2 --output /mcsema-llvm11-EEMBC_test/test/coremark_test2.cfg --log_file /mcsema-llvm11-EEMBC_test/test/coremark_test2.log
mcsema-lift-11.0 --arch amd64 --os linux --cfg /mcsema-llvm11-EEMBC_test/test/coremark_test2.cfg --output /mcsema-llvm11-EEMBC_test/test/coremark_test2.bc --explicit_args --merge_segments --name_lifted_sections