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