How to generate a call graph in Elf?

How to generate a call graph in Elf?

Generate a CFG: cfg = p.analyses.CFG (show_progressbar=True). Access/traverse the call graph (which is a networkx.DiGraph) in whatever way you want: cfg.functions.callgraph. You can limit the range of CFG generation by passing the regions argument to CFG ().

What does shstrtab stand for in ELF file?

For the first question, we would need the hexedit of the elf file to understand properly. For the second question – strtab stands for String Table shstrtab stands for Section Header String table. When we read ELF header, we see that every ElfHeader structure contains a member called e_shstrndx. This is an index to the shstrtab.

Which is the string table in Elf Stack Overflow?

If you use this index and then read from shstrtab you can find the name of that section. strtab, is the string table for all other references. When you read symbols from an ELF object, every SYmbol structure (Elf32_Sym) has a member called st_name. This is an index into strtab to get the string name of that symbol.

What do the headers of an elf file contain?

The ELF File Header also contains the number of Program Headers and the number of Section Headers. Each Program Header describes a “segment”: It contains the permissions (Readable, Writeable, or Executable) , offset of the “segment” (which is just a byte stream) into the file, and the size of the “segment”.

How to generate the call graph of a binary file?

The free version of IDA is also capable of generate GDL of call graph but it is only available as exe, use wine on Linux to run it You might want to give angr a try. Load the binary. Suppose p is the angr Project instance. Generate a CFG: cfg = p.analyses.CFG (show_progressbar=True).

How to generate call graph in DOT format?

You can use radare2 or one of the alternatives below to generate a full call-graph in dot format. After you’ve downloaded and installed radare2, open your binary and perform analysis on it using the aaa command: