2 # Building a vDSO image for AArch64.
4 # Author: Will Deacon <will.deacon@arm.com>
5 # Heavily based on the vDSO Makefiles for other archs.
8 obj-vdso
:= gettimeofday.o note.o sigreturn.o
11 targets
:= $(obj-vdso
) vdso.so vdso.so.dbg
12 obj-vdso
:= $(addprefix $(obj
)/, $(obj-vdso
))
14 ccflags-y
:= -shared
-fno-common
-fno-builtin
15 ccflags-y
+= -nostdlib
-Wl
,-soname
=linux-vdso.so
.1 \
16 $(call cc-ldoption
, -Wl
$(comma
)--hash-style
=sysv
)
18 # Workaround for bare-metal (ELF) toolchains that neglect to pass -shared
19 # down to collect2, resulting in silent corruption of the vDSO image.
20 ccflags-y
+= -Wl
,-shared
23 extra-y
+= vdso.lds vdso-offsets.h
24 CPPFLAGS_vdso.lds
+= -P
-C
-U
$(ARCH
)
26 # Force dependency (incbin is bad)
27 $(obj
)/vdso.o
: $(obj
)/vdso.so
29 # Link rule for the .so file, .lds has to be first
30 $(obj
)/vdso.so.dbg
: $(src
)/vdso.lds
$(obj-vdso
)
31 $(call if_changed
,vdsold
)
33 # Strip rule for the .so file
34 $(obj
)/%.so
: OBJCOPYFLAGS
:= -S
35 $(obj
)/%.so
: $(obj
)/%.so.dbg FORCE
36 $(call if_changed
,objcopy
)
38 # Generate VDSO offsets using helper script
39 gen-vdsosym
:= $(srctree
)/$(src
)/gen_vdso_offsets.sh
40 quiet_cmd_vdsosym
= VDSOSYM
$@
42 $(NM
) $< |
$(gen-vdsosym
) | LC_ALL
=C
sort > $@
&& \
43 cp
$@
include/generated
/
46 $(obj
)/vdso-offsets.h
: $(obj
)/vdso.so.dbg FORCE
47 $(call if_changed
,vdsosym
)
49 # Assembly rules for the .S files
50 $(obj-vdso
): %.o
: %.S FORCE
51 $(call if_changed_dep
,vdsoas
)
53 # Actual build commands
54 quiet_cmd_vdsold
= VDSOL
$@
55 cmd_vdsold
= $(CC
) $(c_flags
) -Wl
,-n
-Wl
,-T
$^
-o
$@
56 quiet_cmd_vdsoas
= VDSOA
$@
57 cmd_vdsoas
= $(CC
) $(a_flags
) -c
-o
$@
$<
59 # Install commands for the unstripped file
60 quiet_cmd_vdso_install
= INSTALL
$@
61 cmd_vdso_install
= cp
$(obj
)/$@.dbg
$(MODLIB
)/vdso
/$@
63 vdso.so
: $(obj
)/vdso.so.dbg
64 @mkdir
-p
$(MODLIB
)/vdso
65 $(call cmd
,vdso_install
)