My goal is to modify some instructions and make some instrumentation in ELF executables or libraries(For example, modifying all memory writes instructions). Since there're so many instructions, I want to find them automatically and apply some modification. Are there any tools that I can leverage?
Are there any static binary rewriting tools
binary analysis;static analysis;instrumentation;binary rewriting
I just extracted the following list during my research of this paper:Reassembleable Disassembling Shuai Wang, Pei Wang, and Dinghao Wu,  The Pennsylvania State UniversityThe following list consits of all mentioned tools (dynamic and static), perhaps there is something useful:UROBOROS (Static, x86/x64 ELF)So the paper itself introduces UROBOROS. I think it's one of the best options for you:https://github.com/s3team/uroborosReassembleable Disassembling Shuai Wang, Pei Wang, and Dinghao Wu,  The Pennsylvania State UniversityIn this paper, we present UROBOROS, a tool that can disassemble  executables to the extent that the gener- ated code can be assembled  back to working binaries without manual effort. [...] We have implemented a prototype of UROBOROS in OCaml and Python, with  a total of 13,209 lines of code. Our prototype works for both x86 and  x64 ELF binaries. [...] We have presented UROBOROS, a tool that can disassem- ble stripped  binaries and produce reassembleable assem- bly code in a fully  automated manner. We call this tech- nique reassembleable  disassembling and have developed a prototype called UROBOROS. Our  experiments show that reassembled programs incur negligible execution  overhead, and thus UROBOROS can be potentially used as a foundation  for binary-based software retrofitting.Dyninst [10, 20] (Static+Dynamic)BUCK, B., AND HOLLINGSWORTH, J. K. An API for runtime code patching.  Int. J. High Perform. Comput. Appl. 14, 4 (2000), 317329.Vulcan [16] (Static, binaries compiled by special compilers, not stripped)EDWARDS, A., VO, H., SRIVASTAVA, A., AND SRIVASTAVA, A. Vulcan binary  transformation in a distributed environment. Tech. Rep.  MSR-TR-2001-50, Microsoft Research, 2001.Alto [35] (Static, binaries compiled by special compilers, not stripped)MUTH, R., DEBRAY, S. K., WATTERSON, S., AND DE BOSS- CHERE, K. Alto: A  link-time optimizer for the Compaq Alpha. Softw. Pract. Exper. 31, 1  (2001), 67101.Diablo [13] (Static, binaries compiled by special compilers, not stripped)DE SUTTER, B., DE BUS, B., AND DE BOSSCHERE, K. Link- time binary  rewriting techniques for program compaction. ACM Trans. Program. Lang.  Syst. 27, 5 (2005), 882945.SecondWrite [3] (Static)ANAND, K., SMITHSON, M., ELWAZEER, K., KOTHA, A., GRUEN, J., GILES,  N., AND BARUA, R. A compiler-level inter- mediate representation based  binary analysis and rewriting sys- tem. In Proceedings of the 8th ACM  European Conference on Computer Systems (2013), ACM, pp. 295308.Pin [31] (Dynamic)LUK, C.-K., COHN, R., MUTH, R., PATIL, H., KLAUSER, A., LOWNEY, G.,  WALLACE, S., REDDI, V. J., AND HAZELWOOD, K. Pin: Building customized  program analysis tools with dy- namic instrumentation. In Proceedings  of the 2005 ACM SIG- PLAN Conference on Programming Language Design  and Im- plementation (2005), ACM, pp. 190200.DynamoRIO [7] (Dynamic)BRUENING, D. L. Efficient, transparent, and comprehensive runtime code  manipulation. PhD thesis, Massachusetts Institute of Technology, 2004.miasm2Miasm is a free and open source (GPLv2) reverse engineering framework.  Miasm aims to analyze / modify / generate binary programs.  https://github.com/cea-sec/miasmVxStripper (dynamic)Josse, Sbastien. Malware Dynamic Recompilation. System Sciences  (HICSS), 2014 47th Hawaii International Conference on. IEEE, 2014.