upenn-acg/ocolos-public

extrac_call_sites does not work

xianzheliu opened this issue · 6 comments

I have built this target binary, but when I use it to generate call_sites_all.bin file ,it always get nothing. I saw the standard output get the call site infomation, but it didn't write into this file. That made me so confused. The standard output looks like this.

....
00000000042996b0 0000000000000030 B _ZN53protobuf_replication_asynchronous_connection_failover33_VariableStatus_default_instance_E

00000000042996e0 0000000000000040 B _ZN53protobuf_replication_asynchronous_connection_failover37_VariableStatusList_default_instance_E

0000000004299720 0000000000000080 B _ZN53protobuf_replication_asynchronous_connection_failover48_SourceAndManagedAndStatusList_default_instance_E

[extract_call_sites] 61186 functions in the original binary
the size of call_sites = 0
the size of call_sites = 0
the size of call_sites = 0
the size of call_sites = 0
the size of call_sites = 0
the size of call_sites = 0
the size of call_sites = 0
the size of call_sites = 0
the size of call_sites = 0
the size of call_sites = 0
the size of call_sites = 0
the size of call_sites = 0
the size of call_sites = 0
the size of call_sites = 0
the size of call_sites = 0
the size of call_sites = 0
@@@@@@@@@@@@ the size of call_sites (final) = 0
########### the size of call_sites_list = 0

Who can tell why? Thanks

Thanks for posting this issue.

The fast solution is to change https://github.com/upenn-acg/ocolos-public/blob/main/src/extract_call_sites.cpp#L50 's call into callq.

The function calls on your machine are translated into callq instead of call. However, on our machine, direct function calls are only translated into call instructions. So we didn't handle the callq case.

I don't know whether it will have other impacts if you merely change call into callq in extract_call_sites.cpp, since in our original implementation, we only handle the case of decoding call instructions and update the function pointers of these call instructions. I will check it later and update the code to make it fully support both call and callq instructions.

Actually there is no need to change the source code. What you need to do is to compile MySQL from source again by gcc instead of clang. After the mysqld binary being compiled by gcc, all callq will be replaced by call.

I updated the instruction about how to build MySQL by gcc here. This time you also need to add -no-pie flag to the CMakeList.txt of MySQL.

Actually there is no need to change the source code. What you need to do is to compile MySQL from source again by gcc instead of clang. After the mysqld binary being compiled by gcc, all callq will be replaced by call.

I updated the instruction about how to build MySQL by gcc here. This time you also need to add -no-pie flag to the CMakeList.txt of MySQL.

Sorry ,I don't know which version of GCC do you use. I tried gcc 8.4.0 and gcc 9.4.0, but neither of them worked. The objdump result are still callq. So the extract_call_sites is still not work.

The gcc version I used is 8.30 and 9.40.

Did you delete the build directory under mysql-server directory and create a new build directory again? Sometimes CMake will cache some of its configurations, so I suggest you to build MySQL from the very beginning. Also, please don't forget to add -no-pie flag to the CMakeList.txt.

Another solution is, you can change https://github.com/upenn-acg/ocolos-public/blob/main/src/extract_call_sites.cpp#L50 's call into callq.

Yep, I did delete the build directory and rebuild it again. But still generate the callq inst. But I find a good solution https://stackoverflow.com/questions/46752964/what-is-callq-instruction.
Hope this will be helpful to others.

Thank you for this information.
I also updated your solution to the readme.md.