xref: /openbmc/linux/arch/arm64/kernel/vdso/Makefile (revision 6a767685)
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
9obj-vdso := gettimeofday.o note.o sigreturn.o
10
11# Build rules
12targets := $(obj-vdso) vdso.so vdso.so.dbg
13obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
14
15ccflags-y := -shared -fno-common -fno-builtin
16ccflags-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
20GCOV_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.
24ccflags-y += -Wl,-shared
25
26obj-y += vdso.o
27extra-y += vdso.lds
28CPPFLAGS_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
43gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
44quiet_cmd_vdsosym = VDSOSYM $@
45define cmd_vdsosym
46	$(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
47endef
48
49include/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
57quiet_cmd_vdsold = VDSOL   $@
58      cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $^ -o $@
59quiet_cmd_vdsoas = VDSOA   $@
60      cmd_vdsoas = $(CC) $(a_flags) -c -o $@ $<
61
62# Install commands for the unstripped file
63quiet_cmd_vdso_install = INSTALL $@
64      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
65
66vdso.so: $(obj)/vdso.so.dbg
67	@mkdir -p $(MODLIB)/vdso
68	$(call cmd,vdso_install)
69
70vdso_install: vdso.so
71