pyelftools
pyelftools copied to clipboard
Is it possible to see what other functions a given function calls? With ARM or PowerPC architectures?
Given an ELF file, is it possible using elftools to create a graph of how the code is layed out? Say I have the following:
void bar1(void)
{
return;
}
void bar2(void)
{
bar1();
return;
}
void foo(void)
{
bar1();
bar2();
return;
}
Such that I can generate a graph where node foo has 2 children, bar1 and bar2. And then bar2 has 1 child, bar1. Then bar1 has no children since it does not call anything. I am essentially wondering is given a compile unit, for each function, can I get the list of what other functions that function calls? I know it is possible to infer this from raw text parsing the disassembly, but thats not the best way to do it.
This is CFG recovery, and afaik this is not what pyelftools does directly. You may use binary analysis tools to recover CFG on a given binary. Some examples of binary analysis tools are angr, Ghidra, Binary Ninja, IDA Pro, etc.