xref: /openbmc/linux/arch/powerpc/kernel/vdso/Makefile (revision 25c2e591)
1# SPDX-License-Identifier: GPL-2.0
2
3# List of files in the vdso, has to be asm only for now
4
5ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN|R_PPC_REL24
6include $(srctree)/lib/vdso/Makefile
7
8obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o note-32.o getcpu-32.o
9obj-vdso64 = sigtramp64-64.o gettimeofday-64.o datapage-64.o cacheflush-64.o note-64.o getcpu-64.o
10
11ifneq ($(c-gettimeofday-y),)
12  CFLAGS_vgettimeofday-32.o += -include $(c-gettimeofday-y)
13  CFLAGS_vgettimeofday-32.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
14  CFLAGS_vgettimeofday-32.o += $(call cc-option, -fno-stack-protector)
15  CFLAGS_vgettimeofday-32.o += -DDISABLE_BRANCH_PROFILING
16  CFLAGS_vgettimeofday-32.o += -ffreestanding -fasynchronous-unwind-tables
17  CFLAGS_REMOVE_vgettimeofday-32.o = $(CC_FLAGS_FTRACE)
18  CFLAGS_REMOVE_vgettimeofday-32.o += -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc
19  CFLAGS_vgettimeofday-64.o += -include $(c-gettimeofday-y)
20  CFLAGS_vgettimeofday-64.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
21  CFLAGS_vgettimeofday-64.o += $(call cc-option, -fno-stack-protector)
22  CFLAGS_vgettimeofday-64.o += -DDISABLE_BRANCH_PROFILING
23  CFLAGS_vgettimeofday-64.o += -ffreestanding -fasynchronous-unwind-tables
24  CFLAGS_REMOVE_vgettimeofday-64.o = $(CC_FLAGS_FTRACE)
25# Go prior to 1.16.x assumes r30 is not clobbered by any VDSO code. That used to be true
26# by accident when the VDSO was hand-written asm code, but may not be now that the VDSO is
27# compiler generated. To avoid breaking Go tell GCC not to use r30. Impact on code
28# generation is minimal, it will just use r29 instead.
29  CFLAGS_vgettimeofday-64.o += $(call cc-option, -ffixed-r30)
30endif
31
32# Build rules
33
34ifdef CROSS32_COMPILE
35    VDSOCC := $(CROSS32_COMPILE)gcc
36else
37    VDSOCC := $(CC)
38endif
39
40targets := $(obj-vdso32) vdso32.so.dbg vgettimeofday-32.o
41obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
42targets += $(obj-vdso64) vdso64.so.dbg vgettimeofday-64.o
43obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
44
45GCOV_PROFILE := n
46KCOV_INSTRUMENT := n
47UBSAN_SANITIZE := n
48KASAN_SANITIZE := n
49
50ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both
51ccflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld)
52
53CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32
54AS32FLAGS := -D__VDSO32__ -s
55
56CC64FLAGS := -Wl,-soname=linux-vdso64.so.1
57AS64FLAGS := -D__VDSO64__ -s
58
59targets += vdso32.lds
60CPPFLAGS_vdso32.lds += -P -C -Upowerpc
61targets += vdso64.lds
62CPPFLAGS_vdso64.lds += -P -C -U$(ARCH)
63
64# link rule for the .so file, .lds has to be first
65$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday-32.o FORCE
66	$(call if_changed,vdso32ld_and_check)
67$(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) $(obj)/vgettimeofday-64.o FORCE
68	$(call if_changed,vdso64ld_and_check)
69
70# assembly rules for the .S files
71$(obj-vdso32): %-32.o: %.S FORCE
72	$(call if_changed_dep,vdso32as)
73$(obj)/vgettimeofday-32.o: %-32.o: %.c FORCE
74	$(call if_changed_dep,vdso32cc)
75$(obj-vdso64): %-64.o: %.S FORCE
76	$(call if_changed_dep,vdso64as)
77$(obj)/vgettimeofday-64.o: %-64.o: %.c FORCE
78	$(call if_changed_dep,cc_o_c)
79
80# Generate VDSO offsets using helper script
81gen-vdso32sym := $(srctree)/$(src)/gen_vdso32_offsets.sh
82quiet_cmd_vdso32sym = VDSO32SYM $@
83      cmd_vdso32sym = $(NM) $< | $(gen-vdso32sym) | LC_ALL=C sort > $@
84gen-vdso64sym := $(srctree)/$(src)/gen_vdso64_offsets.sh
85quiet_cmd_vdso64sym = VDSO64SYM $@
86      cmd_vdso64sym = $(NM) $< | $(gen-vdso64sym) | LC_ALL=C sort > $@
87
88include/generated/vdso32-offsets.h: $(obj)/vdso32.so.dbg FORCE
89	$(call if_changed,vdso32sym)
90include/generated/vdso64-offsets.h: $(obj)/vdso64.so.dbg FORCE
91	$(call if_changed,vdso64sym)
92
93# actual build commands
94quiet_cmd_vdso32ld_and_check = VDSO32L $@
95      cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
96quiet_cmd_vdso32as = VDSO32A $@
97      cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $<
98quiet_cmd_vdso32cc = VDSO32C $@
99      cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $<
100
101quiet_cmd_vdso64ld_and_check = VDSO64L $@
102      cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
103quiet_cmd_vdso64as = VDSO64A $@
104      cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $<
105