2 # Building vDSO images for x86.
5 # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
10 vdso-install-$(VDSO64-y) += vdso.so
13 # files to link into the vdso
14 vobjs-y := vdso-note.o um_vdso.o
16 # files to link into kernel
17 obj-$(VDSO64-y) += vdso.o vma.o
19 vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
21 $(obj)/vdso.o: $(obj)/vdso.so
23 targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y)
25 export CPPFLAGS_vdso.lds += -P -C
27 VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
28 -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
30 $(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
32 $(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE
33 $(call if_changed,vdso)
35 $(obj)/%.so: OBJCOPYFLAGS := -S
36 $(obj)/%.so: $(obj)/%.so.dbg FORCE
37 $(call if_changed,objcopy)
40 # Don't omit frame pointers for ease of userspace debugging, but do
41 # optimize sibling calls.
43 CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
44 $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \
45 -fno-omit-frame-pointer -foptimize-sibling-calls
47 $(vobjs): KBUILD_CFLAGS += $(CFL)
50 # vDSO code runs in userspace and -pg doesn't help with profiling anyway.
52 CFLAGS_REMOVE_vdso-note.o = -pg -fprofile-arcs -ftest-coverage
53 CFLAGS_REMOVE_um_vdso.o = -pg -fprofile-arcs -ftest-coverage
55 targets += vdso-syms.lds
56 obj-$(VDSO64-y) += vdso-syms.lds
59 # Match symbols in the DSO that look like VDSO*; produce a file of constants.
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 $@
65 $(NM) $< | LC_ALL=C sed -n $(sed-vdsosym) | LC_ALL=C sort > $@
68 $(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE
69 $(call if_changed,vdsosym)
72 # The DSO images are built using a special linker script.
74 quiet_cmd_vdso = VDSO $@
75 cmd_vdso = $(CC) -nostdlib -o $@ \
76 $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
77 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
78 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
80 VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
84 # Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
86 quiet_cmd_vdso_install = INSTALL $@
87 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
88 $(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
89 @mkdir -p $(MODLIB)/vdso
90 $(call cmd,vdso_install)
92 PHONY += vdso_install $(vdso-install-y)
93 vdso_install: $(vdso-install-y)