This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

Re: GCC-3.4, official way to get size of functions ?


--- Ian Lance Taylor wrote:
> Etienne Lorrain  writes:
> >   Is there any official way to get the value of this last
> >  debugging symbol - or an official way to get the size of a
> >  function?
> 
> In ELF you can normally find the size of a function in the st_size
> field of the function's entry in the symbol table.
> 
> This is displayed in the fifth column of objdump -t or the second
> column of readelf -s.

  I was more hoping something in the assembler file, instead of creating
 a batch file with objdump or readelf. The target being to copy a function
 stored in a "constant data" to another area (the real mode segment just
 following the stack) before executing it. Another function could be
 copied there and executed instead.

  So I more need something which can be inserted into the assembler file,
 something like (in a C source file):
int myfct (int param) {
    return 3 * param;
    }
asm (" __sizeof__myfct = .size myfct \n"); // .size without comma

  To be able to do:
  extern char __sizeof__myfct[], *dest_addr;
  memcopy (dest_addr, myfct, (unsigned)__sizeof__myfct);

  Because GCC-3.4 reorders completely functions and
 this is no more working:
int myfct (int param) {
    return 3 * param;
    }
asm (" __sizeof__myfct = . - myfct \n");

  Note that because the reorder, the line containning the
 ".size without comma" may be before or after the real function,
 so it may be better handled at linker time with lazy evaluation.

  Note also that it does not solve all my problems (I also use
 an asm("") to replace the ret by lretw), but I just bring the
 point here because I am probably not the only guy needing to
 get the size of a function...

  Etienne.

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com


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