x86: prepare for the unification of the cpa code
[wrt350n-kernel.git] / arch / x86 / vdso / Makefile
blobd28dda574700949f12c6301cf7f5f85457256e8b
2 # Building vDSO images for x86.
5 VDSO64-$(CONFIG_X86_64) := y
6 VDSO32-$(CONFIG_X86_32) := y
7 VDSO32-$(CONFIG_COMPAT) := y
9 vdso-install-$(VDSO64-y) += vdso.so
10 vdso-install-$(VDSO32-y) += $(vdso32-y:=.so)
13 # files to link into the vdso
14 vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vvar.o
16 # files to link into kernel
17 obj-$(VDSO64-y) += vma.o vdso.o
18 obj-$(VDSO32-y) += vdso32.o vdso32-setup.o
20 vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
22 $(obj)/vdso.o: $(obj)/vdso.so
24 targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y)
26 export CPPFLAGS_vdso.lds += -P -C
28 VDSO_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
31 $(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
33 $(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE
34 $(call if_changed,vdso)
36 $(obj)/%.so: OBJCOPYFLAGS := -S
37 $(obj)/%.so: $(obj)/%.so.dbg FORCE
38 $(call if_changed,objcopy)
40 CFL := $(PROFILING) -mcmodel=small -fPIC -g0 -O2 -fasynchronous-unwind-tables -m64
42 $(vobjs): KBUILD_CFLAGS = $(CFL)
44 targets += vdso-syms.lds
45 obj-$(VDSO64-y) += vdso-syms.lds
48 # Match symbols in the DSO that look like VDSO*; produce a file of constants.
50 sed-vdsosym := -e 's/^00*/0/' \
51 -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p'
52 quiet_cmd_vdsosym = VDSOSYM $@
53 cmd_vdsosym = $(NM) $< | sed -n $(sed-vdsosym) | LC_ALL=C sort > $@
55 $(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE
56 $(call if_changed,vdsosym)
59 # Build multiple 32-bit vDSO images to choose from at boot time.
61 obj-$(VDSO32-y) += vdso32-syms.lds
62 vdso32.so-$(CONFIG_X86_32) += int80
63 vdso32.so-$(CONFIG_COMPAT) += syscall
64 vdso32.so-$(VDSO32-y) += sysenter
66 CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds)
67 VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -Wl,-soname=linux-gate.so.1
69 # This makes sure the $(obj) subdirectory exists even though vdso32/
70 # is not a kbuild sub-make subdirectory.
71 override obj-dirs = $(dir $(obj)) $(obj)/vdso32/
73 targets += vdso32/vdso32.lds
74 targets += $(vdso32.so-y:%=vdso32-%.so.dbg) $(vdso32.so-y:%=vdso32-%.so)
75 targets += vdso32/note.o $(vdso32.so-y:%=vdso32/%.o)
77 extra-y += $(vdso32.so-y:%=vdso32-%.so)
79 $(obj)/vdso32.o: $(vdso32.so-y:%=$(obj)/vdso32-%.so)
81 KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS))
82 $(vdso32.so-y:%=$(obj)/vdso32-%.so.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
83 $(vdso32.so-y:%=$(obj)/vdso32-%.so.dbg): asflags-$(CONFIG_X86_64) += -m32
85 $(vdso32.so-y:%=$(obj)/vdso32-%.so.dbg): $(obj)/vdso32-%.so.dbg: FORCE \
86 $(obj)/vdso32/vdso32.lds \
87 $(obj)/vdso32/note.o \
88 $(obj)/vdso32/%.o
89 $(call if_changed,vdso)
91 # Make vdso32-*-syms.lds from each image, and then make sure they match.
92 # The only difference should be that some do not define VDSO32_SYSENTER_RETURN.
94 targets += vdso32-syms.lds $(vdso32.so-y:%=vdso32-%-syms.lds)
96 quiet_cmd_vdso32sym = VDSOSYM $@
97 define cmd_vdso32sym
98 if LC_ALL=C sort -u $(filter-out FORCE,$^) > $(@D)/.tmp_$(@F) && \
99 $(foreach H,$(filter-out FORCE,$^),\
100 if grep -q VDSO32_SYSENTER_RETURN $H; \
101 then diff -u $(@D)/.tmp_$(@F) $H; \
102 else sed /VDSO32_SYSENTER_RETURN/d $(@D)/.tmp_$(@F) | \
103 diff -u - $H; fi &&) : ;\
104 then mv -f $(@D)/.tmp_$(@F) $@; \
105 else rm -f $(@D)/.tmp_$(@F); exit 1; \
107 endef
109 $(obj)/vdso32-syms.lds: $(vdso32.so-y:%=$(obj)/vdso32-%-syms.lds) FORCE
110 $(call if_changed,vdso32sym)
113 # The DSO images are built using a special linker script.
115 quiet_cmd_vdso = VDSO $@
116 cmd_vdso = $(CC) -nostdlib -o $@ \
117 $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
118 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^)
120 VDSO_LDFLAGS = -fPIC -shared $(call ld-option, -Wl$(comma)--hash-style=sysv)
123 # Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
125 quiet_cmd_vdso_install = INSTALL $@
126 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
127 $(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
128 @mkdir -p $(MODLIB)/vdso
129 $(call cmd,vdso_install)
131 PHONY += vdso_install $(vdso-install-y)
132 vdso_install: $(vdso-install-y)
134 clean-files := vdso32-syscall* vdso32-sysenter* vdso32-int80*