New symbol binding to fix C++ ABI

Ulrich Drepper drepper@redhat.com
Mon Jun 1 20:56:00 GMT 2009


The C++ ABI demands that certain data objects are unique in the entire
process.  This is the case static class members or static variables in
inline functions.  Jason can provide the necessary details, if needed.

I attach a patch which implements a new symbol binding, STB_GNU_UNIQUE.
 The compile will use this binding, instead of defining the variable as
a global variable.  Jason already has a patch for gcc which is using the
extension of the patch below.

There is one detail of the patch which is non-obvious.  The interface to
get to such an object is not implemented by providing a pseudo-op
similar to .global.  Instead, I've defined a new symbol type, to be used
with the .type pseudo-op.  The reason for this is that it is wrong to
apply the new symbol binding to anything but data object (no functions
in particular).  It makes no sense.  So, instead of opening the door for
misuse the compiler will emit

  .type name,%gnu_unique_object
  .global

instead of

  .type name,%object
  .global

At the assembler source level this isn't confusing at all.  It's only
the translation to what it means at the ELF level that might be a bit
confusing.  But not many people have to actually deal with this so I
don't consider it a problem.

The patch below applies on top of the RH binutils RPM.  It should also
apply with little fuzz to the normal sources.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: binutils-uobject.patch
URL: <https://sourceware.org/pipermail/binutils/attachments/20090601/85ec9059/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/binutils/attachments/20090601/85ec9059/attachment.sig>


More information about the Binutils mailing list