Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 1 | # |
| 2 | # x86-64 vDSO. |
| 3 | # |
| 4 | |
| 5 | # files to link into the vdso |
| 6 | # vdso-start.o has to be first |
| 7 | vobjs-y := vdso-start.o vdso-note.o vclock_gettime.o vgetcpu.o vvar.o |
| 8 | |
| 9 | # files to link into kernel |
| 10 | obj-y := vma.o vdso.o vdso-syms.o |
| 11 | |
| 12 | vobjs := $(foreach F,$(vobjs-y),$(obj)/$F) |
| 13 | |
| 14 | $(obj)/vdso.o: $(obj)/vdso.so |
| 15 | |
Roland McGrath | f79eb83 | 2007-10-17 18:04:32 +0200 | [diff] [blame] | 16 | targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y) vdso-syms.o |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 17 | |
| 18 | # The DSO images are built using a special linker script. |
| 19 | quiet_cmd_syscall = SYSCALL $@ |
| 20 | cmd_syscall = $(CC) -m elf_x86_64 -nostdlib $(SYSCFLAGS_$(@F)) \ |
| 21 | -Wl,-T,$(filter-out FORCE,$^) -o $@ |
| 22 | |
| 23 | export CPPFLAGS_vdso.lds += -P -C -U$(ARCH) |
| 24 | |
| 25 | vdso-flags = -fPIC -shared -Wl,-soname=linux-vdso.so.1 \ |
| 26 | $(call ld-option, -Wl$(comma)--hash-style=sysv) \ |
| 27 | -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096 |
| 28 | SYSCFLAGS_vdso.so = $(vdso-flags) |
Roland McGrath | f79eb83 | 2007-10-17 18:04:32 +0200 | [diff] [blame] | 29 | SYSCFLAGS_vdso.so.dbg = $(vdso-flags) |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 30 | |
| 31 | $(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so |
| 32 | |
| 33 | $(obj)/vdso.so: $(src)/vdso.lds $(vobjs) FORCE |
Roland McGrath | f79eb83 | 2007-10-17 18:04:32 +0200 | [diff] [blame] | 34 | |
| 35 | $(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 36 | $(call if_changed,syscall) |
| 37 | |
Roland McGrath | f79eb83 | 2007-10-17 18:04:32 +0200 | [diff] [blame] | 38 | $(obj)/%.so: OBJCOPYFLAGS := -S |
| 39 | $(obj)/%.so: $(obj)/%.so.dbg FORCE |
| 40 | $(call if_changed,objcopy) |
| 41 | |
Andi Kleen | 037e20a | 2007-07-22 21:13:11 +0200 | [diff] [blame] | 42 | CFL := $(PROFILING) -mcmodel=small -fPIC -g0 -O2 -fasynchronous-unwind-tables -m64 |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 43 | |
Sam Ravnborg | a0f97e0 | 2007-10-14 22:21:35 +0200 | [diff] [blame] | 44 | $(obj)/vclock_gettime.o: KBUILD_CFLAGS = $(CFL) |
| 45 | $(obj)/vgetcpu.o: KBUILD_CFLAGS = $(CFL) |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 46 | |
| 47 | # We also create a special relocatable object that should mirror the symbol |
| 48 | # table and layout of the linked DSO. With ld -R we can then refer to |
| 49 | # these symbols in the kernel code rather than hand-coded addresses. |
| 50 | extra-y += vdso-syms.o |
| 51 | $(obj)/built-in.o: $(obj)/vdso-syms.o |
| 52 | $(obj)/built-in.o: ld_flags += -R $(obj)/vdso-syms.o |
| 53 | |
| 54 | SYSCFLAGS_vdso-syms.o = -r -d |
| 55 | $(obj)/vdso-syms.o: $(src)/vdso.lds $(vobjs) FORCE |
| 56 | $(call if_changed,syscall) |
Roland McGrath | f79eb83 | 2007-10-17 18:04:32 +0200 | [diff] [blame] | 57 | |
| 58 | quiet_cmd_vdso_install = INSTALL $@ |
| 59 | cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ |
| 60 | vdso.so: |
| 61 | @mkdir -p $(MODLIB)/vdso |
| 62 | $(call cmd,vdso_install) |
| 63 | |
| 64 | vdso_install: vdso.so |