1 # SPDX-License-Identifier: GPL-2.0-only
3 # Building a vDSO image for AArch64.
5 # Author: Will Deacon <will.deacon@arm.com>
6 # Heavily based on the vDSO Makefiles for other archs.
9 obj-vdso
:= note.o datapage.o sigreturn.o gettimeofday.o
12 targets
:= $(obj-vdso
) vdso.so vdso.so.dbg
13 obj-vdso
:= $(addprefix $(obj
)/, $(obj-vdso
))
15 ccflags-y
:= -shared
-fno-common
-fno-builtin
-nostdlib
-fPIC
-Wl
,-shared
-g \
16 -Wl
,-soname
=linux-vdso.so
.1 -Wl
,--hash-style
=sysv
18 # Disable gcov profiling for VDSO code
24 CPPFLAGS_vdso.lds
+= -P
-C
-U
$(ARCH
)
27 $(obj
)/vdso.o
: $(obj
)/vdso.so
29 # Link rule for the .so file, .lds has to be first
30 $(obj
)/vdso.so.dbg
: $(obj
)/vdso.lds
$(obj-vdso
) FORCE
31 $(call if_changed
,vdsold
)
34 # Strip rule for the .so file
35 $(obj
)/%.so
: OBJCOPYFLAGS
:= -S
36 $(obj
)/%.so
: $(obj
)/%.so.dbg FORCE
37 $(call if_changed
,objcopy
)
39 # Generate VDSO offsets using helper script
40 gen-vdsosym
:= $(srctree
)/$(src
)/gen_vdso_offsets.sh
41 quiet_cmd_vdsosym
= VDSOSYM
$@
42 cmd_vdsosym
= $(NM
) $< |
$(gen-vdsosym
) | LC_ALL
=C
sort > $@
44 include/generated
/vdso-offsets.h
: $(obj
)/vdso.so.dbg FORCE
45 $(call if_changed
,vdsosym
)
49 # Assembly rules for the .S files
51 sigreturn.o
: sigreturn.S
52 $(call if_changed_dep
,vdsoas
)
55 $(call if_changed_dep
,vdsoas
)
57 datapage.o
: datapage.S
58 $(call if_changed_dep
,vdsoas
)
60 gettimeofday.o
: gettimeofday.c FORCE
61 $(call if_changed_dep
,vdsocc
)
63 # Actual build commands
64 quiet_cmd_vdsold
= VDSOL
$@
65 cmd_vdsold
= $(CC
) $(c_flags
) -Wl
,-n
-Wl
,-T
$(real-prereqs
) -o
$@
66 quiet_cmd_vdsoas
= VDSOA
$@
67 cmd_vdsoas
= $(CC
) $(a_flags
) -c
-o
$@
$<
68 quiet_cmd_vdsocc
= VDSOA
$@
69 cmd_vdsocc
= $(CC
) $(c_flags
) -c
-o
$@
$<
71 # Install commands for the unstripped file
72 quiet_cmd_vdso_install
= INSTALL
$@
73 cmd_vdso_install
= cp
$(obj
)/$@.dbg
$(MODLIB
)/vdso
/$@
75 vdso.so
: $(obj
)/vdso.so.dbg
76 @mkdir
-p
$(MODLIB
)/vdso
77 $(call cmd
,vdso_install
)