getting symbol information from elf binary

J

junky_fellow

Guys,

I am extremely sorry for posting a question that is not
related to C. I tried my best to get some information from web but
failed. I would be highly grateful if someone could provide me some
hint or direct me to some useful link.

My question is that, I want to retrieve the information about all
structures from an elf binary. For eg. suppose I use a structure of
some type in my C program and then I compile it to get the elf binary.
Now, can I get the information about that structure (names of all the
fields used in that structure, their type etc) from the elf binary. I
believe this is possible with the COFF binary but I didn't find any
section in ELF binary that keeps this information.

If anyone knows any way, please let me know.

thakns a lot for any hint ....
 
S

santosh

Guys,

I am extremely sorry for posting a question that is not
related to C. I tried my best to get some information from web but
failed. I would be highly grateful if someone could provide me some
hint or direct me to some useful link.

My question is that, I want to retrieve the information about all
structures from an elf binary. For eg. suppose I use a structure of
some type in my C program and then I compile it to get the elf
binary. Now, can I get the information about that structure (names
of all the fields used in that structure, their type etc) from the
elf binary. I believe this is possible with the COFF binary but I
didn't find any section in ELF binary that keeps this information.

If anyone knows any way, please let me know.

thakns a lot for any hint ....

This is possible if you compile your binary with debugging
information. Of course, your program needs to know in exquisite
detail, the format of ELF binaries, as well as the debugging format.

The first job is a *big* one and it's already been done. No need to
duplicate it. Just use the GNU Binary File Descriptor (libbfd),
library. The second job is simpler, particularly if you confine
yourself to only one debugging format.

The job is certainly possible but is a fair amount of work, and in
the general case, a lot of work. Isn't there a way for you to use
something like GDB for this? Or even use the compiler itself?

Anyway, for more details you need to ask in a group specific for your
system. Also the gnu groups might be helpful. Unless the C code is
Standard C, or any non-Standard functions are fully defined, it's
probably better to ask in a more specific group.
 
K

Kenny McCormack

Guys,

I am extremely sorry for posting a question that is not
related to C. I tried my best to get some information from web but
failed. I would be highly grateful if someone could provide me some
hint or direct me to some useful link.

As good a job as you have done of trying to sweettalk us and get on our
good side, there is still only one possible answer to this posting.
And, of course, it is the usual:

Off topic. Not portable. Cant discuss it here. Blah, blah, blah.

Useful clc-related links:
 
S

santosh

As good a job as you have done of trying to sweettalk us and get on
our good side, there is still only one possible answer to this
posting. And, of course, it is the usual:

Off topic.

Yes, because Standard C has no built-in knowledge of ELF or debugging
formats.
Not portable.

I think that a program such as what the OP wants *can* be written in
Standard C; it's just that the knowledge required to write it is not
a part of the C Standard, or even the C language.

<snip>
 
C

Chip Coldwell

Guys,

I am extremely sorry for posting a question that is not
related to C. I tried my best to get some information from web but
failed. I would be highly grateful if someone could provide me some
hint or direct me to some useful link.

My question is that, I want to retrieve the information about all
structures from an elf binary. For eg. suppose I use a structure of
some type in my C program and then I compile it to get the elf binary.
Now, can I get the information about that structure (names of all the
fields used in that structure, their type etc) from the elf binary. I
believe this is possible with the COFF binary but I didn't find any
section in ELF binary that keeps this information.

If anyone knows any way, please let me know.

thakns a lot for any hint ....

see ...

https://ols2006.108.redhat.com/2007/Reprints/melo-Reprint.pdf

Chip
 
K

Kenny McCormack

Yes, because Standard C has no built-in knowledge of ELF or debugging
formats.


I think that a program such as what the OP wants *can* be written in
Standard C; it's just that the knowledge required to write it is not
a part of the C Standard, or even the C language.

OK. So, we're all on the same page. Good to know.
 
M

Mark McIntyre

My question is that, I want to retrieve the information about all
structures from an elf binary.

I presume an elf binary is some sort of machine specific library
format. Did you try comp.unix.programmer?
believe this is possible with the COFF binary but I didn't find any
section in ELF binary that keeps this information.

Its entirely possible that the binary does NOT retain this info. Linux
people wuold probably know....
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
R

Richard

Mark McIntyre said:
I presume an elf binary is some sort of machine specific library
format. Did you try comp.unix.programmer?


Its entirely possible that the binary does NOT retain this info. Linux
people wuold probably know....

To the OP : if you are using Linux look up the elfutils package. IN
particular eu-nm which lists symbols in the binary.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top