This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: using libbfd for reading procedure information and hidden data in the text segment
- From: Ravi Ramaseshan <ramaseshan dot ravi at gmail dot com>
- To: Kugan Vivekanandarajah <kuganv at gmail dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Tue, 5 Jul 2005 14:26:18 +0530
- Subject: Re: using libbfd for reading procedure information and hidden data in the text segment
- References: <4217037d05070423044d787a85@mail.gmail.com>
- Reply-to: Ravi Ramaseshan <ramaseshan dot ravi at gmail dot com>
Hi,
On 7/5/05, Kugan Vivekanandarajah <kuganv@gmail.com> wrote:
> For my research, I need to construct control flow graph (CFG) from the
> executable; separately for each procedure in the executable
> (executable is compiled with gcc and I can compile the code with all
> the necessary compilation switches).
>
> I am using libbfd for reading the code sections and the symbols. Is
> there any way I can do the following with the information provided by
> the libbfd.
For my undergraduate project LIZARD (lizard.sourceforge.net/) we too
needed to build the CFG from a GCC compiled ELF executable. I wrote a
small script which used the output of readelf and objdump to build the
CFG. You could probably do your CFG-building in the same way.
On 7/5/05, Kugan Vivekanandarajah <kuganv@gmail.com> wrote:
> 1. By reading the symbol information can I tell whether it is a
> function or not. That is, can I find out the procedures and its
> starting and end addresses.
Readelf -s gives the symbol type to be FUNC if it's a function. It
also gives the starting address and the size which you could use to
build your CFG.
> 2. Also, the compilers seem to be inserting data inside the text
> section. For example, for switch statements are some time handled with
> the jump table. Is there anyway I can find out the start address and
> the end address of these data inside the code section.
We hadn't been able to solve this either, maybe someone could help
both of us with this.
Cheers,
--
Ravi Ramaseshan
http://www.geocities.com/ramaseshan_ravi/
" All man's miseries derive from not being able to sit in a room alone. "
- Blaise Pascal