This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/12285] Add sizeof_function functionality


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]