After a program is compiled and the binary file is generated, we can use objdump to disassemble the binary file and extract the assembly code and a lot of information.
However, using -j .text with objdump, it will disassembly the whole functions (glibc, OS functions, etc ... ) that I do not want.
I want to focus only on my own functions in the binary file. Using nm, it is possible to find only the user defined functions. After extracting the name of these functions, I want to disassembly only these functions. However, I do not want to search in the hug dump file that objdump generates it and extract disassembly code that related to my functions.
Assuming we have the binary file for basicmath program from MiBench benchmark.
using nm, it is possible to find only the functions that are defined in the source code of this program.
The command below will show the functions that I want (the user-defined functions)
nm -P tst.o | awk '$2 == "T" && $1 != "main" {print "b " $1}'
The result will be (considering basicmath program)
b deg2rad
b rad2deg
b solveCubic
b usqrt
Now, I need a way to tell objdump to disassembly only these functions and write the result to a single file.