Commit | Line | Data |
---|---|---|
b2441318 | 1 | # SPDX-License-Identifier: GPL-2.0 |
1da177e4 LT |
2 | |
3 | # List of files in the vdso, has to be asm only for now | |
4 | ||
aff69273 | 5 | # Include the generic Makefile to check the built vdso. |
ab037dd8 CL |
6 | include $(srctree)/lib/vdso/Makefile |
7 | ||
d88378d8 | 8 | obj-vdso32 = sigtramp32-32.o gettimeofday-32.o datapage-32.o cacheflush-32.o note-32.o getcpu-32.o |
fd1feade | 9 | obj-vdso64 = sigtramp64-64.o gettimeofday-64.o datapage-64.o cacheflush-64.o note-64.o getcpu-64.o |
1da177e4 | 10 | |
ab037dd8 | 11 | ifneq ($(c-gettimeofday-y),) |
d88378d8 CL |
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 | |
05e05bfc NC |
19 | # This flag is supported by clang for 64-bit but not 32-bit so it will cause |
20 | # an unused command line flag warning for this file. | |
21 | ifdef CONFIG_CC_IS_CLANG | |
22 | CFLAGS_REMOVE_vgettimeofday-32.o += -fno-stack-clash-protection | |
23 | endif | |
fd1feade CL |
24 | CFLAGS_vgettimeofday-64.o += -include $(c-gettimeofday-y) |
25 | CFLAGS_vgettimeofday-64.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) | |
26 | CFLAGS_vgettimeofday-64.o += $(call cc-option, -fno-stack-protector) | |
27 | CFLAGS_vgettimeofday-64.o += -DDISABLE_BRANCH_PROFILING | |
28 | CFLAGS_vgettimeofday-64.o += -ffreestanding -fasynchronous-unwind-tables | |
29 | CFLAGS_REMOVE_vgettimeofday-64.o = $(CC_FLAGS_FTRACE) | |
30 | # Go prior to 1.16.x assumes r30 is not clobbered by any VDSO code. That used to be true | |
31 | # by accident when the VDSO was hand-written asm code, but may not be now that the VDSO is | |
32 | # compiler generated. To avoid breaking Go tell GCC not to use r30. Impact on code | |
33 | # generation is minimal, it will just use r29 instead. | |
34 | CFLAGS_vgettimeofday-64.o += $(call cc-option, -ffixed-r30) | |
ab037dd8 CL |
35 | endif |
36 | ||
1da177e4 LT |
37 | # Build rules |
38 | ||
af3901cb NP |
39 | ifdef CROSS32_COMPILE |
40 | VDSOCC := $(CROSS32_COMPILE)gcc | |
41 | else | |
42 | VDSOCC := $(CC) | |
43 | endif | |
44 | ||
d88378d8 | 45 | targets := $(obj-vdso32) vdso32.so.dbg vgettimeofday-32.o |
1da177e4 | 46 | obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32)) |
fd1feade CL |
47 | targets += $(obj-vdso64) vdso64.so.dbg vgettimeofday-64.o |
48 | obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64)) | |
1da177e4 | 49 | |
f0a42fba | 50 | ccflags-y := -fno-common -fno-builtin |
a7e5eb53 | 51 | ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack $(CLANG_FLAGS) |
f0a42fba | 52 | ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld) |
8ad57add NP |
53 | ldflags-$(CONFIG_LD_ORPHAN_WARN) += -Wl,--orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL) |
54 | ||
f0a42fba | 55 | # Filter flags that clang will warn are unused for linking |
4e3feaad | 56 | ldflags-y += $(filter-out $(CC_AUTO_VAR_INIT_ZERO_ENABLER) $(CC_FLAGS_FTRACE) -Wa$(comma)%, $(KBUILD_CFLAGS)) |
d88378d8 | 57 | |
f0a42fba NC |
58 | CC32FLAGS := -m32 |
59 | LD32FLAGS := -Wl,-soname=linux-vdso32.so.1 | |
024734d1 | 60 | AS32FLAGS := -D__VDSO32__ |
1da177e4 | 61 | |
f0a42fba | 62 | LD64FLAGS := -Wl,-soname=linux-vdso64.so.1 |
024734d1 | 63 | AS64FLAGS := -D__VDSO64__ |
fd1feade | 64 | |
887af6d7 | 65 | targets += vdso32.lds |
271c3f35 | 66 | CPPFLAGS_vdso32.lds += -P -C -Upowerpc |
fd1feade | 67 | targets += vdso64.lds |
42449052 | 68 | CPPFLAGS_vdso64.lds += -P -C |
1da177e4 | 69 | |
1da177e4 | 70 | # link rule for the .so file, .lds has to be first |
b957df3b | 71 | $(obj)/vdso32.so.dbg: $(obj)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday-32.o FORCE |
ab037dd8 | 72 | $(call if_changed,vdso32ld_and_check) |
b957df3b | 73 | $(obj)/vdso64.so.dbg: $(obj)/vdso64.lds $(obj-vdso64) $(obj)/vgettimeofday-64.o FORCE |
fd1feade | 74 | $(call if_changed,vdso64ld_and_check) |
1da177e4 LT |
75 | |
76 | # assembly rules for the .S files | |
d88378d8 | 77 | $(obj-vdso32): %-32.o: %.S FORCE |
1da177e4 | 78 | $(call if_changed_dep,vdso32as) |
d88378d8 | 79 | $(obj)/vgettimeofday-32.o: %-32.o: %.c FORCE |
ab037dd8 | 80 | $(call if_changed_dep,vdso32cc) |
fd1feade CL |
81 | $(obj-vdso64): %-64.o: %.S FORCE |
82 | $(call if_changed_dep,vdso64as) | |
83 | $(obj)/vgettimeofday-64.o: %-64.o: %.c FORCE | |
84 | $(call if_changed_dep,cc_o_c) | |
1da177e4 | 85 | |
91bf6955 | 86 | # Generate VDSO offsets using helper script |
b1992c37 | 87 | gen-vdso32sym := $(src)/gen_vdso32_offsets.sh |
d88378d8 CL |
88 | quiet_cmd_vdso32sym = VDSO32SYM $@ |
89 | cmd_vdso32sym = $(NM) $< | $(gen-vdso32sym) | LC_ALL=C sort > $@ | |
b1992c37 | 90 | gen-vdso64sym := $(src)/gen_vdso64_offsets.sh |
fd1feade CL |
91 | quiet_cmd_vdso64sym = VDSO64SYM $@ |
92 | cmd_vdso64sym = $(NM) $< | $(gen-vdso64sym) | LC_ALL=C sort > $@ | |
91bf6955 CL |
93 | |
94 | include/generated/vdso32-offsets.h: $(obj)/vdso32.so.dbg FORCE | |
d88378d8 | 95 | $(call if_changed,vdso32sym) |
fd1feade CL |
96 | include/generated/vdso64-offsets.h: $(obj)/vdso64.so.dbg FORCE |
97 | $(call if_changed,vdso64sym) | |
91bf6955 | 98 | |
1da177e4 | 99 | # actual build commands |
ab037dd8 | 100 | quiet_cmd_vdso32ld_and_check = VDSO32L $@ |
f0a42fba | 101 | cmd_vdso32ld_and_check = $(VDSOCC) $(ldflags-y) $(CC32FLAGS) $(LD32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check) |
1da177e4 | 102 | quiet_cmd_vdso32as = VDSO32A $@ |
d88378d8 | 103 | cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $< |
ab037dd8 CL |
104 | quiet_cmd_vdso32cc = VDSO32C $@ |
105 | cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $< | |
fd1feade CL |
106 | |
107 | quiet_cmd_vdso64ld_and_check = VDSO64L $@ | |
f0a42fba | 108 | cmd_vdso64ld_and_check = $(VDSOCC) $(ldflags-y) $(LD64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check) |
fd1feade | 109 | quiet_cmd_vdso64as = VDSO64A $@ |
f0a42fba | 110 | cmd_vdso64as = $(VDSOCC) $(a_flags) $(AS64FLAGS) -c -o $@ $< |