This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PowerPC 64]r12 is not updated to GEP when control transferred from virtual thunk function .
- From: Alan Modra <amodra at gmail dot com>
- To: Segher Boessenkool <segher at kernel dot crashing dot org>
- Cc: Umesh Kalappa <umesh dot kalappa0 at gmail dot com>, Eric Botcazou <ebotcazou at adacore dot com>, gcc at gcc dot gnu dot org
- Date: Mon, 20 May 2019 16:19:54 +0930
- Subject: Re: [PowerPC 64]r12 is not updated to GEP when control transferred from virtual thunk function .
- References: <CAGfacvQc=X8vcxoVqbjbimTPLctQzKbzex1odEggRsjrphnurw@mail.gmail.com> <3290120.NdSNzDBL4k@polaris> <CAGfacvTwafpM7vzdv0x-rvx4KZh_uwhZ==MVjYP4qEfiQM9HJQ@mail.gmail.com> <1938670.JyHVrHFxKJ@polaris> <20190515235233.GN8599@gate.crashing.org> <CAGfacvQpbZJBxvnshsTtpuDi1VfU+rUAeKLw2RvjnnWKZ68Xwg@mail.gmail.com> <CAGfacvTVdpEkn+7ep=z=zk+ck=X_6XYKn1A5BeqWmgi0rGv7tQ@mail.gmail.com> <20190516225242.GE31586@gate.crashing.org>
On Thu, May 16, 2019 at 05:52:42PM -0500, Segher Boessenkool wrote:
> Hi Umesh,
>
> On Thu, May 16, 2019 at 06:12:48PM +0530, Umesh Kalappa wrote:
> > We are very new to Power abi and we are thinking to handle this case
> > in loader like go through the relocations like R_PPC64_REL24 and
> > found symbol has the localentry ,then compute the delta (GEP - LEP )
> > and patch the caller address like (sym.value - delta).
>
> I wonder if you have found a bug in the compiler after all. Most things
> are supposed to work without the linker/loader having to do special
> things; e.g. using the global entry point should always work, using the
> local entry point is just an optimisation.
That isn't true for direct calls. If using the global entry point,
the linker must provide stub code to load up r12 with the global entry
address and modify the nop after the bl. The linker must also adjust
calls using the local entry point; the call instruction (and
relocation) specify the function symbol not the function plus local
entry offset.
So I don't think there is any compiler bug here, just a broken kernel
module loader. Incidentally, if thunks are broken then it's very
likely local function calls are broken too.
--
Alan Modra
Australia Development Lab, IBM