1 # SPDX-License-Identifier: GPL-2.0
2 # Objects to go into the VDSO.
4 # Include the generic Makefile to check the built vdso.
5 include $(srctree
)/lib
/vdso
/Makefile
7 obj-vdso-y
:= elf.o vgetcpu.o vgettimeofday.o vgetrandom.o \
8 vgetrandom-chacha.o sigreturn.o
10 # Common compiler flags between ABIs.
12 $(filter -I
%,$(KBUILD_CFLAGS
)) \
13 $(filter -E
%,$(KBUILD_CFLAGS
)) \
14 $(filter -march
=%,$(KBUILD_CFLAGS
)) \
15 $(filter -m
%-float
,$(KBUILD_CFLAGS
)) \
19 cflags-vdso
:= $(ccflags-vdso
) \
20 -isystem
$(shell $(CC
) -print-file-name
=include) \
21 $(filter -W
%,$(filter-out -Wa
$(comma
)%,$(KBUILD_CFLAGS
))) \
22 -std
=gnu11
-O2
-g
-fno-strict-aliasing
-fno-common
-fno-builtin \
23 -fno-stack-protector
-fno-jump-tables
-DDISABLE_BRANCH_PROFILING \
24 $(call cc-option
, -fno-asynchronous-unwind-tables
) \
25 $(call cc-option
, -fno-stack-protector
)
26 aflags-vdso
:= $(ccflags-vdso
) \
27 -D__ASSEMBLY__
-Wa
,-gdwarf-2
29 ifneq ($(c-gettimeofday-y
),)
30 CFLAGS_vgettimeofday.o
+= -include $(c-gettimeofday-y
)
33 ifneq ($(c-getrandom-y
),)
34 CFLAGS_vgetrandom.o
+= -include $(c-getrandom-y
)
38 ldflags-y
:= -Bsymbolic
--no-undefined
-soname
=linux-vdso.so
.1 \
39 $(filter -E
%,$(KBUILD_CFLAGS
)) -nostdlib
-shared \
40 --hash-style
=sysv
--build-id
-T
43 # Shared build commands.
46 quiet_cmd_vdsold_and_vdso_check
= LD
$@
47 cmd_vdsold_and_vdso_check
= $(cmd_ld
); $(cmd_vdso_check
)
49 quiet_cmd_vdsoas_o_S
= AS
$@
50 cmd_vdsoas_o_S
= $(CC
) $(a_flags
) -c
-o
$@
$<
52 # Generate VDSO offsets using helper script
53 gen-vdsosym
:= $(src
)/gen_vdso_offsets.sh
54 quiet_cmd_vdsosym
= VDSOSYM
$@
55 cmd_vdsosym
= $(NM
) $< |
$(gen-vdsosym
) | LC_ALL
=C
sort > $@
57 include/generated
/vdso-offsets.h
: $(obj
)/vdso.so.dbg FORCE
58 $(call if_changed
,vdsosym
)
64 native-abi
:= $(filter -mabi
=%,$(KBUILD_CFLAGS
))
66 targets
+= $(obj-vdso-y
)
67 targets
+= vdso.lds vdso.so.dbg vdso.so
69 obj-vdso
:= $(obj-vdso-y
:%.o
=$(obj
)/%.o
)
71 $(obj-vdso
): KBUILD_CFLAGS
:= $(cflags-vdso
) $(native-abi
)
72 $(obj-vdso
): KBUILD_AFLAGS
:= $(aflags-vdso
) $(native-abi
)
74 $(obj
)/vdso.lds
: KBUILD_CPPFLAGS
:= $(ccflags-vdso
) $(native-abi
)
76 $(obj
)/vdso.so.dbg
: $(obj
)/vdso.lds
$(obj-vdso
) FORCE
77 $(call if_changed
,vdsold_and_vdso_check
)
79 $(obj
)/vdso.so
: OBJCOPYFLAGS
:= -S
80 $(obj
)/vdso.so
: $(obj
)/vdso.so.dbg FORCE
81 $(call if_changed
,objcopy
)
85 $(obj
)/vdso.o
: $(obj
)/vdso.so