question about symbols and function locations
Linas Vepstas
linas at austin.ibm.com
Wed Aug 17 01:44:22 EST 2005
On Mon, Aug 15, 2005 at 11:24:55AM -0700, Tim Bird was heard to remark:
> On ppc64 the function address matches
> the data address for the call, but the call site is in the
> range of the weak symbols.
Caution: My answer below may be only partly correct ...
I beleive the ppc ABI makes use of a struct with three pointers
in it to identify a called subroutine. One pointer is to the executable
code, one pointer is to the "TOC" (table of contents) which holds pointers
to all of the global variables that the subroutine references. The
TOC is 65K in size, so that immediate (16-bit offset) instructions can
be used to do the addressing. The third pointer is the "environment"
pointer; its not used by the C language, but is used by other languages,
e.g. Pascal, I beleive.
The "address of a subroutine" is actually the address of this 3-pointer
struct. The subroutine call glue loads the TOC pointer into r2 before
calling the subroutine. You'll notice that global vars are always
addrssed relative to r2. (The TOC also contains addresses of called
subroutines, as well as global vars. Also, note that some static "global"
vars are inlined into the TOC, rather than being pointed at. ).
I think the call glue is named .gl-something or other.
--linas
More information about the Linuxppc64-dev
mailing list