Proposal for STT_GNU_IFUNC and R_*_IRELATIVE
H.J. Lu
hjl.tools@gmail.com
Tue May 26 17:10:00 GMT 2009
On Tue, May 26, 2009 at 8:43 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, May 26, 2009 at 8:31 AM, Jan Beulich <JBeulich@novell.com> wrote:
>>>>> "H.J. Lu" <hjl.tools@gmail.com> 26.05.09 16:39 >>>
>>>2. How should locally defined symbols with the new type be handled?
>>>
>>>I don't see the fundamental difference between the new relocation and
>>>the new DT_* tags. The end result is the same. If your OS doesn't support
>>>them, the application will crash if they are used. I will propose a new
>>>x86-64 psABI extension, which will be optional. If an OS supports
>>>STT_GNU_IFUNC, it must support R_X86_64_IRELATIVE.
>>
>> The fundamental difference is that the new-relocation-type approach is
>> not matching the general ELF idea, whereas the new dynamic-tag-approach
>> fits well with other ELF definitions.
>>
>
> Relocation types are defined in the psABI. I don't see any problems
> with R_X86_64_IRELATIVE.
>
Here is the proposed update for x86-64 psABI.
--
H.J.
-------------- next part --------------
Index: object-files.tex
===================================================================
--- object-files.tex (revision 5945)
+++ object-files.tex (working copy)
@@ -344,6 +344,23 @@ the section until the end, counting entr
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_T
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
More information about the Libc-alpha
mailing list