1# SPDX-License-Identifier: GPL-2.0
2
3# List of files in the vdso, has to be asm only for now
4
5obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o getcpu.o
6
7# Build rules
8
9ifdef CROSS32_COMPILE
10    VDSOCC := $(CROSS32_COMPILE)gcc
11else
12    VDSOCC := $(CC)
13endif
14
15CC32FLAGS :=
16ifdef CONFIG_PPC64
17CC32FLAGS += -m32
18endif
19
20targets := $(obj-vdso32) vdso32.so vdso32.so.dbg
21obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
22
23GCOV_PROFILE := n
24KCOV_INSTRUMENT := n
25UBSAN_SANITIZE := n
26
27ccflags-y := -shared -fno-common -fno-builtin -nostdlib \
28	-Wl,-soname=linux-vdso32.so.1 -Wl,--hash-style=both
29asflags-y := -D__VDSO32__ -s
30
31obj-y += vdso32_wrapper.o
32targets += vdso32.lds
33CPPFLAGS_vdso32.lds += -P -C -Upowerpc
34
35# Force dependency (incbin is bad)
36$(obj)/vdso32_wrapper.o : $(obj)/vdso32.so
37
38# link rule for the .so file, .lds has to be first
39$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) FORCE
40	$(call if_changed,vdso32ld)
41
42# strip rule for the .so file
43$(obj)/%.so: OBJCOPYFLAGS := -S
44$(obj)/%.so: $(obj)/%.so.dbg FORCE
45	$(call if_changed,objcopy)
46
47# assembly rules for the .S files
48$(obj-vdso32): %.o: %.S FORCE
49	$(call if_changed_dep,vdso32as)
50
51# actual build commands
52quiet_cmd_vdso32ld = VDSO32L $@
53      cmd_vdso32ld = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^)
54quiet_cmd_vdso32as = VDSO32A $@
55      cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $<
56
57# install commands for the unstripped file
58quiet_cmd_vdso_install = INSTALL $@
59      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
60
61vdso32.so: $(obj)/vdso32.so.dbg
62	@mkdir -p $(MODLIB)/vdso
63	$(call cmd,vdso_install)
64
65vdso_install: vdso32.so
66