[Bug middle-end/12285] Add sizeof_function functionality
wilson at specifixinc dot com
gcc-bugzilla@gcc.gnu.org
Fri Sep 19 06:27:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12285
------- Additional Comments From wilson at specifixinc dot com 2003-09-19 05:17 -------
Subject: Re: New: Add sizeof_function functionality
mkgnu at gmx dot net wrote:
> I am requesting the feature of adding a means of computing the size of a
> function at run time.
If your target is ELF, then there is already function size info in the
ELF symbol table. Try objdump -t executable. The first number is an
address, the second number is the size of the symbol.
The compiler doesn't have enough info to compute function sizes. It has
to defer it to the assembler by putting a laberl after the function end
and then subtracting labels. This is what we do to get the ELF symbol
table size info. The only way to get this info back into C code would
be to store it in a variable somewhere, but since the value is already
in the symbol table, it would be wasteful to have a second copy of it.
If you are trying to copy functions around, you probably need to be
looking at ELF headers anyways, so getting the info from there shouldn't
be too much trouble.
More information about the Gcc-bugs
mailing list