public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: discuss@x86-64.org, GCC Development <gcc@gcc.gnu.org>,
	Binutils <binutils@sourceware.org>,
		GNU C Library <libc-alpha@sourceware.org>,
	GDB <gdb@sourceware.org>
Subject: [x86-64 psABI] Document STT_GNU_IFUNC and R_X86_64_IRELATIVE
Date: Tue, 10 Apr 2012 15:33:00 -0000	[thread overview]
Message-ID: <CAMe9rOoYsexzruzCr5YZ545R2o2XPm7HPWc_eSJkqP9DxNJTQQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 202 bytes --]

Hi,

This patch for x86-64 psABI adds document for STT_GNU_IFUNC and
R_X86_64_IRELATIVE. It has been implemented on Linux/x86-64 for
more than a year.  Please add it to x86-64 psABI.

Thanks.

-- 
H.J.

[-- Attachment #2: ifunc-spec.patch --]
[-- Type: application/octet-stream, Size: 2731 bytes --]

2010-12-30  H.J. Lu  <hongjiu.lu@intel.com>

	* object-files.tex: Document STT_GNU_IFUNC and R_X86_64_IRELATIVE.

diff --git a/object-files.tex b/object-files.tex
index 757a25d..4705e96 100644
--- a/object-files.tex
+++ b/object-files.tex
@@ -344,6 +344,23 @@ the section until the end, counting entries as they are encountered.
 The discussion of "Function Addresses" in Section \ref{function_addresses}
 defines some special values for symbol table fields.
 
+The \texttt{STT_GNU_IFUNC}
+\footnote{It is specified in {\bf ifunc.txt}
+at \url{http://groups.google.com/group/generic-abi/files}}
+symbol type is optional. It is the same as
+\texttt{STT_FUNC} except that it always points to a function or piece of
+executable code which takes no arguments and returns a function pointer.
+If an \texttt{STT_GNU_IFUNC} symbol is referred to by a relocation, then
+evaluation of that relocation is delayed until load-time.  The value
+used in the relocation is the function pointer returned by an invocation
+of the \texttt{STT_GNU_IFUNC} symbol.
+ 
+The purpose of the \texttt{STT_GNU_IFUNC} symbol type is to allow the
+run-time to select between multiple versions of the implementation of
+a specific function.  The selection made in general will take the
+currently available hardware into account and select the most
+appropriate version.
+
 \section{Relocation}
 
 \subsection{Relocation Types}
@@ -451,6 +468,7 @@ the relocation addend.
       \texttt{R_X86_64_GOTPC32_TLSDESC} & 34 & \textit{word32} &  \\
       \texttt{R_X86_64_TLSDESC_CALL} & 35 & none &  \\
       \texttt{R_X86_64_TLSDESC} & 36 & \textit{word64}$\times 2$ & \\
+      \texttt{R_X86_64_IRELATIVE} & 37 & \textit{word64} & \texttt{indirect (B + A)}\\
 %      \texttt{R_X86_64_GOT64} & 16 & \textit{word64} & \texttt{G + A} \\
 %      \texttt{R_X86_64_PLT64} & 17 & \textit{word64} & \texttt{L + A - P} \\
     \end{tabular}
@@ -563,6 +581,16 @@ to the named symbol.  \texttt{R_X86_64_TLSDESC_CALL} must annotate the
 instruction used to call the TLS Descriptor resolver function, so as
 to enable relaxation of that instruction.
 
+\texttt{R_X86_64_IRELATIVE} is similar to \texttt{R_X86_64_RELATIVE}
+except that the value used in this relocation is the program address
+returned by the function, which takes no arguments, at the address of
+the result of the corresponding \texttt{R_X86_64_RELATIVE} relocation.
+
+One use of the \texttt{R_X86_64_IRELATIVE} relocation is to avoid name
+lookup for the locally defined \texttt{STT_GNU_IFUNC} symbols at
+load-time.  Support for this relocation is optional, but is required for
+the \texttt{STT_GNU_IFUNC} symbols.
+
 \subsection{Large Models}
 
 In order to extend both the PLT and the GOT beyond 2GB, it

             reply	other threads:[~2012-04-10 15:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-10 15:33 H.J. Lu [this message]
2012-04-16 16:52 ` H.J. Lu
2012-04-17 12:42   ` Michael Matz

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=CAMe9rOoYsexzruzCr5YZ545R2o2XPm7HPWc_eSJkqP9DxNJTQQ@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=discuss@x86-64.org \
    --cc=gcc@gcc.gnu.org \
    --cc=gdb@sourceware.org \
    --cc=libc-alpha@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).