This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Proposal for STT_GNU_IFUNC and DT_GNU_* tags
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Jan Beulich <JBeulich at novell dot com>
- Cc: Generic System V Application Binary Interface <generic-abi at googlegroups dot com>, IUlrich Drepper <drepper at redhat dot com>, Nick Clifton <nickc at redhat dot com>, Binutils <binutils at sourceware dot org>, GNU C Library <libc-alpha at sourceware dot org>, "H. Peter Anvin" <hpa at zytor dot com>
- Date: Wed, 27 May 2009 10:12:41 -0700
- Subject: Proposal for STT_GNU_IFUNC and DT_GNU_* tags
Here is the updated proposal for STT_GNU_IFUNC and DT_GNU_* tags.
H.J.
----
STT_GNU_IFUNC
This symbol type is the same as 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 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 STT_GNU_IFUNC symbol.
The purpose of this 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.
STT_GNU_IFUNC is defined in OS-specific range:
#define STT_LOOS 10 /* OS-specific semantics */
#define STT_GNU_IFUNC 10 /* Symbol is an indirect code object */
#define STT_HIOS 12 /* OS-specific semantics */
STT_GNU_IFUNC symbols can be in shared object, dynamic executable and
gnu-6:pts/3[46]> cat ifunc.txt /export/gnu/import/svn/psABI/ifunc
STT_GNU_IFUNC
This symbol type is the same as 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 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 STT_GNU_IFUNC symbol.
The purpose of this 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.
STT_GNU_IFUNC is defined in OS-specific range:
#define STT_LOOS 10 /* OS-specific semantics */
#define STT_GNU_IFUNC 10 /* Symbol is an indirect code object */
#define STT_HIOS 12 /* OS-specific semantics */
STT_GNU_IFUNC symbols can be in shared object, dynamic executable and
static executable. DT_GNU_XXX tags are used to mark the indirect
relocation table for relocations against locally defined STT_GNU_IFUNC
symbols.
DT_GNU_IRELA
This element holds the address of the indirect relocation table with
explicit addends, such as Elf32_Rela for the 32-bit file class or
Elf64_Rela for the 64-bit file class. If this element is present,
the dynamic structure must also have DT_GNU_IRELASZ and
DT_GNU_IRELAENT elements.
DT_GNU_IRELASZ
This element holds the total size, in bytes, of the DT_GNU_IRELA
relocation table.
DT_GNU_IRELAENT
This element holds the size, in bytes, of the DT_GNU_IRELA
relocation entry.
DT_GNU_IREL
This element is similar to DT_GNU_IRELA, except its table has
implicit addends, such as Elf32_Rel for the 32-bit file class or
Elf64_Rel for the 64-bit file class. If this element is present,
the dynamic structure must also have DT_GNU_IRELSZ and
DT_GNU_IRELENT elements.
DT_GNU_IRELSZ
This element holds the total size, in bytes, of the DT_GNU_IREL
relocation table.
DT_GNU_IRELENT
This element holds the size, in bytes, of the DT_GNU_IREL
relocation entry.
DT_GNU_ITEXTREL
This element holds the address of low and high addresses, in that
order, in non-writable segment where relocation entries apply.
Relocations in the indirect relocation table don't require name lookup
and their symbol values are zero. The value used in the relocation is
the program address returned by the function, which takes no arguments,
at the address of the result of the corresponding R_*_* relocation.
The purpose of the indirect relocation table to support executables and
avoid name lookup for locally defined STT_GNU_IFUNC symbols at load-time.
The indirect relocation table is optional. Either DT_GNU_IRELA or
DT_GNU_IREL may occur, not both. It should be processed as soon as the
object is relocated.
DT_GNU_ITEXTREL is required if the indirect relocation table contains
relocation entries which modify non-writable segment.
#define DT_VALRNGLO 0x6ffffd00
#define DT_GNU_IRELASZ 0x6ffffdf1
#define DT_GNU_IRELAENT 0x6ffffdf2
#define DT_GNU_IRELSZ 0x6ffffdf3
#define DT_GNU_IRELENT 0x6ffffdf4
#define DT_VALRNGHI 0x6ffffdff
#define DT_ADDRRNGLO 0x6ffffe00
#define DT_GNU_IRELA 0x6ffffef2
#define DT_GNU_IREL 0x6ffffef3
#define DT_GNU_ITEXTREL 0x6ffffef4
#define DT_ADDRRNGHI 0x6ffffeff