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