1 # SPDX-License-Identifier: GPL-2.0
2 hostprogs-y
:= vdsomunge
4 obj-vdso
:= vgettimeofday.o datapage.o
7 targets
:= $(obj-vdso
) vdso.so vdso.so.dbg vdso.so.raw vdso.lds
8 obj-vdso
:= $(addprefix $(obj
)/, $(obj-vdso
))
10 ccflags-y
:= -fPIC
-fno-common
-fno-builtin
-fno-stack-protector
11 ccflags-y
+= -DDISABLE_BRANCH_PROFILING
13 VDSO_LDFLAGS
:= -Wl
,-Bsymbolic
-Wl
,--no-undefined
-Wl
,-soname
=linux-vdso.so
.1
14 VDSO_LDFLAGS
+= -Wl
,-z
,max-page-size
=4096 -Wl
,-z
,common-page-size
=4096
15 VDSO_LDFLAGS
+= -nostdlib
-shared
16 VDSO_LDFLAGS
+= $(call cc-ldoption
, -Wl
$(comma
)--hash-style
=sysv
)
17 VDSO_LDFLAGS
+= $(call cc-ldoption
, -Wl
$(comma
)--build-id
)
18 VDSO_LDFLAGS
+= $(call cc-ldoption
, -fuse-ld
=bfd
)
20 obj-
$(CONFIG_VDSO
) += vdso.o
21 extra-
$(CONFIG_VDSO
) += vdso.lds
22 CPPFLAGS_vdso.lds
+= -P
-C
-U
$(ARCH
)
24 CFLAGS_REMOVE_vdso.o
= -pg
26 # Force -O2 to avoid libgcc dependencies
27 CFLAGS_REMOVE_vgettimeofday.o
= -pg
-Os
28 CFLAGS_vgettimeofday.o
= -O2
30 # Disable gcov profiling for VDSO code
34 $(obj
)/vdso.o
: $(obj
)/vdso.so
36 # Link rule for the .so file
37 $(obj
)/vdso.so.raw
: $(src
)/vdso.lds
$(obj-vdso
) FORCE
38 $(call if_changed
,vdsold
)
40 $(obj
)/vdso.so.dbg
: $(obj
)/vdso.so.raw
$(obj
)/vdsomunge FORCE
41 $(call if_changed
,vdsomunge
)
43 # Strip rule for the .so file
44 $(obj
)/%.so
: OBJCOPYFLAGS
:= -S
45 $(obj
)/%.so
: $(obj
)/%.so.dbg FORCE
46 $(call if_changed
,objcopy
)
48 # Actual build commands
49 quiet_cmd_vdsold
= VDSO
$@
50 cmd_vdsold
= $(CC
) $(c_flags
) $(VDSO_LDFLAGS
) \
51 -Wl
,-T
$(filter %.lds
,$^
) $(filter %.o
,$^
) -o
$@
53 quiet_cmd_vdsomunge
= MUNGE
$@
54 cmd_vdsomunge
= $(objtree
)/$(obj
)/vdsomunge
$< $@
57 # Install the unstripped copy of vdso.so.dbg. If our toolchain
58 # supports build-id, install .build-id links as well.
60 # Cribbed from arch/x86/vdso/Makefile.
62 quiet_cmd_vdso_install
= INSTALL
$<
63 define cmd_vdso_install
64 cp
$< "$(MODLIB)/vdso/vdso.so"; \
65 if readelf
-n
$< | grep
-q
'Build ID'; then \
66 buildid
=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \
67 first
=`echo $$buildid | cut -b-2`; \
68 last
=`echo $$buildid | cut -b3-`; \
69 mkdir
-p
"$(MODLIB)/vdso/.build-id/$$first"; \
70 ln
-sf
"../../vdso.so" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \
75 @mkdir
-p
$(MODLIB
)/vdso
78 vdso_install
: $(obj
)/vdso.so.dbg
$(MODLIB
)/vdso
79 $(call cmd
,vdso_install
)