public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Keith Owens <kaos@sgi.com>
To: linux-ia64@vger.kernel.org
Subject: [Linux-ia64] Re: Calling functions via function descriptors saved with cast needed for ia64 code. Il
Date: Thu, 03 Jan 2002 08:46:09 +0000	[thread overview]
Message-ID: <marc-linux-ia64-105590698805735@msgid-missing> (raw)

On Thu, 3 Jan 2002 00:18:33 -0800, 
Piet/Pete Delaney <piet@sgi.com> wrote:
>On Wed, Jan 02, 2002 at 09:46:35PM -0800, Piet/Pete Delaney wrote:
>$2 = {
>  fprintf_func = 0x400000000006cfb0 <dis_fprintf>, 		<-- Pointer to function seems to be ok

That is exactly what you are not supposed to do.  Function pointers
must be treated as opaque cookies.  You can pass them around, assign
them, call the function via the pointer but _never_ assume that
function pointers point to the function.

Dereferencing an ia64 function pointer to get the address of the
function code is only valid for printing the real function address.
You cannot call the function using the dereferenced address because you
do not have the correct environment, you discarded the global data
pointer when you dereferenced the function pointer.

The only time this works on ia64 and ppc64 is in specialized
environments where you know that the global data pointer is not
changing across a function call.  The Linux kernel uses -mconstant-gp
as a performance optimization, intra kernel function calls by name use
the same global pointer so we can skip the save/load/restore cycle for
the global pointer.  Indirect function calls require the function
descriptor, even if you are calling another routine in the kernel.
Calls to module code always have a different global pointer.



                 reply	other threads:[~2002-01-03  8:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-ia64-105590698805735@msgid-missing \
    --to=kaos@sgi.com \
    --cc=linux-ia64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox