pyelftools icon indicating copy to clipboard operation
pyelftools copied to clipboard

Is it possible to see what other functions a given function calls? With ARM or PowerPC architectures?

Open ArjunNarayan2066 opened this issue 5 years ago • 1 comments

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.

ArjunNarayan2066 avatar Jul 04 '20 21:07 ArjunNarayan2066

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.

ltfish avatar Jul 05 '20 12:07 ltfish