blob: a0af6bf6c11bf93376e9937ebc57b1724b85afe8 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Will Deacon9031fef2012-03-05 11:49:31 +00002#
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
Arnd Bergmann54309782015-11-12 15:37:12 +010019# Disable gcov profiling for VDSO code
20GCOV_PROFILE := n
21
Will Deacon6f1a6ae2015-06-19 13:56:33 +010022# 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
Will Deacon9031fef2012-03-05 11:49:31 +000026obj-y += vdso.o
Kevin Brodskya66649d2016-05-12 17:39:15 +010027extra-y += vdso.lds
Will Deacon9031fef2012-03-05 11:49:31 +000028CPPFLAGS_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
Masahiro Yamada697e96e2019-04-03 17:48:22 +090034$(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
Will Deacon9031fef2012-03-05 11:49:31 +000035 $(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 $@
Masahiro Yamada697e96e2019-04-03 17:48:22 +090045 cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
Will Deacon9031fef2012-03-05 11:49:31 +000046
Kevin Brodskya66649d2016-05-12 17:39:15 +010047include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
Will Deacon9031fef2012-03-05 11:49:31 +000048 $(call if_changed,vdsosym)
49
50# Assembly rules for the .S files
Arun Chandran1915e2a2014-06-26 15:16:03 +053051$(obj-vdso): %.o: %.S FORCE
Will Deacon9031fef2012-03-05 11:49:31 +000052 $(call if_changed_dep,vdsoas)
53
54# Actual build commands
Ian Campbellad789ba2014-07-15 08:38:08 +010055quiet_cmd_vdsold = VDSOL $@
Masahiro Yamada697e96e2019-04-03 17:48:22 +090056 cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $(real-prereqs) -o $@
Ian Campbellad789ba2014-07-15 08:38:08 +010057quiet_cmd_vdsoas = VDSOA $@
Will Deacon9031fef2012-03-05 11:49:31 +000058 cmd_vdsoas = $(CC) $(a_flags) -c -o $@ $<
59
60# Install commands for the unstripped file
61quiet_cmd_vdso_install = INSTALL $@
62 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
63
64vdso.so: $(obj)/vdso.so.dbg
65 @mkdir -p $(MODLIB)/vdso
66 $(call cmd,vdso_install)
67
68vdso_install: vdso.so