public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ name mangling, old and new versions?
@ 1998-03-04  6:10 T. Huld
  1998-03-04 12:45 ` Martin von Loewis
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: T. Huld @ 1998-03-04  6:10 UTC (permalink / raw)
  To: egcs

Hello,

It's probably just me doing something stupid, but here goes:

My setup: 
	Intel 586, Linux Red Hat 5.0, glibc-2.0.6, egcs-1.0.1
	all binary distributions.


According to the info, egcs performs a name mangling which is not
compatible with the one done by gcc-2.7. I have verified this by trying
to link egcs-compiled programs with a binary distribution of the
QT library. With the binary distribution library the linking fails, if I
recompile the library with egcs the linking works OK.

HOWEVER, there is supposed to be an option: -fname-mangling-version-N, 
where you can choose between the old name mangling convention (N=0)
and the new one (N=1). But when I try to compile with the two different
options, I get identical object files, and 'nm' reports no difference
whatsoever. 

The call to g++ looks like this:

g++  -c   -fname-mangling-version-0 -g2  -Wall -DLINUX 
-I/usr/home2/thomas/newreac/includes  -I/usr/local/qt/include 
/usr/home2/thomas/newreac/sources/gui/gwndmain.cpp -o 
/usr/home2/thomas/newreac/sources/gui/gwndmain.o

What am I doing wrong?

BTW: the compiler also accepts N>2 but this doesn't make any difference 
either.

Any help is much appreciated, since I would really like to compile some
of the newer KDE apps without compiling the entire KDE distribution.

aTdHvAaNnKcSe

Thomas


-------------------------------------------------------------------------
Thomas Huld
European Commission - Joint Research Centre - Ispra Site(IT)
T.P.723                 
I-21020 Ispra                | Insofar as my employer has coherent
Absurdistan                  | opinions they are unlikely to be mine
tel. +39 (0)332 785273
fax. +39 (0)332 785869
e-mail: thomas.huld@jrc.it 

Bureaucarcinoma: a terminal disease which afflicts research institutions.
Braindeath occurs when the administration staff reaches 50% of total.
-------------------------------------------------------------------------


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

* Re: C++ name mangling, old and new versions?
  1998-03-04  6:10 C++ name mangling, old and new versions? T. Huld
@ 1998-03-04 12:45 ` Martin von Loewis
  1998-03-04 19:27 ` Andi Kleen
       [not found] ` <k2n2f5vms1.fsf.cygnus.egcs@zero.aec.at>
  2 siblings, 0 replies; 9+ messages in thread
From: Martin von Loewis @ 1998-03-04 12:45 UTC (permalink / raw)
  To: thomas.huld; +Cc: egcs

> It's probably just me doing something stupid, but here goes:

I don't think it is stupid, it's just that your bug report is
incomplete.

I guess -fname-mangling-version-0 is an infrequently-used option,
so it might break. Please let us know what exactly the symbols
are that are missing (e.g. by providing part of the final linker
output).

The linker will probably present you the filtered names, I don't know
whether you can have it print the mangled name. When you know what you
are looking for, you can do nm(1) on the objects, grepping for the
class name as well as for 'U' to get only undefined symbols.

It is a good idea to concentrate on one symbol only, e.g. the first
one.

If virtual tables are missing, you might have been caught by the
change in format of the virtual tables (-fvtable-thunks).

Martin

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

* Re: C++ name mangling, old and new versions?
  1998-03-04  6:10 C++ name mangling, old and new versions? T. Huld
  1998-03-04 12:45 ` Martin von Loewis
@ 1998-03-04 19:27 ` Andi Kleen
       [not found] ` <k2n2f5vms1.fsf.cygnus.egcs@zero.aec.at>
  2 siblings, 0 replies; 9+ messages in thread
From: Andi Kleen @ 1998-03-04 19:27 UTC (permalink / raw)
  To: T. Huld; +Cc: egcs

"T. Huld" <thomas.huld@jrc.it> writes:

> Hello,
> 
> It's probably just me doing something stupid, but here goes:
> 
> My setup: 
> 	Intel 586, Linux Red Hat 5.0, glibc-2.0.6, egcs-1.0.1
> 	all binary distributions.
> 
> 
> According to the info, egcs performs a name mangling which is not
> compatible with the one done by gcc-2.7. I have verified this by trying
> to link egcs-compiled programs with a binary distribution of the
> QT library. With the binary distribution library the linking fails, if I
> recompile the library with egcs the linking works OK.
> 
> HOWEVER, there is supposed to be an option: -fname-mangling-version-N, 
> where you can choose between the old name mangling convention (N=0)
> and the new one (N=1). But when I try to compile with the two different
> options, I get identical object files, and 'nm' reports no difference
> whatsoever. 
> 
> The call to g++ looks like this:
> 
> g++  -c   -fname-mangling-version-0 -g2  -Wall -DLINUX 
> -I/usr/home2/thomas/newreac/includes  -I/usr/local/qt/include 
> /usr/home2/thomas/newreac/sources/gui/gwndmain.cpp -o 
> /usr/home2/thomas/newreac/sources/gui/gwndmain.o

I had good look with -fno-rtti -fno-exceptions together with a 2.7.2
compiled Qt. The vtable layout is different when RTTI is enabled, so
egcs protects against mistakes by encoding that in the mangled name.
You have to explicitely turn it off, -fname-mangling-version-0 is not
enough.

-Andi

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

* Re: C++ name mangling, old and new versions?
       [not found] ` <k2n2f5vms1.fsf.cygnus.egcs@zero.aec.at>
