Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract function prototype from an ELF file?

I have been searching quite a lot, but haven't found a way to extract function prototype, atleast the argument types and return type from an ELF executable file. Using GNU BinUtils or any other method.

I have tried using different options in readelf, nm and objdump, they list the symbols and function names, but how to know a function's argument types and return type?

I have a gut feeling that there should be a way to do it, can anyone throw some light on this?

Host: Windows 7

Target: elf for PowerPC architecture

like image 654
Nithi89 Avatar asked Mar 22 '13 14:03

Nithi89


1 Answers

Assuming your binary was built with debug info, you can get function type, argument types, etc. etc. by reading DWARF debug format, which readelf -wi will dump.

If your binary was produced by IBM's compiler, it may have (older) STABS debug info instead, which you can dump with objdump -g.

If your binary does not have the debug info, then you can't get the info you are looking for -- it's just not there.

like image 163
Employed Russian Avatar answered Sep 24 '22 02:09

Employed Russian