This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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

gcc3.0.2 ( g++) on arm - seeing double ??


Can someone please explain the mystery detailed below
Thx Andy


File TestClass.h contains the following code:
class MyClass {
        public:

               MyClass(void);
	 ~MyClass();

};

File TestClass.cpp contains the following code:
MyClass::MyClass()
{
}

MyClass::~MyClass(void)
{
}

As simple as you can imagine..
Now,lets compile this using a gcc 3.0.2 cross-compiler on a i386 linux host:
$arm-elf-gcc -c TestClass.cpp
$arm-elf-objdump -D TestClass.o

TestClass.o:     file format elf32-littlearm

Disassembly of section .text:

00000000 <_ZN7MyClassC2Ev>:
   0:   e1a0c00d        mov     ip, sp
   4:   e92dd800        stmdb   sp!, {fp, ip, lr, pc}
   8:   e24cb004        sub     fp, ip, #4      ; 0x4
   c:   e24dd004        sub     sp, sp, #4      ; 0x4
  10:   e91ba800        ldmdb   fp, {fp, sp, pc}

00000014 <_ZN7MyClassC1Ev>:
  14:   e1a0c00d        mov     ip, sp
  18:   e92dd800        stmdb   sp!, {fp, ip, lr, pc}
  1c:   e24cb004        sub     fp, ip, #4      ; 0x4
  20:   e24dd004        sub     sp, sp, #4      ; 0x4
  24:   e91ba800        ldmdb   fp, {fp, sp, pc}

00000028 <_ZN7MyClassD2Ev>:
  28:   e1a0c00d        mov     ip, sp
  2c:   e92dd800        stmdb   sp!, {fp, ip, lr, pc}
  30:   e24cb004        sub     fp, ip, #4      ; 0x4
  34:   e24dd004        sub     sp, sp, #4      ; 0x4
  38:   e91ba800        ldmdb   fp, {fp, sp, pc}

0000003c <_ZN7MyClassD1Ev>:
  3c:   e1a0c00d        mov     ip, sp
  40:   e92dd800        stmdb   sp!, {fp, ip, lr, pc}
  44:   e24cb004        sub     fp, ip, #4      ; 0x4
  48:   e24dd004        sub     sp, sp, #4      ; 0x4
  4c:   e91ba800        ldmdb   fp, {fp, sp, pc}

Am I seeing double ?? Why are there 2 ctors and 2 dtors ???

The same code compiled in a gcc 2.95.3 arm cross-compiler produces the following assembly:

TestClass-gcc2.o:     file format elf32-littlearm

Disassembly of section .text:

00000000 <__7MyClass>:
   0:   e1a0c00d        mov     ip, sp
   4:   e92dd800        stmdb   sp!, {fp, ip, lr, pc}
   8:   e24cb004        sub     fp, ip, #4      ; 0x4
   c:   e1a03000        mov     r3, r0
  10:   e1a00003        mov     r0, r3
  14:   ea000004        b       18 <__7MyClass+0x18>
  18:   e91ba800        ldmdb   fp, {fp, sp, pc}

0000001c <_._7MyClass>:
  1c:   e1a0c00d        mov     ip, sp
  20:   e92dd810        stmdb   sp!, {r4, fp, ip, lr, pc}
  24:   e24cb004        sub     fp, ip, #4      ; 0x4
  28:   e24dd004        sub     sp, sp, #4      ; 0x4
  2c:   e1a04000        mov     r4, r0
  30:   e50b1014        str     r1, [fp, -#20]
  34:   e51b2014        ldr     r2, [fp, -#20]
  38:   e2023001        and     r3, r2, #1      ; 0x1
  3c:   e3530000        cmp     r3, #0  ; 0x0
  40:   0a000012        beq     50 <_._7MyClass+0x34>
  44:   e1a00004        mov     r0, r4
  48:   ebfffffe        bl      0 <__7MyClass>
  4c:   ea000012        b       50 <_._7MyClass+0x34>
  50:   e91ba810        ldmdb   fp, {r4, fp, sp, pc}





------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


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