Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* function address from object file?
@ 2005-03-01  9:14 Roopesh Kohad
  2005-03-01 10:21 ` Ramana Radhakrishnan
  2005-03-01 14:26 ` Daniel Jacobowitz
  0 siblings, 2 replies; 4+ messages in thread
From: Roopesh Kohad @ 2005-03-01  9:14 UTC (permalink / raw)
  To: gdb

Hi,
    I am trying to print function address by reading an object file.
But the function address are all shown to be zero. How serious is this
bug? Here is the repro:-

$ cat a.c
#include <stdio.h>

void t(void)
{
        int i=0;
        printf("%d\n",i);
}

void u(void)
{
        int i=0;
        printf("%d\n",i);
}

int main()
{
        t();
        return 0;
}


$ gcc -c -g -o a.o a.c
$ gdb a.o
(gdb) info file
Symbols from "/tmp/a.o".
Local exec file:
        `/tmp/a.o', file type pe-i386.
        Entry point: 0x0
        0x00000000 - 0x00000070 is .text
(gdb) print &t
$1 = (void (*)()) 0		<------------- 0x0
(gdb) print &u
$2 = (void (*)()) 0		<------------- 0x0
(gdb) print &main
$3 = (int (*)()) 0		<------------- 0x0

$ objdump -d a.o

a.o:     file format pe-i386

Disassembly of section .text:

00000000 <_t>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   83 ec 08                sub    $0x8,%esp
   6:   c7 45 fc 00 00 00 00    movl   $0x0,0xfffffffc(%ebp)
   d:   83 ec 08                sub    $0x8,%esp
  10:   ff 75 fc                pushl  0xfffffffc(%ebp)
  13:   68 00 00 00 00          push   $0x0
  18:   e8 00 00 00 00          call   1d <_t+0x1d>
  1d:   83 c4 10                add    $0x10,%esp
  20:   c9                      leave
  21:   c3                      ret

00000022 <_u>:
  22:   55                      push   %ebp
  23:   89 e5                   mov    %esp,%ebp
  25:   83 ec 08                sub    $0x8,%esp
  28:   c7 45 fc 00 00 00 00    movl   $0x0,0xfffffffc(%ebp)
  2f:   83 ec 08                sub    $0x8,%esp
  32:   ff 75 fc                pushl  0xfffffffc(%ebp)
  35:   68 00 00 00 00          push   $0x0
  3a:   e8 00 00 00 00          call   3f <_u+0x1d>
  3f:   83 c4 10                add    $0x10,%esp
  42:   c9                      leave
  43:   c3                      ret

00000044 <_main>:
  44:   55                      push   %ebp
  45:   89 e5                   mov    %esp,%ebp
  47:   83 ec 08                sub    $0x8,%esp
  4a:   83 e4 f0                and    $0xfffffff0,%esp
  4d:   b8 00 00 00 00          mov    $0x0,%eax
  52:   89 45 fc                mov    %eax,0xfffffffc(%ebp)
  55:   8b 45 fc                mov    0xfffffffc(%ebp),%eax
  58:   e8 00 00 00 00          call   5d <_main+0x19>
  5d:   e8 00 00 00 00          call   62 <_main+0x1e>
  62:   e8 00 00 00 00          call   67 <_main+0x23>
  67:   b8 00 00 00 00          mov    $0x0,%eax
  6c:   c9                      leave
  6d:   c3                      ret
  6e:   90                      nop
  6f:   90                      nop

-- 
regards,
Roopesh Kohad


^ permalink raw reply	[flat|nested] 4+ messages in thread
* RE: function address from object file?
@ 2005-03-01 11:20 Atul Talesara
  0 siblings, 0 replies; 4+ messages in thread
From: Atul Talesara @ 2005-03-01 11:20 UTC (permalink / raw)
  To: Roopesh Kohad, gdb


> $ gcc -c -g -o a.o a.c
This command will *only* compile the code, leaving
final address resolution/allocation to linking stage.
Hence you see zero-based addresses.

Regards,
Atul
http://the-shaolin.blogspot.com/ 
---------------------------------------------------------- 
You can tell more about a person by what he says about
others than you can by what others say about him.
----------------------------------------------------------


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-03-01 14:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-01  9:14 function address from object file? Roopesh Kohad
2005-03-01 10:21 ` Ramana Radhakrishnan
2005-03-01 14:26 ` Daniel Jacobowitz
2005-03-01 11:20 Atul Talesara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox