gcc 3.0.3 arm/aout probs with unresolved references to vtable thunks

Luke Diamand ldiamand@virata.com
Thu Feb 28 09:35:00 GMT 2002


Moving from gcc2.95.2 to gcc3.0.3 I've started getting "undefined 
reference to non-virtual thunk" messages, which stop me from linking. 
This is with gcc cross-compiled for arm-aout.

It looks as though vtables in one compilation unit are referencing thunk 
functions which are defined *local* in another, which doesn't work.

Here's some sample code that provokes the problem. It has 3 files, 
foo.h, foo.cc and bar.cc, which are compiled and linked together using 
the arm-a.out toolchain (gcc 3.0.3, binutils 2.11). The commands used are:

arm-gcc-3 -c -O2 foo.cc
arm-gcc-3 -c -O2 bar.cc
arm-gcc-3 -nostdlib foo.o bar.o

//// foo.h ////
struct B1 {
     virtual ~B1();
};

struct B2 {
     virtual ~B2();
     virtual void bar() = 0;
};

struct C : public B1, public B2 {
     virtual ~C();
     void bar();
};

/// foo.cc ////
#include "foo.h"

C c;
B1::~B1(){}
B2::~B2(){}
C::~C() {}

void C::bar(){}

//// bar.cc ////
#include "foo.h"

struct B3 {
     virtual ~B3() {}
};

struct D : public C  {
     virtual void x();
};
void D::x() {}

D d;

With gcc2.95.2 this links fine (apart from the expected unresolved 
references to the standard c++ support code) but in gcc3.0.3 I get the 
following:

...
bar.o(.text+0x2c): undefined reference to `non-virtual thunk to C::bar()'

Now, running 'nm' on foo.o, you get:

00000148 t non-virtual thunk to C::bar()

In other words, this thunk function exists, but is local to foo.o, which 
explains why it can't be used in bar.o.

What's going on? Is this a bug?

This problem was also mentioned here:
http://groups.google.com/groups?selm=9ke60q%24qq8%241%40versa.smarts.com

As far as I can tell, the problem *doesn't* arise for x86/ELF/gcc3.

Thanks in advance for any hints,
Luke Diamand

-- 
GlobespanVirata http://www.globespanvirata.com
Cambridge
Tel: +44 1223 707400      Fax: +44 1223 707447


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



More information about the crossgcc mailing list