I think I have a pretty specific functionality to achieve. I appreciate your suggestion and help. Here is what I want, and I attach an example at the end.

I want to know the address of some function call sites. for example, I want to know is the address of call 8048380 <foo>. (see line "8048366: e8 15 00 00 00 call 8048380 <foo>", which I manually got with objdump).

I thought of using LABEL, but one line in C becomes multi instructions, which may cause impresion under optimization. Also, I don't want to change the source code.

I want to get the mapping without using profiling tool etc. Is there an easy way to modify part of the gcc (or `ld') code and get this functionality? In particular, it would be great if I can get the binary addresses and backpatch them back into the .rtl or .cfg structure somehow.

---------------------
//main.c
     1 #include <stdio.h>
     2 #include "foo.h"
     3 main(){
     4  foo(0); //call site 1
     5  foo(1); //call site 2
     6  printf("done\n");
     7 }

------------------------------------
//foo.c
     1 #include "foo.h"
     2 #include <stdio.h>
     3 void foo(int arg){
     4     int a=0;
     5     a = bar(arg);
     6     printf("sqr of %d= %d\n", arg, a);
     7 }
     8 int bar(arg){
     9     return arg*arg;
    10 }

---------------------------------------
part of objdump output:
08048344 <main>:
8048344:       55                      push   %ebp
8048345:       89 e5                   mov    %esp,%ebp
8048347:       83 ec 08                sub    $0x8,%esp
804834a:       83 e4 f0                and    $0xfffffff0,%esp
804834d:       b8 00 00 00 00          mov    $0x0,%eax
8048352:       29 c4                   sub    %eax,%esp
8048354:       83 ec 0c                sub    $0xc,%esp
8048357:       6a 00                   push   $0x0
8048359:       e8 22 00 00 00          call   8048380 <foo>
804835e:       83 c4 10                add    $0x10,%esp
8048361:       83 ec 0c                sub    $0xc,%esp
8048364:       6a 01                   push   $0x1
8048366:       e8 15 00 00 00          call   8048380 <foo>
804836b:       83 c4 10                add    $0x10,%esp
804836e:       83 ec 0c                sub    $0xc,%esp
8048371:       68 98 84 04 08          push   $0x8048498
8048376:       e8 0d ff ff ff          call   8048288 <_init+0x38>
804837b:       83 c4 10                add    $0x10,%esp
804837e:       c9                      leave
804837f:       c3                      ret

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/


Reply via email to