Finding module TOC address

Heikki Lindholm holindho at cs.helsinki.fi
Thu May 26 19:22:25 EST 2005


Benjamin Herrenschmidt kirjoitti:
> On Thu, 2005-05-26 at 08:06 +1000, Benjamin Herrenschmidt wrote:
> 
>>On Wed, 2005-05-25 at 21:42 +0300, Heikki Lindholm wrote:
>>
>>>Hello,
>>>I need to use assembly jump to a function in a module. How do I find out 
>>>the TOC that the function expects to find in r2? A quick peek at 
>>>kernel/module.c didn't help much, maybe someone here could enlighten me.
>>
>>You don't, there is no TOC on ppc32 ABI, at least the kernel version of
>>it. r2 is reserved in the kernel and always contains "current".
> 
> 
> Ooops ! As you stated privately, wrong list :)
> 
> So yes, ppc64 has a TOC :)
> 
> When you take the function pointer, what you should obtain is a
> descriptor containing the actual pointer and the TOC (unless you are
> calling the .xxx symbol, but that isn't very good to do).
> 
> So if you are doing a pointer-based jump, just load the TOC pointer
> along with the function pointer from the descriptor. If you are doing a
> direct jump (bl .blabla), I'm not 100% sure, you'll probably just load
> the non-dot symbol address in a register to get the descriptor, and then
> peek it for the toc value... Alan ? Is there some better way ?
> 
> Ben.
> 

Thanks! Problem solved.

-- Heikki Lindholm





More information about the Linuxppc64-dev mailing list