Will Deacon | 9031fef | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 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 | |
| 8 | obj-vdso := gettimeofday.o note.o sigreturn.o |
| 9 | |
| 10 | # Build rules |
| 11 | targets := $(obj-vdso) vdso.so vdso.so.dbg |
| 12 | obj-vdso := $(addprefix $(obj)/, $(obj-vdso)) |
| 13 | |
| 14 | ccflags-y := -shared -fno-common -fno-builtin |
| 15 | ccflags-y += -nostdlib -Wl,-soname=linux-vdso.so.1 \ |
| 16 | $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) |
| 17 | |
Arnd Bergmann | 5430978 | 2015-11-12 15:37:12 +0100 | [diff] [blame^] | 18 | # Disable gcov profiling for VDSO code |
| 19 | GCOV_PROFILE := n |
| 20 | |
Will Deacon | 6f1a6ae | 2015-06-19 13:56:33 +0100 | [diff] [blame] | 21 | # Workaround for bare-metal (ELF) toolchains that neglect to pass -shared |
| 22 | # down to collect2, resulting in silent corruption of the vDSO image. |
| 23 | ccflags-y += -Wl,-shared |
| 24 | |
Will Deacon | 9031fef | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 25 | obj-y += vdso.o |
| 26 | extra-y += vdso.lds vdso-offsets.h |
| 27 | CPPFLAGS_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 |
| 42 | gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh |
| 43 | quiet_cmd_vdsosym = VDSOSYM $@ |
| 44 | define cmd_vdsosym |
| 45 | $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ && \ |
| 46 | cp $@ include/generated/ |
| 47 | endef |
| 48 | |
| 49 | $(obj)/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE |
| 50 | $(call if_changed,vdsosym) |
| 51 | |
| 52 | # Assembly rules for the .S files |
Arun Chandran | 1915e2a | 2014-06-26 15:16:03 +0530 | [diff] [blame] | 53 | $(obj-vdso): %.o: %.S FORCE |
Will Deacon | 9031fef | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 54 | $(call if_changed_dep,vdsoas) |
| 55 | |
| 56 | # Actual build commands |
Ian Campbell | ad789ba | 2014-07-15 08:38:08 +0100 | [diff] [blame] | 57 | quiet_cmd_vdsold = VDSOL $@ |
Will Deacon | 4050740 | 2014-02-04 14:41:26 +0000 | [diff] [blame] | 58 | cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $^ -o $@ |
Ian Campbell | ad789ba | 2014-07-15 08:38:08 +0100 | [diff] [blame] | 59 | quiet_cmd_vdsoas = VDSOA $@ |
Will Deacon | 9031fef | 2012-03-05 11:49:31 +0000 | [diff] [blame] | 60 | cmd_vdsoas = $(CC) $(a_flags) -c -o $@ $< |
| 61 | |
| 62 | # Install commands for the unstripped file |
| 63 | quiet_cmd_vdso_install = INSTALL $@ |
| 64 | cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ |
| 65 | |
| 66 | vdso.so: $(obj)/vdso.so.dbg |
| 67 | @mkdir -p $(MODLIB)/vdso |
| 68 | $(call cmd,vdso_install) |
| 69 | |
| 70 | vdso_install: vdso.so |