How Readelf command works?

Hello all

I want to read program header of a executable without using readelf. I know it can be tough. I will do the programming myself. Just give me a hint of it.

Thanks

---------- Post updated at 05:02 AM ---------- Previous update was at 04:58 AM ----------

basically i want to count the program headers.

You means source files? They are sometimes stripped out. 'readelf -l object-file': Man Page for readelf (opensolaris Section 1) - The UNIX and Linux Forums

you are right but i want to count program headers of a binary file without using readelf.
Thanks

Look at the 'strings' or 'cat -vt' output to see if you can pick them out using sed regex somewhat to the left of main or other subroutine names.