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 and -fPIC




On Fri, 15 Oct 2004, Andreas Schwab wrote:

Gerhard Wiesinger <gerhard@wiesinger.com> writes:

Why is there a call at location 80485b3?

This is used to load the program counter since the x86 does not have a pc-relative addressing mode except in calls. That's the only way to get the address of the GOT in position independ code.

So is the code gcc produces (in)correct, or objdump can't read any
Position Independent Code?

Neither.



BTW: Is it possible to see the dynamic symbols in the disassembly? I don't see the call to operator delete[](void*) at location 8048592.
=======================================================================
g++ -fPIC -g testnew.cpp -o testnew
objdump -r -R --dynamic-syms --private-headers -S -C testnew | less -I
=======================================================================
DYNAMIC SYMBOL TABLE:
080483d0 DF *UND* 0000002a GLIBCPP_3.2 operator delete(void*)
080483e0 DF *UND* 000004d1 CXXABI_1.2 __gxx_personality_v0
080483f0 DF *UND* 000000f3 GLIBC_2.0 __libc_start_main
080486c0 g DO .rodata 00000004 Base _IO_stdin_used
08048400 DF *UND* 00000039 GLIBCPP_3.2 operator new[](unsigned int)
08048410 DF *UND* 00000026 GLIBCPP_3.2 operator delete[](void*)
00000000 w D *UND* 00000000 _Jv_RegisterClasses
08048420 DF *UND* 000000a3 GLIBCPP_3.2 operator new(unsigned int)
00000000 w D *UND* 00000000 __gmon_start__


        delete x;
 8048578:       83 ec 0c                sub    $0xc,%esp
 804857b:       ff 75 f4                pushl  0xfffffff4(%ebp)
 804857e:       e8 4d fe ff ff          call   80483d0 <_init+0x28>
 8048583:       83 c4 10                add    $0x10,%esp
        delete [] xarray;
 8048586:       83 7d f0 00             cmpl   $0x0,0xfffffff0(%ebp)
 804858a:       74 0e                   je     804859a <main+0xba>
 804858c:       83 ec 0c                sub    $0xc,%esp
 804858f:       ff 75 f0                pushl  0xfffffff0(%ebp)
 8048592:       e8 79 fe ff ff          call   8048410 <_init+0x68>
 8048597:       83 c4 10                add    $0x10,%esp
}
 804859a:       b8 00 00 00 00          mov    $0x0,%eax
 804859f:       8d 65 f8                lea    0xfffffff8(%ebp),%esp
 80485a2:       5b                      pop    %ebx
 80485a3:       5e                      pop    %esi
 80485a4:       c9                      leave
 80485a5:       c3                      ret
=======================================================================

When I just disassemble the object file this works well (but not in the linked version above):
=======================================================================
g++ -fPIC -g -c testnew.cpp -o testnew.o
objdump -r --private-headers -S -C testnew.o | less -I
=======================================================================
delete [] xarray;
a6: 83 7d f0 00 cmpl $0x0,0xfffffff0(%ebp)
aa: 74 0e je ba <main+0xba>
ac: 83 ec 0c sub $0xc,%esp
af: ff 75 f0 pushl 0xfffffff0(%ebp)
b2: e8 fc ff ff ff call b3 <main+0xb3>
b3: R_386_PLT32 operator delete[](void*)
b7: 83 c4 10 add $0x10,%esp
}
=======================================================================


Any ideas to get the symbols also in the linked version?

Thank you.

Ciao,
Gerhard


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