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