xref: /linux/arch/x86/um/vdso/Makefile (revision 915eed20e40f4dcb142cb29a3de6f6ba67f4bb5a)
15c48b108SAl Viro#
25c48b108SAl Viro# Building vDSO images for x86.
35c48b108SAl Viro#
45c48b108SAl Viro
5*915eed20SVegard Nossum# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
6*915eed20SVegard NossumKCOV_INSTRUMENT                := n
7*915eed20SVegard Nossum
85c48b108SAl ViroVDSO64-y		:= y
95c48b108SAl Viro
105c48b108SAl Virovdso-install-$(VDSO64-y)	+= vdso.so
115c48b108SAl Viro
125c48b108SAl Viro
135c48b108SAl Viro# files to link into the vdso
145c48b108SAl Virovobjs-y := vdso-note.o um_vdso.o
155c48b108SAl Viro
165c48b108SAl Viro# files to link into kernel
175c48b108SAl Viroobj-$(VDSO64-y)			+= vdso.o vma.o
185c48b108SAl Viro
195c48b108SAl Virovobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
205c48b108SAl Viro
215c48b108SAl Viro$(obj)/vdso.o: $(obj)/vdso.so
225c48b108SAl Viro
235c48b108SAl Virotargets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y)
245c48b108SAl Viro
255c48b108SAl Viroexport CPPFLAGS_vdso.lds += -P -C
265c48b108SAl Viro
275c48b108SAl ViroVDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
285c48b108SAl Viro       -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
295c48b108SAl Viro
305c48b108SAl Viro$(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
315c48b108SAl Viro
325c48b108SAl Viro$(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE
335c48b108SAl Viro	$(call if_changed,vdso)
345c48b108SAl Viro
355c48b108SAl Viro$(obj)/%.so: OBJCOPYFLAGS := -S
365c48b108SAl Viro$(obj)/%.so: $(obj)/%.so.dbg FORCE
375c48b108SAl Viro	$(call if_changed,objcopy)
385c48b108SAl Viro
395c48b108SAl Viro#
405c48b108SAl Viro# Don't omit frame pointers for ease of userspace debugging, but do
415c48b108SAl Viro# optimize sibling calls.
425c48b108SAl Viro#
435c48b108SAl ViroCFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
445c48b108SAl Viro       $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \
455c48b108SAl Viro       -fno-omit-frame-pointer -foptimize-sibling-calls
465c48b108SAl Viro
475c48b108SAl Viro$(vobjs): KBUILD_CFLAGS += $(CFL)
485c48b108SAl Viro
495c48b108SAl Viro#
505c48b108SAl Viro# vDSO code runs in userspace and -pg doesn't help with profiling anyway.
515c48b108SAl Viro#
524d211093SAl ViroCFLAGS_REMOVE_vdso-note.o = -pg -fprofile-arcs -ftest-coverage
534d211093SAl ViroCFLAGS_REMOVE_um_vdso.o = -pg -fprofile-arcs -ftest-coverage
545c48b108SAl Viro
555c48b108SAl Virotargets += vdso-syms.lds
565c48b108SAl Viroobj-$(VDSO64-y)			+= vdso-syms.lds
575c48b108SAl Viro
585c48b108SAl Viro#
595c48b108SAl Viro# Match symbols in the DSO that look like VDSO*; produce a file of constants.
605c48b108SAl Viro#
615c48b108SAl Virosed-vdsosym := -e 's/^00*/0/' \
625c48b108SAl Viro	-e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p'
635c48b108SAl Viroquiet_cmd_vdsosym = VDSOSYM $@
645c48b108SAl Virodefine cmd_vdsosym
655c48b108SAl Viro	$(NM) $< | LC_ALL=C sed -n $(sed-vdsosym) | LC_ALL=C sort > $@
665c48b108SAl Viroendef
675c48b108SAl Viro
685c48b108SAl Viro$(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE
695c48b108SAl Viro	$(call if_changed,vdsosym)
705c48b108SAl Viro
715c48b108SAl Viro#
725c48b108SAl Viro# The DSO images are built using a special linker script.
735c48b108SAl Viro#
745c48b108SAl Viroquiet_cmd_vdso = VDSO    $@
755c48b108SAl Viro      cmd_vdso = $(CC) -nostdlib -o $@ \
765c48b108SAl Viro		       $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
775c48b108SAl Viro		       -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
785c48b108SAl Viro		 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
795c48b108SAl Viro
805c48b108SAl ViroVDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
815c48b108SAl ViroGCOV_PROFILE := n
825c48b108SAl Viro
835c48b108SAl Viro#
845c48b108SAl Viro# Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
855c48b108SAl Viro#
865c48b108SAl Viroquiet_cmd_vdso_install = INSTALL $@
875c48b108SAl Viro      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
885c48b108SAl Viro$(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
895c48b108SAl Viro	@mkdir -p $(MODLIB)/vdso
905c48b108SAl Viro	$(call cmd,vdso_install)
915c48b108SAl Viro
925c48b108SAl ViroPHONY += vdso_install $(vdso-install-y)
935c48b108SAl Virovdso_install: $(vdso-install-y)
94