[cxx-abi-dev] Typo in ABI document

Jim Dehnert dehnert at transmeta.com
Fri Apr 12 06:35:57 UTC 2002


Mark Mitchell wrote:
> 
> I believe that there is a typo in 3.3.5.3, which says:
> 
>   When linking any DSO containing a call to __cxa_atexit, the linker should
> 
>   define a hidden symbol __dso_handle, with a value which is an address in
>   one of the object's segments. (It does not matter what address, as long
> as
>   they are different in different DSOs.) It should also include a call to
>   the following function in the FINI list (to be executed first):
>   extern "C" void __cxa_finalize ( dso_handle d );
>   The parameter passed should be &__dso_handle.
> 
> The last line should read "The parameter passed should be __dso_handle."
> 
> This is what G++ does, and it is what makes sense: the value of
> __dso_handle is NULL in the main object and is the address of some
> object in the DSO otherwise.  Passing the address of __dso_handle is
> weird; then the runtime would have to dereference the pointer to
> get the real value.
> 
> I will make this change in a week or so if there is no objection.

This is correct as it stands, though it may be confusing.  I'll explain
more carefully what I meant in case that's the only problem.  The "value"
of a linker symbol is the same thing as the address of a variable with
that name.  The first requirement is simply that the linker associate a
symbol (named __dso_handle) with some address in the object's data space.
It therefore appears to C code that there is a variable named
__dso_handle at the selected address, though there isn't any relevant
data at that address.  When calling __cxa_finalize, we need to pass the
address associated with __dso_handle, not the data at that address.
We accomplish that by passing &__dso_handle.  The value of the resulting
pointer parameter is what __cxa_finalize needs -- it doesn't need to
dereference the pointer, as there's no data of interest at that address.

Does that help?

Jim

-- 
-	    Jim Dehnert		dehnert at transmeta.com
	    (408)919-6984	dehnertj at acm.org



More information about the cxx-abi-dev mailing list