mirror of
https://github.com/torvalds/linux.git
synced 2024-11-18 10:01:43 +00:00
0b0bf7a3cc
The latest toolchains can produce a new ELF section in DSOs and dynamically-linked executables. The new section ".gnu.hash" replaces ".hash", and allows for more efficient runtime symbol lookups by the dynamic linker. The new ld option --hash-style={sysv|gnu|both} controls whether to produce the old ".hash", the new ".gnu.hash", or both. In some new systems such as Fedora Core 6, gcc by default passes --hash-style=gnu to the linker, so that a standard invocation of "gcc -shared" results in producing a DSO with only ".gnu.hash". The new ".gnu.hash" sections need to be dealt with the same way as ".hash" sections in all respects; only the dynamic linker cares about their contents. To work with older dynamic linkers (i.e. preexisting releases of glibc), a binary must have the old ".hash" section. The --hash-style=both option produces binaries that a new dynamic linker can use more efficiently, but an old dynamic linker can still handle. The new section runs afoul of the custom linker scripts used to build vDSO images for the kernel. On ia64, the failure mode for this is a boot-time panic because the vDSO's PT_IA_64_UNWIND segment winds up ill-formed. This patch addresses the problem in two ways. First, it mentions ".gnu.hash" in all the linker scripts alongside ".hash". This produces correct vDSO images with --hash-style=sysv (or old tools), with --hash-style=gnu, or with --hash-style=both. Second, it passes the --hash-style=sysv option when building the vDSO images, so that ".gnu.hash" is not actually produced. This is the most conservative choice for compatibility with any old userland. There is some concern that some ancient glibc builds (though not any known old production system) might choke on --hash-style=both binaries. The optimizations provided by the new style of hash section do not really matter for a DSO with a tiny number of symbols, as the vDSO has. If someone wants to use =gnu or =both for their vDSO builds and worry less about that compatibility, just change the option and the linker script changes will make any choice work fine. Signed-off-by: Roland McGrath <roland@redhat.com> Cc: "Luck, Tony" <tony.luck@intel.com> Cc: Kyle McMartin <kyle@mcmartin.ca> Cc: Paul Mackerras <paulus@samba.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Jeff Dike <jdike@addtoit.com> Cc: Andi Kleen <ak@muc.de> Cc: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
68 lines
1.9 KiB
ArmAsm
68 lines
1.9 KiB
ArmAsm
/*
|
|
* Linker script for vsyscall DSO. The vsyscall page is an ELF shared
|
|
* object prelinked to its virtual address, and with only one read-only
|
|
* segment (that fits in one page). This script controls its layout.
|
|
*/
|
|
#include <asm/asm-offsets.h>
|
|
|
|
SECTIONS
|
|
{
|
|
. = VDSO_PRELINK + SIZEOF_HEADERS;
|
|
|
|
.hash : { *(.hash) } :text
|
|
.gnu.hash : { *(.gnu.hash) }
|
|
.dynsym : { *(.dynsym) }
|
|
.dynstr : { *(.dynstr) }
|
|
.gnu.version : { *(.gnu.version) }
|
|
.gnu.version_d : { *(.gnu.version_d) }
|
|
.gnu.version_r : { *(.gnu.version_r) }
|
|
|
|
/* This linker script is used both with -r and with -shared.
|
|
For the layouts to match, we need to skip more than enough
|
|
space for the dynamic symbol table et al. If this amount
|
|
is insufficient, ld -shared will barf. Just increase it here. */
|
|
. = VDSO_PRELINK + 0x400;
|
|
|
|
.text : { *(.text) } :text =0x90909090
|
|
.note : { *(.note.*) } :text :note
|
|
.eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
|
|
.eh_frame : { KEEP (*(.eh_frame)) } :text
|
|
.dynamic : { *(.dynamic) } :text :dynamic
|
|
.useless : {
|
|
*(.got.plt) *(.got)
|
|
*(.data .data.* .gnu.linkonce.d.*)
|
|
*(.dynbss)
|
|
*(.bss .bss.* .gnu.linkonce.b.*)
|
|
} :text
|
|
}
|
|
|
|
/*
|
|
* We must supply the ELF program headers explicitly to get just one
|
|
* PT_LOAD segment, and set the flags explicitly to make segments read-only.
|
|
*/
|
|
PHDRS
|
|
{
|
|
text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */
|
|
dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
|
|
note PT_NOTE FLAGS(4); /* PF_R */
|
|
eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */
|
|
}
|
|
|
|
/*
|
|
* This controls what symbols we export from the DSO.
|
|
*/
|
|
VERSION
|
|
{
|
|
LINUX_2.5 {
|
|
global:
|
|
__kernel_vsyscall;
|
|
__kernel_sigreturn;
|
|
__kernel_rt_sigreturn;
|
|
|
|
local: *;
|
|
};
|
|
}
|
|
|
|
/* The ELF entry point can be used to set the AT_SYSINFO value. */
|
|
ENTRY(__kernel_vsyscall);
|