blob: 4d6ef0a336d6d3499580b32958d59c93639bc647 [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
Roland McGrath8705a492008-04-14 12:19:30 -070040CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
41 $(filter -g%,$(KBUILD_CFLAGS))
Andi Kleen2aae9502007-07-21 17:10:01 +020042
Glauber de Oliveira Costaf6bc4022008-03-19 14:25:53 -030043$(vobjs): KBUILD_CFLAGS += $(CFL)
Andi Kleen2aae9502007-07-21 17:10:01 +020044
Roland McGrath5b930492008-01-30 13:30:40 +010045targets += vdso-syms.lds
Roland McGrath6c3652e2008-01-30 13:30:42 +010046obj-$(VDSO64-y) += vdso-syms.lds
Roland McGrath5b930492008-01-30 13:30:40 +010047
48#
49# Match symbols in the DSO that look like VDSO*; produce a file of constants.
50#
51sed-vdsosym := -e 's/^00*/0/' \
Roland McGrathf2dbe032008-02-27 11:42:15 -080052 -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p'
Roland McGrath5b930492008-01-30 13:30:40 +010053quiet_cmd_vdsosym = VDSOSYM $@
Roland McGrathf2dbe032008-02-27 11:42:15 -080054define cmd_vdsosym
55 $(NM) $< | LC_ALL=C sed -n $(sed-vdsosym) | LC_ALL=C sort > $@
56endef
Roland McGrath5b930492008-01-30 13:30:40 +010057
58$(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE
59 $(call if_changed,vdsosym)
60
Roland McGrath0249c9c2008-01-30 13:30:42 +010061#
62# Build multiple 32-bit vDSO images to choose from at boot time.
63#
Roland McGrath6c3652e2008-01-30 13:30:42 +010064obj-$(VDSO32-y) += vdso32-syms.lds
Jeremy Fitzhardinge6a52e4b2008-07-12 02:22:00 -070065vdso32.so-$(VDSO32-y) += int80
Roland McGrath00f8b1b2008-01-30 13:30:43 +010066vdso32.so-$(CONFIG_COMPAT) += syscall
Roland McGrath0249c9c2008-01-30 13:30:42 +010067vdso32.so-$(VDSO32-y) += sysenter
68
Roland McGrath2c158262008-02-11 14:38:51 -080069vdso32-images = $(vdso32.so-y:%=vdso32-%.so)
70
Roland McGrath0249c9c2008-01-30 13:30:42 +010071CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
72VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -Wl,-soname=linux-gate.so.1
73
74# This makes sure the $(obj) subdirectory exists even though vdso32/
75# is not a kbuild sub-make subdirectory.
76override obj-dirs = $(dir $(obj)) $(obj)/vdso32/
77
78targets += vdso32/vdso32.lds
Roland McGrath2c158262008-02-11 14:38:51 -080079targets += $(vdso32-images) $(vdso32-images:=.dbg)
Roland McGrath0249c9c2008-01-30 13:30:42 +010080targets += vdso32/note.o $(vdso32.so-y:%=vdso32/%.o)
81
Roland McGrath2c158262008-02-11 14:38:51 -080082extra-y += $(vdso32-images)
Roland McGrath0249c9c2008-01-30 13:30:42 +010083
Roland McGrath2c158262008-02-11 14:38:51 -080084$(obj)/vdso32.o: $(vdso32-images:%=$(obj)/%)
Roland McGrath6c3652e2008-01-30 13:30:42 +010085
Roland McGrath0249c9c2008-01-30 13:30:42 +010086KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS))
Roland McGrath2c158262008-02-11 14:38:51 -080087$(vdso32-images:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
88$(vdso32-images:%=$(obj)/%.dbg): asflags-$(CONFIG_X86_64) += -m32
Roland McGrath0249c9c2008-01-30 13:30:42 +010089
Roland McGrath2c158262008-02-11 14:38:51 -080090$(vdso32-images:%=$(obj)/%.dbg): $(obj)/vdso32-%.so.dbg: FORCE \
91 $(obj)/vdso32/vdso32.lds \
92 $(obj)/vdso32/note.o \
93 $(obj)/vdso32/%.o
Roland McGrath0249c9c2008-01-30 13:30:42 +010094 $(call if_changed,vdso)
95
96# Make vdso32-*-syms.lds from each image, and then make sure they match.
97# The only difference should be that some do not define VDSO32_SYSENTER_RETURN.
98
99targets += vdso32-syms.lds $(vdso32.so-y:%=vdso32-%-syms.lds)
100
101quiet_cmd_vdso32sym = VDSOSYM $@
102define cmd_vdso32sym
103 if LC_ALL=C sort -u $(filter-out FORCE,$^) > $(@D)/.tmp_$(@F) && \
104 $(foreach H,$(filter-out FORCE,$^),\
105 if grep -q VDSO32_SYSENTER_RETURN $H; \
106 then diff -u $(@D)/.tmp_$(@F) $H; \
107 else sed /VDSO32_SYSENTER_RETURN/d $(@D)/.tmp_$(@F) | \
108 diff -u - $H; fi &&) : ;\
109 then mv -f $(@D)/.tmp_$(@F) $@; \
110 else rm -f $(@D)/.tmp_$(@F); exit 1; \
111 fi
112endef
113
114$(obj)/vdso32-syms.lds: $(vdso32.so-y:%=$(obj)/vdso32-%-syms.lds) FORCE
115 $(call if_changed,vdso32sym)
116
117#
118# The DSO images are built using a special linker script.
119#
120quiet_cmd_vdso = VDSO $@
121 cmd_vdso = $(CC) -nostdlib -o $@ \
122 $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
123 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^)
124
125VDSO_LDFLAGS = -fPIC -shared $(call ld-option, -Wl$(comma)--hash-style=sysv)
126
127#
128# Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
129#
Roland McGrathf79eb832007-10-17 18:04:32 +0200130quiet_cmd_vdso_install = INSTALL $@
131 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
Roland McGrath0249c9c2008-01-30 13:30:42 +0100132$(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
Roland McGrathf79eb832007-10-17 18:04:32 +0200133 @mkdir -p $(MODLIB)/vdso
134 $(call cmd,vdso_install)
135
Roland McGrath0249c9c2008-01-30 13:30:42 +0100136PHONY += vdso_install $(vdso-install-y)
137vdso_install: $(vdso-install-y)
Sam Ravnborgd531b4f2008-01-30 13:32:27 +0100138
139clean-files := vdso32-syscall* vdso32-sysenter* vdso32-int80*