Commit | Line | Data |
---|---|---|
9031fefd WD |
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 | ||
053814a3 MS |
8 | obj-vdso-s := note.o sigreturn.o |
9 | obj-vdso-c := vgettimeofday.o | |
9031fefd WD |
10 | |
11 | # Build rules | |
053814a3 MS |
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) | |
9031fefd | 16 | |
053814a3 MS |
17 | ccflags-y := -shared -fno-common -fno-builtin -fno-stack-protector |
18 | ccflags-y += -DDISABLE_BRANCH_PROFILING | |
9031fefd WD |
19 | ccflags-y += -nostdlib -Wl,-soname=linux-vdso.so.1 \ |
20 | $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) | |
21 | ||
053814a3 MS |
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 | ||
54309784 AB |
29 | # Disable gcov profiling for VDSO code |
30 | GCOV_PROFILE := n | |
053814a3 MS |
31 | KASAN_SANITIZE := n |
32 | UBSAN_SANITIZE := n | |
33 | KCOV_INSTRUMENT := n | |
54309784 | 34 | |
6f1a6ae8 WD |
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 | ||
9031fefd | 39 | obj-y += vdso.o |
fb47dee8 | 40 | extra-y += vdso.lds |
9031fefd WD |
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 | |
fb47dee8 | 59 | $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ |
9031fefd WD |
60 | endef |
61 | ||
fb47dee8 | 62 | include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE |
9031fefd WD |
63 | $(call if_changed,vdsosym) |
64 | ||
65 | # Assembly rules for the .S files | |
053814a3 | 66 | $(obj-vdso-s): %.o: %.S FORCE |
9031fefd WD |
67 | $(call if_changed_dep,vdsoas) |
68 | ||
053814a3 MS |
69 | $(obj-vdso-c): %.o: %.c FORCE |
70 | $(call if_changed_dep,vdsocc) | |
71 | ||
9031fefd | 72 | # Actual build commands |
ad789ba5 | 73 | quiet_cmd_vdsold = VDSOL $@ |
40507403 | 74 | cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $^ -o $@ |
053814a3 MS |
75 | quiet_cmd_vdsocc = VDSOC $@ |
76 | cmd_vdsocc = ${CC} $(c_flags) -c -o $@ $< | |
ad789ba5 | 77 | quiet_cmd_vdsoas = VDSOA $@ |
9031fefd WD |
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 |