Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Will Deacon | 9031fef | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 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 | |
Arnd Bergmann | 5430978 | 2015-11-12 15:37:12 +0100 | [diff] [blame] | 19 | # Disable gcov profiling for VDSO code |
| 20 | GCOV_PROFILE := n |
| 21 | |
Will Deacon | 6f1a6ae | 2015-06-19 13:56:33 +0100 | [diff] [blame] | 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 | |
Will Deacon | 9031fef | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 26 | obj-y += vdso.o |
Kevin Brodsky | a66649d | 2016-05-12 17:39:15 +0100 | [diff] [blame] | 27 | extra-y += vdso.lds |
Will Deacon | 9031fef | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 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 |
Masahiro Yamada | 697e96e | 2019-04-03 17:48:22 +0900 | [diff] [blame^] | 34 | $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE |
Will Deacon | 9031fef | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 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 $@ |
Masahiro Yamada | 697e96e | 2019-04-03 17:48:22 +0900 | [diff] [blame^] | 45 | cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ |
Will Deacon | 9031fef | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 46 | |
Kevin Brodsky | a66649d | 2016-05-12 17:39:15 +0100 | [diff] [blame] | 47 | include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE |
Will Deacon | 9031fef | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 48 | $(call if_changed,vdsosym) |
| 49 | |
| 50 | # Assembly rules for the .S files |
Arun Chandran | 1915e2a | 2014-06-26 15:16:03 +0530 | [diff] [blame] | 51 | $(obj-vdso): %.o: %.S FORCE |
Will Deacon | 9031fef | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 52 | $(call if_changed_dep,vdsoas) |
| 53 | |
| 54 | # Actual build commands |
Ian Campbell | ad789ba | 2014-07-15 08:38:08 +0100 | [diff] [blame] | 55 | quiet_cmd_vdsold = VDSOL $@ |
Masahiro Yamada | 697e96e | 2019-04-03 17:48:22 +0900 | [diff] [blame^] | 56 | cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $(real-prereqs) -o $@ |
Ian Campbell | ad789ba | 2014-07-15 08:38:08 +0100 | [diff] [blame] | 57 | quiet_cmd_vdsoas = VDSOA $@ |
Will Deacon | 9031fef | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 58 | cmd_vdsoas = $(CC) $(a_flags) -c -o $@ $< |
| 59 | |
| 60 | # Install commands for the unstripped file |
| 61 | quiet_cmd_vdso_install = INSTALL $@ |
| 62 | cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ |
| 63 | |
| 64 | vdso.so: $(obj)/vdso.so.dbg |
| 65 | @mkdir -p $(MODLIB)/vdso |
| 66 | $(call cmd,vdso_install) |
| 67 | |
| 68 | vdso_install: vdso.so |