xref: /linux/arch/x86/um/vdso/Makefile (revision 5c48b108ecbf6505d929e64d50dace13ac2bdf34)
1*5c48b108SAl Viro#
2*5c48b108SAl Viro# Building vDSO images for x86.
3*5c48b108SAl Viro#
4*5c48b108SAl Viro
5*5c48b108SAl ViroVDSO64-y		:= y
6*5c48b108SAl Viro
7*5c48b108SAl Virovdso-install-$(VDSO64-y)	+= vdso.so
8*5c48b108SAl Viro
9*5c48b108SAl Viro
10*5c48b108SAl Viro# files to link into the vdso
11*5c48b108SAl Virovobjs-y := vdso-note.o um_vdso.o
12*5c48b108SAl Viro
13*5c48b108SAl Viro# files to link into kernel
14*5c48b108SAl Viroobj-$(VDSO64-y)			+= vdso.o vma.o
15*5c48b108SAl Viro
16*5c48b108SAl Virovobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
17*5c48b108SAl Viro
18*5c48b108SAl Viro$(obj)/vdso.o: $(obj)/vdso.so
19*5c48b108SAl Viro
20*5c48b108SAl Virotargets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y)
21*5c48b108SAl Viro
22*5c48b108SAl Viroexport CPPFLAGS_vdso.lds += -P -C
23*5c48b108SAl Viro
24*5c48b108SAl ViroVDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
25*5c48b108SAl Viro       -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
26*5c48b108SAl Viro
27*5c48b108SAl Viro$(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
28*5c48b108SAl Viro
29*5c48b108SAl Viro$(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE
30*5c48b108SAl Viro	$(call if_changed,vdso)
31*5c48b108SAl Viro
32*5c48b108SAl Viro$(obj)/%.so: OBJCOPYFLAGS := -S
33*5c48b108SAl Viro$(obj)/%.so: $(obj)/%.so.dbg FORCE
34*5c48b108SAl Viro	$(call if_changed,objcopy)
35*5c48b108SAl Viro
36*5c48b108SAl Viro#
37*5c48b108SAl Viro# Don't omit frame pointers for ease of userspace debugging, but do
38*5c48b108SAl Viro# optimize sibling calls.
39*5c48b108SAl Viro#
40*5c48b108SAl ViroCFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
41*5c48b108SAl Viro       $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \
42*5c48b108SAl Viro       -fno-omit-frame-pointer -foptimize-sibling-calls
43*5c48b108SAl Viro
44*5c48b108SAl Viro$(vobjs): KBUILD_CFLAGS += $(CFL)
45*5c48b108SAl Viro
46*5c48b108SAl Viro#
47*5c48b108SAl Viro# vDSO code runs in userspace and -pg doesn't help with profiling anyway.
48*5c48b108SAl Viro#
49*5c48b108SAl ViroCFLAGS_REMOVE_vdso-note.o = -pg
50*5c48b108SAl ViroCFLAGS_REMOVE_um_vdso.o = -pg
51*5c48b108SAl Viro
52*5c48b108SAl Virotargets += vdso-syms.lds
53*5c48b108SAl Viroobj-$(VDSO64-y)			+= vdso-syms.lds
54*5c48b108SAl Viro
55*5c48b108SAl Viro#
56*5c48b108SAl Viro# Match symbols in the DSO that look like VDSO*; produce a file of constants.
57*5c48b108SAl Viro#
58*5c48b108SAl Virosed-vdsosym := -e 's/^00*/0/' \
59*5c48b108SAl Viro	-e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p'
60*5c48b108SAl Viroquiet_cmd_vdsosym = VDSOSYM $@
61*5c48b108SAl Virodefine cmd_vdsosym
62*5c48b108SAl Viro	$(NM) $< | LC_ALL=C sed -n $(sed-vdsosym) | LC_ALL=C sort > $@
63*5c48b108SAl Viroendef
64*5c48b108SAl Viro
65*5c48b108SAl Viro$(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE
66*5c48b108SAl Viro	$(call if_changed,vdsosym)
67*5c48b108SAl Viro
68*5c48b108SAl Viro#
69*5c48b108SAl Viro# The DSO images are built using a special linker script.
70*5c48b108SAl Viro#
71*5c48b108SAl Viroquiet_cmd_vdso = VDSO    $@
72*5c48b108SAl Viro      cmd_vdso = $(CC) -nostdlib -o $@ \
73*5c48b108SAl Viro		       $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
74*5c48b108SAl Viro		       -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
75*5c48b108SAl Viro		 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
76*5c48b108SAl Viro
77*5c48b108SAl ViroVDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
78*5c48b108SAl ViroGCOV_PROFILE := n
79*5c48b108SAl Viro
80*5c48b108SAl Viro#
81*5c48b108SAl Viro# Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
82*5c48b108SAl Viro#
83*5c48b108SAl Viroquiet_cmd_vdso_install = INSTALL $@
84*5c48b108SAl Viro      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
85*5c48b108SAl Viro$(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
86*5c48b108SAl Viro	@mkdir -p $(MODLIB)/vdso
87*5c48b108SAl Viro	$(call cmd,vdso_install)
88*5c48b108SAl Viro
89*5c48b108SAl ViroPHONY += vdso_install $(vdso-install-y)
90*5c48b108SAl Virovdso_install: $(vdso-install-y)
91