83deb2a47de5026029cd99fd875e00c7e215828e
[GitHub/exynos8895/android_kernel_samsung_universal8895.git] / arch / arm64 / kernel / vdso / Makefile
1 #
2 # Building a vDSO image for AArch64.
3 #
4 # Author: Will Deacon <will.deacon@arm.com>
5 # Heavily based on the vDSO Makefiles for other archs.
6 #
7
8 obj-vdso-s := note.o sigreturn.o
9 obj-vdso-c := vgettimeofday.o
10
11 # Build rules
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)
16
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)
21
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
27 endif
28
29 # Disable gcov profiling for VDSO code
30 GCOV_PROFILE := n
31 KASAN_SANITIZE := n
32 UBSAN_SANITIZE := n
33 KCOV_INSTRUMENT := n
34
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
38
39 obj-y += vdso.o
40 extra-y += vdso.lds
41 CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
42
43 # Force dependency (incbin is bad)
44 $(obj)/vdso.o : $(obj)/vdso.so
45
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)
49
50 # Strip rule for the .so file
51 $(obj)/%.so: OBJCOPYFLAGS := -S
52 $(obj)/%.so: $(obj)/%.so.dbg FORCE
53 $(call if_changed,objcopy)
54
55 # Generate VDSO offsets using helper script
56 gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
57 quiet_cmd_vdsosym = VDSOSYM $@
58 define cmd_vdsosym
59 $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
60 endef
61
62 include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
63 $(call if_changed,vdsosym)
64
65 # Assembly rules for the .S files
66 $(obj-vdso-s): %.o: %.S FORCE
67 $(call if_changed_dep,vdsoas)
68
69 $(obj-vdso-c): %.o: %.c FORCE
70 $(call if_changed_dep,vdsocc)
71
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 $@ $<
79
80 # Install commands for the unstripped file
81 quiet_cmd_vdso_install = INSTALL $@
82 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
83
84 vdso.so: $(obj)/vdso.so.dbg
85 @mkdir -p $(MODLIB)/vdso
86 $(call cmd,vdso_install)
87
88 vdso_install: vdso.so