@ 1998-03-04 19:38   ` Jason Merrill
  1998-03-04 20:12     ` ak
  0 siblings, 1 reply; 9+ messages in thread
From: Jason Merrill @ 1998-03-04 19:38 UTC (permalink / raw)
  To: Andi Kleen, egcs

>>>>> Andi Kleen <ak@muc.de> writes:

> I had good look with -fno-rtti -fno-exceptions together with a 2.7.2
> compiled Qt. The vtable layout is different when RTTI is enabled, so
> egcs protects against mistakes by encoding that in the mangled name.

Both those statements are false for -fno-rtti, though they are true of
-fvtable-thunks.

Jason

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

* Re: C++ name mangling, old and new versions?
  1998-03-04 19:38   ` Jason Merrill
@ 1998-03-04 20:12     ` ak
  1998-03-04 20:25       ` Jason Merrill
  1998-03-05  0:18       ` Martin von Loewis
  0 siblings, 2 replies; 9+ messages in thread
From: ak @ 1998-03-04 20:12 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Andi Kleen, egcs

On Thu, Mar 05, 1998 at 04:37:33AM +0100, Jason Merrill wrote:
> >>>>> Andi Kleen <ak@muc.de> writes:
> 
> > I had good look with -fno-rtti -fno-exceptions together with a 2.7.2
> > compiled Qt. The vtable layout is different when RTTI is enabled, so
> > egcs protects against mistakes by encoding that in the mangled name.
> 
> Both those statements are false for -fno-rtti, though they are true of
> -fvtable-thunks.

You mean the mangling is only changed (between -frtti/no-rtti) when
vtable-thunks is enabled? If this is true how is the typeinfo encoded
then when vtable-thunks is not enabled?

-Andi (a bit puzzled about your statements)


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

* Re: C++ name mangling, old and new versions?
  1998-03-04 20:12     ` ak
@ 1998-03-04 20:25       ` Jason Merrill
  1998-03-05 15:33         ` ak
  1998-03-05  0:18       ` Martin von Loewis
  1 sibling, 1 reply; 9+ messages in thread
From: Jason Merrill @ 1998-03-04 20:25 UTC (permalink / raw)
  To: ak; +Cc: egcs

>>>>> ak  <ak@muc.de> writes:

> On Thu, Mar 05, 1998 at 04:37:33AM +0100, Jason Merrill wrote:
>> >>>>> Andi Kleen <ak@muc.de> writes:
>> 
>> > I had good look with -fno-rtti -fno-exceptions together with a 2.7.2
>> > compiled Qt. The vtable layout is different when RTTI is enabled, so
>> > egcs protects against mistakes by encoding that in the mangled name.
>> 
>> Both those statements are false for -fno-rtti, though they are true of
>> -fvtable-thunks.

> You mean the mangling is only changed (between -frtti/no-rtti) when
> vtable-thunks is enabled? If this is true how is the typeinfo encoded
> then when vtable-thunks is not enabled?

No.  -frtti has no effect on vtable layout or mangling, ever.
-fvtable-thunks changes vtable layout and mangling.

If -fno-rtti, the RTTI entry in the vtable is set to zero, but the layout
is the same.

Jason

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

* Re: C++ name mangling, old and new versions?
  1998-03-04 20:12     ` ak
  1998-03-04 20:25       ` Jason Merrill
