blob: 88fef38678862f08aa3fe11b110e9fe61edb00dd [file] [log] [blame]
Will Deacon9031fef2012-03-05 11:49:31 +00001#
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)
Sami Tolvanen2104b872017-12-19 08:55:23 -080017ccflags-y += $(DISABLE_LTO)
Will Deacon9031fef2012-03-05 11:49:31 +000018
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
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
Kevin Brodskya66649d2016-05-12 17:39:15 +010046 $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
Will Deacon9031fef2012-03-05 11:49:31 +000047endef
48
Kevin Brodskya66649d2016-05-12 17:39:15 +010049include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
Will Deacon9031fef2012-03-05 11:49:31 +000050 $(call if_changed,vdsosym)
51
52# Assembly rules for the .S files
Arun Chandran1915e2a2014-06-26 15:16:03 +053053$(obj-vdso): %.o: %.S FORCE
Will Deacon9031fef2012-03-05 11:49:31 +000054 $(call if_changed_dep,vdsoas)
55
56# Actual build commands
Ian Campbellad789ba2014-07-15 08:38:08 +010057quiet_cmd_vdsold = VDSOL $@
Will Deacon40507402014-02-04 14:41:26 +000058 cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $^ -o $@
Ian Campbellad789ba2014-07-15 08:38:08 +010059quiet_cmd_vdsoas = VDSOA $@
Will Deacon9031fef2012-03-05 11:49:31 +000060 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