blob: d8200adae9fa51f37918df90c83a5e936c8462c2 [file] [log] [blame]
Andi Kleen2aae9502007-07-21 17:10:01 +02001#
2# x86-64 vDSO.
3#
4
5# files to link into the vdso
6# vdso-start.o has to be first
7vobjs-y := vdso-start.o vdso-note.o vclock_gettime.o vgetcpu.o vvar.o
8
9# files to link into kernel
10obj-y := vma.o vdso.o vdso-syms.o
11
12vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
13
14$(obj)/vdso.o: $(obj)/vdso.so
15
Roland McGrathf79eb832007-10-17 18:04:32 +020016targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y) vdso-syms.o
Andi Kleen2aae9502007-07-21 17:10:01 +020017
18# The DSO images are built using a special linker script.
19quiet_cmd_syscall = SYSCALL $@
20 cmd_syscall = $(CC) -m elf_x86_64 -nostdlib $(SYSCFLAGS_$(@F)) \
21 -Wl,-T,$(filter-out FORCE,$^) -o $@
22
Sam Ravnborgd746d642007-11-12 20:14:19 +010023export CPPFLAGS_vdso.lds += -P -C
Andi Kleen2aae9502007-07-21 17:10:01 +020024
25vdso-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
28SYSCFLAGS_vdso.so = $(vdso-flags)
Roland McGrathf79eb832007-10-17 18:04:32 +020029SYSCFLAGS_vdso.so.dbg = $(vdso-flags)
Andi Kleen2aae9502007-07-21 17:10:01 +020030
31$(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
32
33$(obj)/vdso.so: $(src)/vdso.lds $(vobjs) FORCE
Roland McGrathf79eb832007-10-17 18:04:32 +020034
35$(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE
Andi Kleen2aae9502007-07-21 17:10:01 +020036 $(call if_changed,syscall)
37
Roland McGrathf79eb832007-10-17 18:04:32 +020038$(obj)/%.so: OBJCOPYFLAGS := -S
39$(obj)/%.so: $(obj)/%.so.dbg FORCE
40 $(call if_changed,objcopy)
41
Andi Kleen037e20a2007-07-22 21:13:11 +020042CFL := $(PROFILING) -mcmodel=small -fPIC -g0 -O2 -fasynchronous-unwind-tables -m64
Andi Kleen2aae9502007-07-21 17:10:01 +020043
Sam Ravnborga0f97e02007-10-14 22:21:35 +020044$(obj)/vclock_gettime.o: KBUILD_CFLAGS = $(CFL)
45$(obj)/vgetcpu.o: KBUILD_CFLAGS = $(CFL)
Andi Kleen2aae9502007-07-21 17:10:01 +020046
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.
50extra-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
54SYSCFLAGS_vdso-syms.o = -r -d
55$(obj)/vdso-syms.o: $(src)/vdso.lds $(vobjs) FORCE
56 $(call if_changed,syscall)
Roland McGrathf79eb832007-10-17 18:04:32 +020057
Roland McGrath5b930492008-01-30 13:30:40 +010058targets += vdso-syms.lds
59obj-y += vdso-syms.lds
60
61#
62# Match symbols in the DSO that look like VDSO*; produce a file of constants.
63#
64sed-vdsosym := -e 's/^00*/0/' \
65 -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p'
66quiet_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 McGrathf79eb832007-10-17 18:04:32 +020072quiet_cmd_vdso_install = INSTALL $@
73 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
74vdso.so:
75 @mkdir -p $(MODLIB)/vdso
76 $(call cmd,vdso_install)
77
78vdso_install: vdso.so