Why the "opd" section?

Alan Modra amodra at bigpond.net.au
Tue Jul 25 12:15:58 EST 2006


On Sun, Jul 23, 2006 at 09:01:38PM -0700, Jonathan Bartlett wrote:
> I'm learning PPC64 assembly language, and I found the existence of the
> "opd" sections containing function descriptors quite odd.  What is the use
> of these?  Are they used by the linker?  Why are they needed in the 64-bit
> ELF platforms and not the 32-bit ones?

OPD is an array of function pointers.  Function pointers on powerpc64
are not just simple pointers to some code;  They specify the code entry
point, the TOC pointer, and the static chain pointer (unused by C).
To call a function, you need to know all these values because functions
do not initialise their own TOC pointer.  This allows for more efficient
code.  The compiler/linker can omit the TOC pointer load when both
caller and callee are known to share the same TOC.  (In many ways, the
TOC is like the powerpc32 GOT.  powerpc32 -fpic/PIC code initialises the
GOT pointer on entry to every function, even when caller and callee are
known to have the same GOT pointer.)

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Linuxppc-dev mailing list