@ 1998-03-05  0:18       ` Martin von Loewis
  1 sibling, 0 replies; 9+ messages in thread
From: Martin von Loewis @ 1998-03-05  0:18 UTC (permalink / raw)
  To: ak; +Cc: egcs

> You mean the mangling is only changed (between -frtti/no-rtti) when
> vtable-thunks is enabled? 

No. The vtable mangling is changed when vtable-thunks is enabled, period.
-frtti does not influence the format of the vtable.

> If this is true how is the typeinfo encoded
> then when vtable-thunks is not enabled?

In the traditional vtables, slot 0 has been reserved for the virtual
typeinfo function for quite a while now. -fno-rtti still reserves this
slot, but fills the typeinfo slot with a null pointer.

Martin

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

* Re: C++ name mangling, old and new versions?
  1998-03-05 15:33         ` ak
@ 1998-03-05 15:33           ` Jason Merrill
  0 siblings, 0 replies; 9+ messages in thread
From: Jason Merrill @ 1998-03-05 15:33 UTC (permalink / raw)
  To: ak; +Cc: egcs

>>>>> ak  <ak@muc.de> writes:

> I see. I didn't know that 2.7.2 already had a reserved vtable entry for
> the rtti function(1), therefore the confusion. The original point still
> holds - a 2.7.2 compiled shared library Qt doesn't link with a egcs
> program (even though Qt doesn't use RTTI) unless -fno-exceptions
> -fno-rtti is specified.

> It complains about missing "Class type_info function" (that is probably the 
> RTTI entry you were refering to), and missing RTTI (__rtti_class) and 
> exceptions function from the runtime library. I don't know why -fno-rtti/
> -fno-exceptions makes a difference for the runtime library.

Because code compiled with RTTI assumes that all code was compiled with
RTTI.  In particular, it assumes that RTTI functions for base classes were
written out along with their vtables.

Jason

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

* Re: C++ name mangling, old and new versions?
  1998-03-04 20:25       ` Jason Merrill
@ 1998-03-05 15:33         ` ak
  1998-03-05 15:33           ` Jason Merrill
  0 siblings, 1 reply; 9+ messages in thread
From: ak @ 1998-03-05 15:33 UTC (permalink / raw)
  To: Jason Merrill; +Cc: ak, egcs

On Thu, Mar 05, 1998 at 05:24:29AM +0100, Jason Merrill wrote:
> >>>>> ak  <ak@muc.de> writes:
> 
> > On Thu, Mar 05, 1998 at 04:37:33AM +0100, Jason Merrill wrote:
> >> >>>>> Andi Kleen <ak@muc.de> writes:
> >> 
> >> > I had good look with -fno-rtti -fno-exceptions together with a 2.7.2
> >> > compiled Qt. The vtable layout is different when RTTI is enabled, so
> >> > egcs protects against mistakes by encoding that in the mangled name.
> >> 
> >> Both those statements are false for -fno-rtti, though they are true of
> >> -fvtable-thunks.
> 
> > You mean the mangling is only changed (between -frtti/no-rtti) when
> > vtable-thunks is enabled? If this is true how is the typeinfo encoded
> > then when vtable-thunks is not enabled?
> 
> No.  -frtti has no effect on vtable layout or mangling, ever.
> -fvtable-thunks changes vtable layout and mangling.
> 
> If -fno-rtti, the RTTI entry in the vtable is set to zero, but the layout
> is the same.

I see. I didn't know that 2.7.2 already had a reserved vtable entry for
the rtti function(1), therefore the confusion. The original point still holds -
a 2.7.2 compiled shared library Qt doesn't link with a egcs program (even 
though Qt doesn't use RTTI) unless -fno-exceptions -fno-rtti is specified. 

It complains about missing "Class type_info function" (that is probably the 
RTTI entry you were refering to), and missing RTTI (__rtti_class) and 
exceptions function from the runtime library. I don't know why -fno-rtti/
-fno-exceptions makes a difference for the runtime library.


-Andi

(1) Thanks to rth for the pointer.

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

end of thread, other threads:[~1998-03-05 15:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-04  6:10 C++ name mangling, old and new versions? T. Huld
1998-03-04 12:45 ` Martin von Loewis
1998-03-04 19:27 ` Andi Kleen
     [not found] ` <k2n2f5vms1.fsf.cygnus.egcs@zero.aec.at>
1998-03-04 19:38   ` Jason Merrill
1998-03-04 20:12     ` ak
1998-03-04 20:25       ` Jason Merrill
1998-03-05 15:33         ` ak
1998-03-05 15:33           ` Jason Merrill
1998-03-05  0:18       ` Martin von Loewis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).