]>
Commit | Line | Data |
---|---|---|
1 | # | |
2 | # Building vDSO images for x86. | |
3 | # | |
4 | ||
5 | VDSO64-$(CONFIG_X86_64) := y | |
6 | VDSO32-$(CONFIG_X86_32) := y | |
7 | VDSO32-$(CONFIG_COMPAT) := y | |
8 | ||
9 | vdso-install-$(VDSO64-y) += vdso.so | |
10 | vdso-install-$(VDSO32-y) += $(vdso32-y:=.so) | |
11 | ||
12 | ||
13 | # files to link into the vdso | |
14 | vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vvar.o | |
15 | ||
16 | # files to link into kernel | |
17 | obj-$(VDSO64-y) += vma.o vdso.o | |
18 | obj-$(CONFIG_X86_32) += vdso32.o vdso32-setup.o | |
19 | ||
20 | vobjs := $(foreach F,$(vobjs-y),$(obj)/$F) | |
21 | ||
22 | $(obj)/vdso.o: $(obj)/vdso.so | |
23 | ||
24 | targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y) | |
25 | ||
26 | # The DSO images are built using a special linker script. | |
27 | quiet_cmd_syscall = SYSCALL $@ | |
28 | cmd_syscall = $(CC) -m elf_x86_64 -nostdlib $(SYSCFLAGS_$(@F)) \ | |
29 | -Wl,-T,$(filter-out FORCE,$^) -o $@ | |
30 | ||
31 | export CPPFLAGS_vdso.lds += -P -C | |
32 | ||
33 | vdso-flags = -fPIC -shared -Wl,-soname=linux-vdso.so.1 \ | |
34 | $(call ld-option, -Wl$(comma)--hash-style=sysv) \ | |
35 | -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 | |
36 | SYSCFLAGS_vdso.so = $(vdso-flags) | |
37 | SYSCFLAGS_vdso.so.dbg = $(vdso-flags) | |
38 | ||
39 | $(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so | |
40 | ||
41 | $(obj)/vdso.so: $(src)/vdso.lds $(vobjs) FORCE | |
42 | ||
43 | $(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE | |
44 | $(call if_changed,syscall) | |
45 | ||
46 | $(obj)/%.so: OBJCOPYFLAGS := -S | |
47 | $(obj)/%.so: $(obj)/%.so.dbg FORCE | |
48 | $(call if_changed,objcopy) | |
49 | ||
50 | CFL := $(PROFILING) -mcmodel=small -fPIC -g0 -O2 -fasynchronous-unwind-tables -m64 | |
51 | ||
52 | $(obj)/vclock_gettime.o: KBUILD_CFLAGS = $(CFL) | |
53 | $(obj)/vgetcpu.o: KBUILD_CFLAGS = $(CFL) | |
54 | ||
55 | targets += vdso-syms.lds | |
56 | obj-$(VDSO64-y) += vdso-syms.lds | |
57 | ||
58 | # | |
59 | # Match symbols in the DSO that look like VDSO*; produce a file of constants. | |
60 | # | |
61 | sed-vdsosym := -e 's/^00*/0/' \ | |
62 | -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p' | |
63 | quiet_cmd_vdsosym = VDSOSYM $@ | |
64 | cmd_vdsosym = $(NM) $< | sed -n $(sed-vdsosym) | LC_ALL=C sort > $@ | |
65 | ||
66 | $(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE | |
67 | $(call if_changed,vdsosym) | |
68 | ||
69 | # | |
70 | # Build multiple 32-bit vDSO images to choose from at boot time. | |
71 | # | |
72 | obj-$(VDSO32-y) += vdso32-syms.lds | |
73 | vdso32.so-$(CONFIG_X86_32) += int80 | |
74 | vdso32.so-$(VDSO32-y) += sysenter | |
75 | ||
76 | CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds) | |
77 | VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -Wl,-soname=linux-gate.so.1 | |
78 | ||
79 | # This makes sure the $(obj) subdirectory exists even though vdso32/ | |
80 | # is not a kbuild sub-make subdirectory. | |
81 | override obj-dirs = $(dir $(obj)) $(obj)/vdso32/ | |
82 | ||
83 | targets += vdso32/vdso32.lds | |
84 | targets += $(vdso32.so-y:%=vdso32-%.so.dbg) $(vdso32.so-y:%=vdso32-%.so) | |
85 | targets += vdso32/note.o $(vdso32.so-y:%=vdso32/%.o) | |
86 | ||
87 | extra-y += $(vdso32.so-y:%=vdso32-%.so) | |
88 | ||
89 | $(obj)/vdso32.o: $(vdso32.so-y:%=$(obj)/vdso32-%.so) | |
90 | ||
91 | KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) | |
92 | $(vdso32.so-y:%=$(obj)/vdso32-%.so.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32) | |
93 | $(vdso32.so-y:%=$(obj)/vdso32-%.so.dbg): asflags-$(CONFIG_X86_64) += -m32 | |
94 | ||
95 | $(vdso32.so-y:%=$(obj)/vdso32-%.so.dbg): $(obj)/vdso32-%.so.dbg: FORCE \ | |
96 | $(obj)/vdso32/vdso32.lds \ | |
97 | $(obj)/vdso32/note.o \ | |
98 | $(obj)/vdso32/%.o | |
99 | $(call if_changed,vdso) | |
100 | ||
101 | # Make vdso32-*-syms.lds from each image, and then make sure they match. | |
102 | # The only difference should be that some do not define VDSO32_SYSENTER_RETURN. | |
103 | ||
104 | targets += vdso32-syms.lds $(vdso32.so-y:%=vdso32-%-syms.lds) | |
105 | ||
106 | quiet_cmd_vdso32sym = VDSOSYM $@ | |
107 | define cmd_vdso32sym | |
108 | if LC_ALL=C sort -u $(filter-out FORCE,$^) > $(@D)/.tmp_$(@F) && \ | |
109 | $(foreach H,$(filter-out FORCE,$^),\ | |
110 | if grep -q VDSO32_SYSENTER_RETURN $H; \ | |
111 | then diff -u $(@D)/.tmp_$(@F) $H; \ | |
112 | else sed /VDSO32_SYSENTER_RETURN/d $(@D)/.tmp_$(@F) | \ | |
113 | diff -u - $H; fi &&) : ;\ | |
114 | then mv -f $(@D)/.tmp_$(@F) $@; \ | |
115 | else rm -f $(@D)/.tmp_$(@F); exit 1; \ | |
116 | fi | |
117 | endef | |
118 | ||
119 | $(obj)/vdso32-syms.lds: $(vdso32.so-y:%=$(obj)/vdso32-%-syms.lds) FORCE | |
120 | $(call if_changed,vdso32sym) | |
121 | ||
122 | # | |
123 | # The DSO images are built using a special linker script. | |
124 | # | |
125 | quiet_cmd_vdso = VDSO $@ | |
126 | cmd_vdso = $(CC) -nostdlib -o $@ \ | |
127 | $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \ | |
128 | -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) | |
129 | ||
130 | VDSO_LDFLAGS = -fPIC -shared $(call ld-option, -Wl$(comma)--hash-style=sysv) | |
131 | ||
132 | # | |
133 | # Install the unstripped copy of vdso*.so listed in $(vdso-install-y). | |
134 | # | |
135 | quiet_cmd_vdso_install = INSTALL $@ | |
136 | cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ | |
137 | $(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE | |
138 | @mkdir -p $(MODLIB)/vdso | |
139 | $(call cmd,vdso_install) | |
140 | ||
141 | PHONY += vdso_install $(vdso-install-y) | |
142 | vdso_install: $(vdso-install-y) |