New symbol binding to fix C++ ABI

H.J. Lu hjl.tools@gmail.com
Mon Jun 1 22:00:00 GMT 2009


On Mon, Jun 1, 2009 at 1:55 PM, Ulrich Drepper <drepper@redhat.com> wrote:
> 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.
>

We need a testcase patch.

-- 
H.J.



More information about the Binutils mailing list