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 | |
Sam Ravnborg | d746d64 | 2007-11-12 20:14:19 +0100 | [diff] [blame] | 23 | export CPPFLAGS_vdso.lds += -P -C |
Andi Kleen | 2aae950 | 2007-07-21 17:10:01 +0200 | [diff] [blame] | 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 | |
Roland McGrath | 5b93049 | 2008-01-30 13:30:40 +0100 | [diff] [blame^] | 58 | targets += vdso-syms.lds |
| 59 | obj-y += vdso-syms.lds |
| 60 | |
| 61 | # |
| 62 | # Match symbols in the DSO that look like VDSO*; produce a file of constants. |
| 63 | # |
| 64 | sed-vdsosym := -e 's/^00*/0/' \ |
| 65 | -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p' |
| 66 | quiet_cmd_vdsosym = VDSOSYM $@ |
| 67 | cmd_vdsosym = $(NM) $< | sed -n $(sed-vdsosym) | LC_ALL=C sort > $@ |
| 68 | |
| 69 | $(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE |
| 70 | $(call if_changed,vdsosym) |
| 71 | |
Roland McGrath | f79eb83 | 2007-10-17 18:04:32 +0200 | [diff] [blame] | 72 | quiet_cmd_vdso_install = INSTALL $@ |
| 73 | cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@ |
| 74 | vdso.so: |
| 75 | @mkdir -p $(MODLIB)/vdso |
| 76 | $(call cmd,vdso_install) |
| 77 | |
| 78 | vdso_install: vdso.so |