blob: 7d9a6fee0e3dc1a01e066314721f09e732af8ae6 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002
3# List of files in the vdso, has to be asm only for now
4
Michael Ellerman42ed6d52020-12-18 22:16:17 +11005ARCH_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
Christophe Leroyab037dd2020-11-27 00:10:05 +11006include $(srctree)/lib/vdso/Makefile
7
Christophe Leroy902137b2019-12-02 07:57:27 +00008obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o getcpu.o
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Christophe Leroyab037dd2020-11-27 00:10:05 +110010ifneq ($(c-gettimeofday-y),)
11 CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
12 CFLAGS_vgettimeofday.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
13 CFLAGS_vgettimeofday.o += $(call cc-option, -fno-stack-protector)
14 CFLAGS_vgettimeofday.o += -DDISABLE_BRANCH_PROFILING
15 CFLAGS_vgettimeofday.o += -ffreestanding -fasynchronous-unwind-tables
16 CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE)
17endif
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019# Build rules
20
Nicholas Pigginaf3901c2018-05-30 22:19:20 +100021ifdef CROSS32_COMPILE
22 VDSOCC := $(CROSS32_COMPILE)gcc
23else
24 VDSOCC := $(CC)
25endif
26
27CC32FLAGS :=
28ifdef CONFIG_PPC64
29CC32FLAGS += -m32
Michael Ellerman107521e2020-12-18 22:16:18 +110030KBUILD_CFLAGS := $(filter-out -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc,$(KBUILD_CFLAGS))
Benjamin Herrenschmidta7f290d2005-11-11 21:15:21 +110031endif
32
Masahiro Yamadabce74492020-12-24 02:11:41 +090033targets := $(obj-vdso32) vdso32.so.dbg vgettimeofday.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070034obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
35
Michael Ellermana15098c2009-08-09 19:02:51 +000036GCOV_PROFILE := n
Andrew Donnellanfb0b0a72019-02-22 11:40:46 +110037KCOV_INSTRUMENT := n
Daniel Axtensbf76f732016-01-20 15:00:58 -080038UBSAN_SANITIZE := n
Christophe Leroyab037dd2020-11-27 00:10:05 +110039KASAN_SANITIZE := n
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Nick Desaulniers33dda8c2019-04-23 14:11:14 -070041ccflags-y := -shared -fno-common -fno-builtin -nostdlib \
42 -Wl,-soname=linux-vdso32.so.1 -Wl,--hash-style=both
matt mooney4108d9b2010-09-22 20:51:09 +000043asflags-y := -D__VDSO32__ -s
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45obj-y += vdso32_wrapper.o
Masahiro Yamada887af6d2020-09-01 03:22:39 +090046targets += vdso32.lds
Paul Mackerras271c3f32005-11-11 23:04:40 +110047CPPFLAGS_vdso32.lds += -P -C -Upowerpc
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Linus Torvalds1da177e2005-04-16 15:20:36 -070049# link rule for the .so file, .lds has to be first
Christophe Leroyab037dd2020-11-27 00:10:05 +110050$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday.o FORCE
51 $(call if_changed,vdso32ld_and_check)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53# assembly rules for the .S files
Nicholas Pigginb9a4a0d2016-08-09 22:17:29 +100054$(obj-vdso32): %.o: %.S FORCE
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 $(call if_changed_dep,vdso32as)
Christophe Leroyab037dd2020-11-27 00:10:05 +110056$(obj)/vgettimeofday.o: %.o: %.c FORCE
57 $(call if_changed_dep,vdso32cc)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Christophe Leroy91bf6952020-09-27 09:16:33 +000059# Generate VDSO offsets using helper script
60gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
61quiet_cmd_vdsosym = VDSOSYM $@
62 cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
63
64include/generated/vdso32-offsets.h: $(obj)/vdso32.so.dbg FORCE
65 $(call if_changed,vdsosym)
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067# actual build commands
Christophe Leroyab037dd2020-11-27 00:10:05 +110068quiet_cmd_vdso32ld_and_check = VDSO32L $@
69 cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check)
Linus Torvalds1da177e2005-04-16 15:20:36 -070070quiet_cmd_vdso32as = VDSO32A $@
Nicholas Pigginaf3901c2018-05-30 22:19:20 +100071 cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $<
Christophe Leroyab037dd2020-11-27 00:10:05 +110072quiet_cmd_vdso32cc = VDSO32C $@
73 cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $<