This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH/RFA] PR target/16665: SH thunk with -fPIC


amylaar@spamcop.net (Joern Rennecke) wrote:
> We don't actually need the got, all we need is a pc-relative jump.
> For arbirtary offsets than can be done with a mov.l / braf combination.
> 
> If the thunks were actually emitted together with the function, we could
> even use just a bra, thus making the thunks even smaller and faster.
> 
> However, cp/method.c:make_thunk is self-contradicting in this regard.
> 
> There is a comment
> 
>   /* All thunks must be created before FUNCTION is actually emitted;
>      the ABI requires that all thunks be emitted together with the
>      function to which they transfer control.  */
> 
> But later it says:
> 
>   if (flag_weak)
>     comdat_linkage (thunk);
> 
> which turns the thunk into DECL_ONE_ONLY.  If the thunked-to function is
> not DECL_ONE_ONLY, the thunks end up in a different section than the function,
> and the linker can pull them arbitrarily far apart.
> 
> Is this a bug, or is the comment wrong?

It seems that x86 uses a simple jump when the thunked-to function
satisfies bind_local_p even for PIC and uses the got otherwise,
though this issue is beyond me.

> FWIW, I have found that when I force the thunk to agree with the function
> in use_thunk, bra works.  I've done this with a special thunk sibcall pattern
> that wraps the symbol_ref into an unspec, to prevent accidental matches.

Looks great!

Regards,
	kaz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]