Quo vadis, thunk? (Was: Re: [PATCH/RFA] PR target/16665: SH thunk
Joern Rennecke
joern.rennecke@superh.com
Tue Aug 3 11:37:00 GMT 2004
>
> Joern Rennecke wrote:
>
> >I see that you wrote the comment in cp/method.c . Is target port supposed
> >to be able to rely on the thunk being emitted together with the function
> >that is being thunked to?
> >
> >
> Yes, where "together with" means "in the same object file". That much
> is required by the C++ ABI. The ABI does not seem to say whether or not
> the thunks must be COMDAT, but it would make sense to make them COMDAT
> only when their associated function is also COMDAT, and in that case
> they should all be in the same group.
>
> Thus, I would consider the fact that G++ presently makes the thunks weak
> even when the underlying function is not weak to be an odd quirk, if not
> a bug. I think that could safely be changed without endangering
> anything. It may be that it is the way it is for historical reasons; it
> could also be that until my recent linkage cleanup, one could not be
> sure whether the associated function would be COMDAT or not. In any
> case, I think you could change it now.
>
> In the case that the associated function is weak, you cannot (since GCC
> does not really do COMDAT groups) assume that the thunks will be "near"
> the associated function; they will still be in separate .gnu.linkonce
> sections.
No, there is code in use_thunk that sets the section of the thunk to match
the section of the function if the function is DECL_ONE_ONLY:
if (TARGET_USE_LOCAL_THUNK_ALIAS_P (function)
&& targetm.have_named_sections)
{
resolve_unique_section (function, 0, flag_function_sections);
if (DECL_SECTION_NAME (function) != NULL && DECL_ONE_ONLY (function))
{
resolve_unique_section (thunk_fndecl, 0, flag_function_sections);
/* Output the thunk into the same section as function. */
DECL_SECTION_NAME (thunk_fndecl) = DECL_SECTION_NAME (function);
}
}
AFAICS after the first resolve_unique_section call
DECL_SECTION_NAME (function) should always be set if the function is
DECL_ONE_ONLY and the port fully supports named sections.
More information about the Gcc
mailing list