blob: f385a4b4a484e36d3262ca154b96dcfd596b7510 [file] [log] [blame]
Andi Kleen2aae9502007-07-21 17:10:01 +02001#
Roland McGrath0249c9c2008-01-30 13:30:42 +01002# Building vDSO images for x86.
Andi Kleen2aae9502007-07-21 17:10:01 +02003#
4
Roland McGrath0249c9c2008-01-30 13:30:42 +01005VDSO64-$(CONFIG_X86_64) := y
6VDSO32-$(CONFIG_X86_32) := y
7VDSO32-$(CONFIG_COMPAT) := y
8
9vdso-install-$(VDSO64-y) += vdso.so
Roland McGrath2c158262008-02-11 14:38:51 -080010vdso-install-$(VDSO32-y) += $(vdso32-images)
Roland McGrath0249c9c2008-01-30 13:30:42 +010011
12
Andi Kleen2aae9502007-07-21 17:10:01 +020013# files to link into the vdso
Roland McGrath7f3646a2008-01-30 13:30:41 +010014vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vvar.o
Andi Kleen2aae9502007-07-21 17:10:01 +020015
16# files to link into kernel
Roland McGrath6c3652e2008-01-30 13:30:42 +010017obj-$(VDSO64-y) += vma.o vdso.o
Roland McGrathaf65d642008-01-30 13:30:43 +010018obj-$(VDSO32-y) += vdso32.o vdso32-setup.o
Andi Kleen2aae9502007-07-21 17:10:01 +020019
20vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
21
22$(obj)/vdso.o: $(obj)/vdso.so
23
Roland McGrath2b9c97e2008-01-30 13:30:41 +010024targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y)
Andi Kleen2aae9502007-07-21 17:10:01 +020025
Sam Ravnborgd746d642007-11-12 20:14:19 +010026export CPPFLAGS_vdso.lds += -P -C
Andi Kleen2aae9502007-07-21 17:10:01 +020027
Roland McGrath16e48e72008-01-30 13:30:44 +010028VDSO_LDFLAGS_vdso.lds = -m elf_x86_64 -Wl,-soname=linux-vdso.so.1 \
29 -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
Andi Kleen2aae9502007-07-21 17:10:01 +020030
31$(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
32
Roland McGrathf79eb832007-10-17 18:04:32 +020033$(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE
Roland McGrath16e48e72008-01-30 13:30:44 +010034 $(call if_changed,vdso)
Andi Kleen2aae9502007-07-21 17:10:01 +020035
Roland McGrathf79eb832007-10-17 18:04:32 +020036$(obj)/%.so: OBJCOPYFLAGS := -S
37$(obj)/%.so: $(obj)/%.so.dbg FORCE
38 $(call if_changed,objcopy)
39
Andi Kleen037e20a2007-07-22 21:13:11 +020040CFL := $(PROFILING) -mcmodel=small -fPIC -g0 -O2 -fasynchronous-unwind-tables -m64
Andi Kleen2aae9502007-07-21 17:10:01 +020041
Roland McGrath16e48e72008-01-30 13:30:44 +010042$(vobjs): KBUILD_CFLAGS = $(CFL)
Andi Kleen2aae9502007-07-21 17:10:01 +020043
Roland McGrath5b930492008-01-30 13:30:40 +010044targets += vdso-syms.lds
Roland McGrath6c3652e2008-01-30 13:30:42 +010045obj-$(VDSO64-y) += vdso-syms.lds
Roland McGrath5b930492008-01-30 13:30:40 +010046
47#
48# Match symbols in the DSO that look like VDSO*; produce a file of constants.
49#
50sed-vdsosym := -e 's/^00*/0/' \
51 -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p'
52quiet_cmd_vdsosym = VDSOSYM $@
53 cmd_vdsosym = $(NM) $< | sed -n $(sed-vdsosym) | LC_ALL=C sort > $@
54
55$(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE
56 $(call if_changed,vdsosym)
57
Roland McGrath0249c9c2008-01-30 13:30:42 +010058#
59# Build multiple 32-bit vDSO images to choose from at boot time.
60#
Roland McGrath6c3652e2008-01-30 13:30:42 +010061obj-$(VDSO32-y) += vdso32-syms.lds
Roland McGrath0249c9c2008-01-30 13:30:42 +010062vdso32.so-$(CONFIG_X86_32) += int80
Roland McGrath00f8b1b2008-01-30 13:30:43 +010063vdso32.so-$(CONFIG_COMPAT) += syscall
Roland McGrath0249c9c2008-01-30 13:30:42 +010064vdso32.so-$(VDSO32-y) += sysenter
65
Roland McGrath2c158262008-02-11 14:38:51 -080066vdso32-images = $(vdso32.so-y:%=vdso32-%.so)
67
Roland McGrath0249c9c2008-01-30 13:30:42 +010068CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
69VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -Wl,-soname=linux-gate.so.1
70
71# This makes sure the $(obj) subdirectory exists even though vdso32/
72# is not a kbuild sub-make subdirectory.
73override obj-dirs = $(dir $(obj)) $(obj)/vdso32/
74
75targets += vdso32/vdso32.lds
Roland McGrath2c158262008-02-11 14:38:51 -080076targets += $(vdso32-images) $(vdso32-images:=.dbg)
Roland McGrath0249c9c2008-01-30 13:30:42 +010077targets += vdso32/note.o $(vdso32.so-y:%=vdso32/%.o)
78
Roland McGrath2c158262008-02-11 14:38:51 -080079extra-y += $(vdso32-images)
Roland McGrath0249c9c2008-01-30 13:30:42 +010080
Roland McGrath2c158262008-02-11 14:38:51 -080081$(obj)/vdso32.o: $(vdso32-images:%=$(obj)/%)
Roland McGrath6c3652e2008-01-30 13:30:42 +010082
Roland McGrath0249c9c2008-01-30 13:30:42 +010083KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS))
Roland McGrath2c158262008-02-11 14:38:51 -080084$(vdso32-images:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
85$(vdso32-images:%=$(obj)/%.dbg): asflags-$(CONFIG_X86_64) += -m32
Roland McGrath0249c9c2008-01-30 13:30:42 +010086
Roland McGrath2c158262008-02-11 14:38:51 -080087$(vdso32-images:%=$(obj)/%.dbg): $(obj)/vdso32-%.so.dbg: FORCE \
88 $(obj)/vdso32/vdso32.lds \
89 $(obj)/vdso32/note.o \
90 $(obj)/vdso32/%.o
Roland McGrath0249c9c2008-01-30 13:30:42 +010091 $(call if_changed,vdso)
92
93# Make vdso32-*-syms.lds from each image, and then make sure they match.
94# The only difference should be that some do not define VDSO32_SYSENTER_RETURN.
95
96targets += vdso32-syms.lds $(vdso32.so-y:%=vdso32-%-syms.lds)
97
98quiet_cmd_vdso32sym = VDSOSYM $@
99define cmd_vdso32sym
100 if LC_ALL=C sort -u $(filter-out FORCE,$^) > $(@D)/.tmp_$(@F) && \
101 $(foreach H,$(filter-out FORCE,$^),\
102 if grep -q VDSO32_SYSENTER_RETURN $H; \
103 then diff -u $(@D)/.tmp_$(@F) $H; \
104 else sed /VDSO32_SYSENTER_RETURN/d $(@D)/.tmp_$(@F) | \
105 diff -u - $H; fi &&) : ;\
106 then mv -f $(@D)/.tmp_$(@F) $@; \
107 else rm -f $(@D)/.tmp_$(@F); exit 1; \
108 fi
109endef
110
111$(obj)/vdso32-syms.lds: $(vdso32.so-y:%=$(obj)/vdso32-%-syms.lds) FORCE
112 $(call if_changed,vdso32sym)
113
114#
115# The DSO images are built using a special linker script.
116#
117quiet_cmd_vdso = VDSO $@
118 cmd_vdso = $(CC) -nostdlib -o $@ \
119 $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
120 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^)
121
122VDSO_LDFLAGS = -fPIC -shared $(call ld-option, -Wl$(comma)--hash-style=sysv)
123
124#
125# Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
126#
Roland McGrathf79eb832007-10-17 18:04:32 +0200127quiet_cmd_vdso_install = INSTALL $@
128 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
Roland McGrath0249c9c2008-01-30 13:30:42 +0100129$(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
Roland McGrathf79eb832007-10-17 18:04:32 +0200130 @mkdir -p $(MODLIB)/vdso
131 $(call cmd,vdso_install)
132
Roland McGrath0249c9c2008-01-30 13:30:42 +0100133PHONY += vdso_install $(vdso-install-y)
134vdso_install: $(vdso-install-y)
Sam Ravnborgd531b4f2008-01-30 13:32:27 +0100135
136clean-files := vdso32-syscall* vdso32-sysenter* vdso32-int80*