aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/vdso/Makefile78
-rw-r--r--arch/x86/vdso/vdso32/vdso32.lds.S37
2 files changed, 112 insertions, 3 deletions
diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
index 6a665dd09848..a02e1ca2a1bc 100644
--- a/arch/x86/vdso/Makefile
+++ b/arch/x86/vdso/Makefile
@@ -1,7 +1,15 @@
1# 1#
2# x86-64 vDSO. 2# Building vDSO images for x86.
3# 3#
4 4
5VDSO64-$(CONFIG_X86_64) := y
6VDSO32-$(CONFIG_X86_32) := y
7VDSO32-$(CONFIG_COMPAT) := y
8
9vdso-install-$(VDSO64-y) += vdso.so
10vdso-install-$(VDSO32-y) += $(vdso32-y:=.so)
11
12
5# files to link into the vdso 13# files to link into the vdso
6vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vvar.o 14vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vvar.o
7 15
@@ -57,10 +65,74 @@ quiet_cmd_vdsosym = VDSOSYM $@
57$(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE 65$(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE
58 $(call if_changed,vdsosym) 66 $(call if_changed,vdsosym)
59 67
68#
69# Build multiple 32-bit vDSO images to choose from at boot time.
70#
71vdso32.so-$(CONFIG_X86_32) += int80
72vdso32.so-$(VDSO32-y) += sysenter
73
74CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
75VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -Wl,-soname=linux-gate.so.1
76
77# This makes sure the $(obj) subdirectory exists even though vdso32/
78# is not a kbuild sub-make subdirectory.
79override obj-dirs = $(dir $(obj)) $(obj)/vdso32/
80
81targets += vdso32/vdso32.lds
82targets += $(vdso32.so-y:%=vdso32-%.so.dbg) $(vdso32.so-y:%=vdso32-%.so)
83targets += vdso32/note.o $(vdso32.so-y:%=vdso32/%.o)
84
85extra-y += $(vdso32.so-y:%=vdso32-%.so)
86
87KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS))
88$(vdso32.so-y:%=$(obj)/vdso32-%.so.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
89$(vdso32.so-y:%=$(obj)/vdso32-%.so.dbg): asflags-$(CONFIG_X86_64) += -m32
90
91$(vdso32.so-y:%=$(obj)/vdso32-%.so.dbg): $(obj)/vdso32-%.so.dbg: FORCE \
92 $(obj)/vdso32/vdso32.lds \
93 $(obj)/vdso32/note.o \
94 $(obj)/vdso32/%.o
95 $(call if_changed,vdso)
96
97# Make vdso32-*-syms.lds from each image, and then make sure they match.
98# The only difference should be that some do not define VDSO32_SYSENTER_RETURN.
99
100targets += vdso32-syms.lds $(vdso32.so-y:%=vdso32-%-syms.lds)
101
102quiet_cmd_vdso32sym = VDSOSYM $@
103define cmd_vdso32sym
104 if LC_ALL=C sort -u $(filter-out FORCE,$^) > $(@D)/.tmp_$(@F) && \
105 $(foreach H,$(filter-out FORCE,$^),\
106 if grep -q VDSO32_SYSENTER_RETURN $H; \
107 then diff -u $(@D)/.tmp_$(@F) $H; \
108 else sed /VDSO32_SYSENTER_RETURN/d $(@D)/.tmp_$(@F) | \
109 diff -u - $H; fi &&) : ;\
110 then mv -f $(@D)/.tmp_$(@F) $@; \
111 else rm -f $(@D)/.tmp_$(@F); exit 1; \
112 fi
113endef
114
115$(obj)/vdso32-syms.lds: $(vdso32.so-y:%=$(obj)/vdso32-%-syms.lds) FORCE
116 $(call if_changed,vdso32sym)
117
118#
119# The DSO images are built using a special linker script.
120#
121quiet_cmd_vdso = VDSO $@
122 cmd_vdso = $(CC) -nostdlib -o $@ \
123 $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
124 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^)
125
126VDSO_LDFLAGS = -fPIC -shared $(call ld-option, -Wl$(comma)--hash-style=sysv)
127
128#
129# Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
130#
60quiet_cmd_vdso_install = INSTALL $@ 131quiet_cmd_vdso_install = INSTALL $@
61 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ 132 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
62vdso.so: 133$(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
63 @mkdir -p $(MODLIB)/vdso 134 @mkdir -p $(MODLIB)/vdso
64 $(call cmd,vdso_install) 135 $(call cmd,vdso_install)
65 136
66vdso_install: vdso.so 137PHONY += vdso_install $(vdso-install-y)
138vdso_install: $(vdso-install-y)
diff --git a/arch/x86/vdso/vdso32/vdso32.lds.S b/arch/x86/vdso/vdso32/vdso32.lds.S
new file mode 100644
index 000000000000..976124bb5f92
--- /dev/null
+++ b/arch/x86/vdso/vdso32/vdso32.lds.S
@@ -0,0 +1,37 @@
1/*
2 * Linker script for 32-bit vDSO.
3 * We #include the file to define the layout details.
4 * Here we only choose the prelinked virtual address.
5 *
6 * This file defines the version script giving the user-exported symbols in
7 * the DSO. We can define local symbols here called VDSO* to make their
8 * values visible using the asm-x86/vdso.h macros from the kernel proper.
9 */
10
11#define VDSO_PRELINK 0
12#include "../vdso-layout.lds.S"
13
14/* The ELF entry point can be used to set the AT_SYSINFO value. */
15ENTRY(__kernel_vsyscall);
16
17/*
18 * This controls what userland symbols we export from the vDSO.
19 */
20VERSION
21{
22 LINUX_2.5 {
23 global:
24 __kernel_vsyscall;
25 __kernel_sigreturn;
26 __kernel_rt_sigreturn;
27 local: *;
28 };
29}
30
31/*
32 * Symbols we define here called VDSO* get their values into vdso32-syms.h.
33 */
34VDSO32_PRELINK = VDSO_PRELINK;
35VDSO32_vsyscall = __kernel_vsyscall;
36VDSO32_sigreturn = __kernel_sigreturn;
37VDSO32_rt_sigreturn = __kernel_rt_sigreturn;