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-s
:= note.o sigreturn.o
9 obj-vdso-c
:= vgettimeofday.o
12 targets
:= $(obj-vdso-s
) $(obj-vdso-c
) vdso.so vdso.so.dbg
13 obj-vdso-s
:= $(addprefix $(obj
)/, $(obj-vdso-s
))
14 obj-vdso-c
:= $(addprefix $(obj
)/, $(obj-vdso-c
))
15 obj-vdso
:= $(obj-vdso-c
) $(obj-vdso-s
)
17 ccflags-y
:= -shared
-fno-common
-fno-builtin
-fno-stack-protector
18 ccflags-y
+= -DDISABLE_BRANCH_PROFILING
19 ccflags-y
+= -nostdlib
-Wl
,-soname
=linux-vdso.so
.1 \
20 $(call cc-ldoption
, -Wl
$(comma
)--hash-style
=sysv
)
22 # Force -O2 to avoid libgcc dependencies
23 CFLAGS_REMOVE_vgettimeofday.o
= -pg
-Os
24 CFLAGS_vgettimeofday.o
= -O2
-fPIC
25 ifneq ($(cc-name
),clang
)
26 CFLAGS_vgettimeofday.o
+= -mcmodel
=tiny
29 # Disable gcov profiling for VDSO code
35 # Workaround for bare-metal (ELF) toolchains that neglect to pass -shared
36 # down to collect2, resulting in silent corruption of the vDSO image.
37 ccflags-y
+= -Wl
,-shared
41 CPPFLAGS_vdso.lds
+= -P
-C
-U
$(ARCH
)
43 # Force dependency (incbin is bad)
44 $(obj
)/vdso.o
: $(obj
)/vdso.so
46 # Link rule for the .so file, .lds has to be first
47 $(obj
)/vdso.so.dbg
: $(src
)/vdso.lds
$(obj-vdso
)
48 $(call if_changed
,vdsold
)
50 # Strip rule for the .so file
51 $(obj
)/%.so
: OBJCOPYFLAGS
:= -S
52 $(obj
)/%.so
: $(obj
)/%.so.dbg FORCE
53 $(call if_changed
,objcopy
)
55 # Generate VDSO offsets using helper script
56 gen-vdsosym
:= $(srctree
)/$(src
)/gen_vdso_offsets.sh
57 quiet_cmd_vdsosym
= VDSOSYM
$@
59 $(NM
) $< |
$(gen-vdsosym
) | LC_ALL
=C
sort > $@
62 include/generated
/vdso-offsets.h
: $(obj
)/vdso.so.dbg FORCE
63 $(call if_changed
,vdsosym
)
65 # Assembly rules for the .S files
66 $(obj-vdso-s
): %.o
: %.S FORCE
67 $(call if_changed_dep
,vdsoas
)
69 $(obj-vdso-c
): %.o
: %.c FORCE
70 $(call if_changed_dep
,vdsocc
)
72 # Actual build commands
73 quiet_cmd_vdsold
= VDSOL
$@
74 cmd_vdsold
= $(CC
) $(c_flags
) -Wl
,-n
-Wl
,-T
$^
-o
$@
75 quiet_cmd_vdsocc
= VDSOC
$@
76 cmd_vdsocc
= ${CC} $(c_flags
) -c
-o
$@
$<
77 quiet_cmd_vdsoas
= VDSOA
$@
78 cmd_vdsoas
= $(CC
) $(a_flags
) -c
-o
$@
$<
80 # Install commands for the unstripped file
81 quiet_cmd_vdso_install
= INSTALL
$@
82 cmd_vdso_install
= cp
$(obj
)/$@.dbg
$(MODLIB
)/vdso
/$@
84 vdso.so
: $(obj
)/vdso.so.dbg
85 @mkdir
-p
$(MODLIB
)/vdso
86 $(call cmd
,vdso_install
)